mirror of
https://github.com/pocoproject/poco.git
synced 2024-12-12 18:20:26 +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
|
||||
#
|
||||
#
|
||||
# Usage:
|
||||
# ------
|
||||
# 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]
|
||||
# [-linkmode shared | static_mt | static_md | all]
|
||||
# [-config release | debug | both]
|
||||
@ -23,9 +24,13 @@ Param
|
||||
[string] $poco_base,
|
||||
|
||||
[Parameter()]
|
||||
[ValidateSet(90, 100, 110, 120, 140, 150)]
|
||||
[ValidateSet(140, 150)]
|
||||
[int] $vs_version,
|
||||
|
||||
[Parameter()]
|
||||
[ValidateSet('Community' , 'Professional' , 'Enterprise')]
|
||||
[string] $vs_flavor = 'Community',
|
||||
|
||||
[Parameter()]
|
||||
[ValidateSet('build', 'rebuild', 'clean')]
|
||||
[string] $action = 'build',
|
||||
@ -68,7 +73,6 @@ function Add-Env-Var([string] $lib, [string] $var)
|
||||
$envvar = [Environment]::GetEnvironmentVariable($libvar, "Process")
|
||||
[Environment]::SetEnvironmentVariable($var, $envvar, "Process")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -80,25 +84,21 @@ function Set-Environment
|
||||
{
|
||||
if ($Env:VS150COMNTOOLS -ne '') { $script:vs_version = 150 }
|
||||
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
|
||||
{
|
||||
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" }
|
||||
|
||||
if ($openssl_base -eq '')
|
||||
{
|
||||
$script:openssl_base = '$poco_base\openssl'
|
||||
}
|
||||
|
||||
|
||||
$Env:OPENSSL_DIR = "$openssl_base"
|
||||
$Env:OPENSSL_INCLUDE = "$Env:OPENSSL_DIR\include"
|
||||
$Env:OPENSSL_LIB = "$Env:OPENSSL_DIR\lib;$Env:OPENSSL_DIR\lib\VC"
|
||||
@ -115,6 +115,11 @@ function Set-Environment
|
||||
}
|
||||
|
||||
$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
|
||||
$Command = ''
|
||||
$CommandArg = ''
|
||||
@ -122,14 +127,15 @@ function Set-Environment
|
||||
else { $CommandArg = "x86" }
|
||||
if ($vs_version -ge 150)
|
||||
{
|
||||
$Command = "$($vsdir)\..\..\VC\Auxiliary\Build\vcvarsall.bat"
|
||||
$script:msbuild_exe = "$($vsdir)\..\..\MSBuild\15.0\Bin\MSBuild.exe"
|
||||
$Command = Resolve-Path "$($vsdir)\..\..\VC\Auxiliary\Build\vcvarsall.bat"
|
||||
$script:msbuild_exe = Resolve-Path "$($vsdir)\..\..\MSBuild\15.0\Bin\MSBuild.exe"
|
||||
}
|
||||
else
|
||||
{
|
||||
$Command = "$($vsdir)\..\..\VC\vcvarsall.bat"
|
||||
$Command = Resolve-Path "$($vsdir)\..\..\VC\vcvarsall.bat"
|
||||
$script:msbuild_exe = "MSBuild.exe"
|
||||
}
|
||||
|
||||
$tempFile = [IO.Path]::GetTempFileName()
|
||||
cmd /c " `"$Command`" $CommandArg && set > `"$tempFile`" "
|
||||
Get-Content $tempFile | Foreach-Object {
|
||||
@ -149,7 +155,8 @@ function Process-Input
|
||||
Write-Host 'Usage:'
|
||||
Write-Host '------'
|
||||
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 ' [-linkmode shared | static_mt | static_md | all]'
|
||||
Write-Host ' [-config release | debug | both]'
|
||||
@ -179,6 +186,11 @@ function Process-Input
|
||||
Write-Host "Samples: $samples"
|
||||
Write-Host "Build Tool: $tool"
|
||||
|
||||
if ($vs_version -eq 150)
|
||||
{
|
||||
Write-Host "VS flavor: $vs_flavor"
|
||||
}
|
||||
|
||||
if ($omit -ne '')
|
||||
{
|
||||
Write-Host "Omit: $omit"
|
||||
@ -188,15 +200,15 @@ function Process-Input
|
||||
{
|
||||
Write-Host "OpenSSL: $openssl_base"
|
||||
}
|
||||
|
||||
|
||||
if ($mysql_base -ne '')
|
||||
{
|
||||
Write-Host "MySQL: $mysql_base"
|
||||
}
|
||||
|
||||
# NB: this won't work in PowerShell ISE
|
||||
Write-Host "Press Ctrl-C to exit or any other key to continue ..."
|
||||
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyUp")
|
||||
#Write-Host "Press Ctrl-C to exit or any other key to continue ..."
|
||||
#$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyUp")
|
||||
}
|
||||
}
|
||||
|
||||
@ -208,7 +220,7 @@ function Exec-MSBuild([string] $vsProject, [string] $projectConfig)
|
||||
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
|
||||
Invoke-Expression $cmd
|
||||
if ($LastExitCode -ne 0) { Exit $LastExitCode }
|
||||
@ -305,7 +317,7 @@ function Build-Devenv([string] $vsProject)
|
||||
|
||||
function Build-samples
|
||||
{
|
||||
process {
|
||||
process {
|
||||
$sampleName = $_.BaseName.split("_")[0]
|
||||
$sampleProjName = "$($poco_base)\$($componentDir)\samples\$($sampleName)\$($_)"
|
||||
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 {
|
||||
|
||||
@ -333,7 +337,7 @@ function Build
|
||||
$componentArr = $_.split('/')
|
||||
$componentName = $componentArr[$componentArr.Length - 1]
|
||||
$suffix = "_vs$vs_version"
|
||||
|
||||
|
||||
$omitArray = @()
|
||||
$omit.Split(',;') | ForEach {
|
||||
$omitArray += "$_"
|
||||
@ -342,7 +346,7 @@ function Build
|
||||
if ($omitArray -NotContains $component)
|
||||
{
|
||||
$vsProject = "$poco_base\$componentDir\$componentName$($platformName)$($suffix).$($extension)"
|
||||
|
||||
|
||||
if (!(Test-Path -Path $vsProject)) # when VS project name is not same as directory name
|
||||
{
|
||||
$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"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Write-Host "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
|
||||
Write-Host "| Building $vsProject"
|
||||
Write-Host "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
|
||||
|
||||
if ($tool -eq 'devenv') { Build-Devenv $vsProject }
|
||||
elseif ($tool -eq 'msbuild') { Build-MSBuild $vsProject }
|
||||
elseif ($tool -ne '') { Write-Host "Build tool not supported: $tool" }
|
||||
else
|
||||
if ($type -eq "lib")
|
||||
{
|
||||
Write-Host "Build tool not specified. Exiting."
|
||||
Exit
|
||||
}
|
||||
|
||||
if ($tests)
|
||||
if ($tool -eq 'devenv') { Build-Devenv $vsProject }
|
||||
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."
|
||||
Exit -1
|
||||
}
|
||||
}
|
||||
ElseIf ($tests -and ($type -eq "test"))
|
||||
{
|
||||
$vsTestProject = "$poco_base\$componentDir\testsuite\TestSuite$($platformName)$($suffix).$($extension)"
|
||||
Write-Host "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
|
||||
@ -379,8 +385,7 @@ function Build
|
||||
elseif ($tool -eq 'msbuild') { Build-MSBuild $vsTestProject }
|
||||
else{ Write-Host "Tool not supported: $tool" }
|
||||
}
|
||||
|
||||
if ($samples)
|
||||
ElseIf ($samples -and ($type -eq "sample"))
|
||||
{
|
||||
Get-Childitem "$poco_base\$($componentDir)" -Recurse |`
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user