mirror of
https://github.com/pocoproject/poco.git
synced 2024-12-13 10:32:57 +01:00
Backport from the develop branch.
This commit is contained in:
parent
a2e27cf19e
commit
9255903554
108
buildwin.ps1
108
buildwin.ps1
@ -1,10 +1,11 @@
|
|||||||
#
|
#
|
||||||
# POCO build script
|
# POCO build script
|
||||||
#
|
#
|
||||||
# Usage:
|
# Usage:
|
||||||
# ------
|
# ------
|
||||||
# buildwin.ps1 [-poco_base dir]
|
# buildwin.ps1 [-poco_base dir]
|
||||||
# [-vs_version 150 | 140 | 120 | 110 | 100 | 90]
|
# [-vs_version 150 | 140]
|
||||||
|
# [-vs_flavor Community | Professional | Enterprise]
|
||||||
# [-action build | rebuild | clean]
|
# [-action build | rebuild | clean]
|
||||||
# [-linkmode shared | static_mt | static_md | all]
|
# [-linkmode shared | static_mt | static_md | all]
|
||||||
# [-config release | debug | both]
|
# [-config release | debug | both]
|
||||||
@ -23,9 +24,13 @@ Param
|
|||||||
[string] $poco_base,
|
[string] $poco_base,
|
||||||
|
|
||||||
[Parameter()]
|
[Parameter()]
|
||||||
[ValidateSet(90, 100, 110, 120, 140, 150)]
|
[ValidateSet(140, 150)]
|
||||||
[int] $vs_version,
|
[int] $vs_version,
|
||||||
|
|
||||||
|
[Parameter()]
|
||||||
|
[ValidateSet('Community' , 'Professional' , 'Enterprise')]
|
||||||
|
[string] $vs_flavor = 'Community',
|
||||||
|
|
||||||
[Parameter()]
|
[Parameter()]
|
||||||
[ValidateSet('build', 'rebuild', 'clean')]
|
[ValidateSet('build', 'rebuild', 'clean')]
|
||||||
[string] $action = 'build',
|
[string] $action = 'build',
|
||||||
@ -68,7 +73,6 @@ function Add-Env-Var([string] $lib, [string] $var)
|
|||||||
$envvar = [Environment]::GetEnvironmentVariable($libvar, "Process")
|
$envvar = [Environment]::GetEnvironmentVariable($libvar, "Process")
|
||||||
[Environment]::SetEnvironmentVariable($var, $envvar, "Process")
|
[Environment]::SetEnvironmentVariable($var, $envvar, "Process")
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -80,25 +84,21 @@ function Set-Environment
|
|||||||
{
|
{
|
||||||
if ($Env:VS150COMNTOOLS -ne '') { $script:vs_version = 150 }
|
if ($Env:VS150COMNTOOLS -ne '') { $script:vs_version = 150 }
|
||||||
elseif ($Env:VS140COMNTOOLS -ne '') { $script:vs_version = 140 }
|
elseif ($Env:VS140COMNTOOLS -ne '') { $script:vs_version = 140 }
|
||||||
elseif ($Env:VS120COMNTOOLS -ne '') { $script:vs_version = 120 }
|
|
||||||
elseif ($Env:VS110COMNTOOLS -ne '') { $script:vs_version = 110 }
|
|
||||||
elseif ($Env:VS100COMNTOOLS -ne '') { $script:vs_version = 100 }
|
|
||||||
elseif ($Env:VS90COMNTOOLS -ne '') { $script:vs_version = 90 }
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Write-Host 'Visual Studio not found, exiting.'
|
Write-Host 'Visual Studio not found, exiting.'
|
||||||
Exit
|
Exit 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (-Not $Env:PATH.Contains("$Env:POCO_BASE\bin64;$Env:POCO_BASE\bin;"))
|
if (-Not $Env:PATH.Contains("$Env:POCO_BASE\bin64;$Env:POCO_BASE\bin;"))
|
||||||
{ $Env:PATH = "$Env:POCO_BASE\bin64;$Env:POCO_BASE\bin;$Env:PATH" }
|
{ $Env:PATH = "$Env:POCO_BASE\bin64;$Env:POCO_BASE\bin;$Env:PATH" }
|
||||||
|
|
||||||
if ($openssl_base -eq '')
|
if ($openssl_base -eq '')
|
||||||
{
|
{
|
||||||
$script:openssl_base = '$poco_base\openssl'
|
$script:openssl_base = '$poco_base\openssl'
|
||||||
}
|
}
|
||||||
|
|
||||||
$Env:OPENSSL_DIR = "$openssl_base"
|
$Env:OPENSSL_DIR = "$openssl_base"
|
||||||
$Env:OPENSSL_INCLUDE = "$Env:OPENSSL_DIR\include"
|
$Env:OPENSSL_INCLUDE = "$Env:OPENSSL_DIR\include"
|
||||||
$Env:OPENSSL_LIB = "$Env:OPENSSL_DIR\lib;$Env:OPENSSL_DIR\lib\VC"
|
$Env:OPENSSL_LIB = "$Env:OPENSSL_DIR\lib;$Env:OPENSSL_DIR\lib\VC"
|
||||||
@ -115,6 +115,11 @@ function Set-Environment
|
|||||||
}
|
}
|
||||||
|
|
||||||
$vsct = "VS$($vs_version)COMNTOOLS"
|
$vsct = "VS$($vs_version)COMNTOOLS"
|
||||||
|
$vsdir = ''
|
||||||
|
if ($vs_version -eq 150)
|
||||||
|
{
|
||||||
|
if (-not (Test-Path Env:$vsct)) { Set-Item -path Env:$vsct -value "C:\Program Files (x86)\Microsoft Visual Studio\2017\$($vs_flavor)\Common7\Tools" }
|
||||||
|
}
|
||||||
$vsdir = (Get-Item Env:$vsct).Value
|
$vsdir = (Get-Item Env:$vsct).Value
|
||||||
$Command = ''
|
$Command = ''
|
||||||
$CommandArg = ''
|
$CommandArg = ''
|
||||||
@ -122,14 +127,15 @@ function Set-Environment
|
|||||||
else { $CommandArg = "x86" }
|
else { $CommandArg = "x86" }
|
||||||
if ($vs_version -ge 150)
|
if ($vs_version -ge 150)
|
||||||
{
|
{
|
||||||
$Command = "$($vsdir)\..\..\VC\Auxiliary\Build\vcvarsall.bat"
|
$Command = Resolve-Path "$($vsdir)\..\..\VC\Auxiliary\Build\vcvarsall.bat"
|
||||||
$script:msbuild_exe = "$($vsdir)\..\..\MSBuild\15.0\Bin\MSBuild.exe"
|
$script:msbuild_exe = Resolve-Path "$($vsdir)\..\..\MSBuild\15.0\Bin\MSBuild.exe"
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$Command = "$($vsdir)\..\..\VC\vcvarsall.bat"
|
$Command = Resolve-Path "$($vsdir)\..\..\VC\vcvarsall.bat"
|
||||||
$script:msbuild_exe = "MSBuild.exe"
|
$script:msbuild_exe = "MSBuild.exe"
|
||||||
}
|
}
|
||||||
|
|
||||||
$tempFile = [IO.Path]::GetTempFileName()
|
$tempFile = [IO.Path]::GetTempFileName()
|
||||||
cmd /c " `"$Command`" $CommandArg && set > `"$tempFile`" "
|
cmd /c " `"$Command`" $CommandArg && set > `"$tempFile`" "
|
||||||
Get-Content $tempFile | Foreach-Object {
|
Get-Content $tempFile | Foreach-Object {
|
||||||
@ -149,7 +155,8 @@ function Process-Input
|
|||||||
Write-Host 'Usage:'
|
Write-Host 'Usage:'
|
||||||
Write-Host '------'
|
Write-Host '------'
|
||||||
Write-Host 'buildwin.ps1 [-poco_base dir]'
|
Write-Host 'buildwin.ps1 [-poco_base dir]'
|
||||||
Write-Host ' [-vs_version 150 | 140 | 120 | 110 | 100 | 90]'
|
Write-Host ' [-vs_version 150 | 140]'
|
||||||
|
Write-Host ' [-vs_flavor Community | Professional | Enterprise]'
|
||||||
Write-Host ' [-action build | rebuild | clean]'
|
Write-Host ' [-action build | rebuild | clean]'
|
||||||
Write-Host ' [-linkmode shared | static_mt | static_md | all]'
|
Write-Host ' [-linkmode shared | static_mt | static_md | all]'
|
||||||
Write-Host ' [-config release | debug | both]'
|
Write-Host ' [-config release | debug | both]'
|
||||||
@ -179,6 +186,11 @@ function Process-Input
|
|||||||
Write-Host "Samples: $samples"
|
Write-Host "Samples: $samples"
|
||||||
Write-Host "Build Tool: $tool"
|
Write-Host "Build Tool: $tool"
|
||||||
|
|
||||||
|
if ($vs_version -eq 150)
|
||||||
|
{
|
||||||
|
Write-Host "VS flavor: $vs_flavor"
|
||||||
|
}
|
||||||
|
|
||||||
if ($omit -ne '')
|
if ($omit -ne '')
|
||||||
{
|
{
|
||||||
Write-Host "Omit: $omit"
|
Write-Host "Omit: $omit"
|
||||||
@ -188,15 +200,15 @@ function Process-Input
|
|||||||
{
|
{
|
||||||
Write-Host "OpenSSL: $openssl_base"
|
Write-Host "OpenSSL: $openssl_base"
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($mysql_base -ne '')
|
if ($mysql_base -ne '')
|
||||||
{
|
{
|
||||||
Write-Host "MySQL: $mysql_base"
|
Write-Host "MySQL: $mysql_base"
|
||||||
}
|
}
|
||||||
|
|
||||||
# NB: this won't work in PowerShell ISE
|
# NB: this won't work in PowerShell ISE
|
||||||
Write-Host "Press Ctrl-C to exit or any other key to continue ..."
|
#Write-Host "Press Ctrl-C to exit or any other key to continue ..."
|
||||||
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyUp")
|
#$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyUp")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,7 +220,7 @@ function Exec-MSBuild([string] $vsProject, [string] $projectConfig)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
$cmd = "&`"$script:msbuild_exe`" $vsProject /t:$action /p:Configuration=$projectConfig /p:BuildProjectReferences=false /p:Platform=$platform /p:useenv=true"
|
$cmd = "&`"$script:msbuild_exe`" $vsProject /m /t:$action /p:Configuration=$projectConfig /p:BuildProjectReferences=false /p:Platform=$platform /p:useenv=true"
|
||||||
Write-Host $cmd
|
Write-Host $cmd
|
||||||
Invoke-Expression $cmd
|
Invoke-Expression $cmd
|
||||||
if ($LastExitCode -ne 0) { Exit $LastExitCode }
|
if ($LastExitCode -ne 0) { Exit $LastExitCode }
|
||||||
@ -305,7 +317,7 @@ function Build-Devenv([string] $vsProject)
|
|||||||
|
|
||||||
function Build-samples
|
function Build-samples
|
||||||
{
|
{
|
||||||
process {
|
process {
|
||||||
$sampleName = $_.BaseName.split("_")[0]
|
$sampleName = $_.BaseName.split("_")[0]
|
||||||
$sampleProjName = "$($poco_base)\$($componentDir)\samples\$($sampleName)\$($_)"
|
$sampleProjName = "$($poco_base)\$($componentDir)\samples\$($sampleName)\$($_)"
|
||||||
if ($tool -eq 'devenv') { Build-Devenv $sampleProjName }
|
if ($tool -eq 'devenv') { Build-Devenv $sampleProjName }
|
||||||
@ -315,16 +327,8 @@ function Build-samples
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function Build
|
function Build-Components([string] $extension, [string] $platformName, [string] $type)
|
||||||
{
|
{
|
||||||
Process-Input
|
|
||||||
|
|
||||||
if ($vs_version -lt 100) { $extension = 'vcproj' }
|
|
||||||
else { $extension = 'vcxproj' }
|
|
||||||
|
|
||||||
$platformName = ''
|
|
||||||
if ($platform -eq 'x64') { $platformName = '_x64' }
|
|
||||||
elseif ($platform -eq 'WinCE') { $platformName = '_CE' }
|
|
||||||
|
|
||||||
Get-Content "$poco_base\components" | Foreach-Object {
|
Get-Content "$poco_base\components" | Foreach-Object {
|
||||||
|
|
||||||
@ -333,7 +337,7 @@ function Build
|
|||||||
$componentArr = $_.split('/')
|
$componentArr = $_.split('/')
|
||||||
$componentName = $componentArr[$componentArr.Length - 1]
|
$componentName = $componentArr[$componentArr.Length - 1]
|
||||||
$suffix = "_vs$vs_version"
|
$suffix = "_vs$vs_version"
|
||||||
|
|
||||||
$omitArray = @()
|
$omitArray = @()
|
||||||
$omit.Split(',;') | ForEach {
|
$omit.Split(',;') | ForEach {
|
||||||
$omitArray += "$_"
|
$omitArray += "$_"
|
||||||
@ -342,7 +346,7 @@ function Build
|
|||||||
if ($omitArray -NotContains $component)
|
if ($omitArray -NotContains $component)
|
||||||
{
|
{
|
||||||
$vsProject = "$poco_base\$componentDir\$componentName$($platformName)$($suffix).$($extension)"
|
$vsProject = "$poco_base\$componentDir\$componentName$($platformName)$($suffix).$($extension)"
|
||||||
|
|
||||||
if (!(Test-Path -Path $vsProject)) # when VS project name is not same as directory name
|
if (!(Test-Path -Path $vsProject)) # when VS project name is not same as directory name
|
||||||
{
|
{
|
||||||
$vsProject = "$poco_base\$componentDir$($platformName)$($suffix).$($extension)"
|
$vsProject = "$poco_base\$componentDir$($platformName)$($suffix).$($extension)"
|
||||||
@ -354,21 +358,23 @@ function Build
|
|||||||
Return # since Foreach-Object is a function, this is actually loop "continue"
|
Return # since Foreach-Object is a function, this is actually loop "continue"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Host "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
|
Write-Host "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
|
||||||
Write-Host "| Building $vsProject"
|
Write-Host "| Building $vsProject"
|
||||||
Write-Host "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
|
Write-Host "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
|
||||||
|
|
||||||
if ($tool -eq 'devenv') { Build-Devenv $vsProject }
|
if ($type -eq "lib")
|
||||||
elseif ($tool -eq 'msbuild') { Build-MSBuild $vsProject }
|
|
||||||
elseif ($tool -ne '') { Write-Host "Build tool not supported: $tool" }
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
Write-Host "Build tool not specified. Exiting."
|
if ($tool -eq 'devenv') { Build-Devenv $vsProject }
|
||||||
Exit
|
elseif ($tool -eq 'msbuild') { Build-MSBuild $vsProject }
|
||||||
}
|
elseif ($tool -ne '') { Write-Host "Build tool not supported: $tool" }
|
||||||
|
else
|
||||||
if ($tests)
|
{
|
||||||
|
Write-Host "Build tool not specified. Exiting."
|
||||||
|
Exit -1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ElseIf ($tests -and ($type -eq "test"))
|
||||||
{
|
{
|
||||||
$vsTestProject = "$poco_base\$componentDir\testsuite\TestSuite$($platformName)$($suffix).$($extension)"
|
$vsTestProject = "$poco_base\$componentDir\testsuite\TestSuite$($platformName)$($suffix).$($extension)"
|
||||||
Write-Host "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
|
Write-Host "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
|
||||||
@ -379,8 +385,7 @@ function Build
|
|||||||
elseif ($tool -eq 'msbuild') { Build-MSBuild $vsTestProject }
|
elseif ($tool -eq 'msbuild') { Build-MSBuild $vsTestProject }
|
||||||
else{ Write-Host "Tool not supported: $tool" }
|
else{ Write-Host "Tool not supported: $tool" }
|
||||||
}
|
}
|
||||||
|
ElseIf ($samples -and ($type -eq "sample"))
|
||||||
if ($samples)
|
|
||||||
{
|
{
|
||||||
Get-Childitem "$poco_base\$($componentDir)" -Recurse |`
|
Get-Childitem "$poco_base\$($componentDir)" -Recurse |`
|
||||||
Where {$_.Extension -Match $extension -And $_.DirectoryName -Like "*samples*" -And $_.BaseName -Like "*$platformName$($suffix)" } `
|
Where {$_.Extension -Match $extension -And $_.DirectoryName -Like "*samples*" -And $_.BaseName -Like "*$platformName$($suffix)" } `
|
||||||
@ -397,4 +402,21 @@ function Build
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function Build
|
||||||
|
{
|
||||||
|
Process-Input
|
||||||
|
|
||||||
|
if ($vs_version -lt 100) { $extension = 'vcproj' }
|
||||||
|
else { $extension = 'vcxproj' }
|
||||||
|
|
||||||
|
$platformName = ''
|
||||||
|
if ($platform -eq 'x64') { $platformName = '_x64' }
|
||||||
|
elseif ($platform -eq 'WinCE') { $platformName = '_CE' }
|
||||||
|
|
||||||
|
Build-Components $extension $platformName "lib"
|
||||||
|
Build-Components $extension $platformName "test"
|
||||||
|
Build-Components $extension $platformName "sample"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Build
|
Build
|
||||||
|
Loading…
Reference in New Issue
Block a user