mirror of
https://github.com/pocoproject/poco.git
synced 2024-12-12 10:13:51 +01:00
parent
ebeef47a8c
commit
6b87beb723
2
build_vs170.cmd
Normal file
2
build_vs170.cmd
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
@echo off
|
||||||
|
buildwin 170 build shared both Win32 samples tests
|
@ -5,7 +5,7 @@ rem
|
|||||||
rem buildwin.cmd
|
rem buildwin.cmd
|
||||||
rem
|
rem
|
||||||
rem POCO C++ Libraries command-line build script
|
rem POCO C++ Libraries command-line build script
|
||||||
rem for MS Visual Studio 2015 to 2019
|
rem for MS Visual Studio 2015 to 2022
|
||||||
rem
|
rem
|
||||||
rem Copyright (c) 2006-2020 by Applied Informatics Software Engineering GmbH
|
rem Copyright (c) 2006-2020 by Applied Informatics Software Engineering GmbH
|
||||||
rem and Contributors.
|
rem and Contributors.
|
||||||
|
700
buildwin.ps1
700
buildwin.ps1
@ -4,7 +4,7 @@
|
|||||||
# Usage:
|
# Usage:
|
||||||
# ------
|
# ------
|
||||||
# buildwin.ps1 [-poco_base dir]
|
# buildwin.ps1 [-poco_base dir]
|
||||||
# [-vs 140 | 150 | 160]
|
# [-vs 140 | 150 | 160| 170]
|
||||||
# [-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]
|
||||||
@ -21,52 +21,52 @@
|
|||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
Param
|
Param
|
||||||
(
|
(
|
||||||
[Parameter()]
|
[Parameter()]
|
||||||
[string] $poco_base,
|
[string] $poco_base,
|
||||||
|
|
||||||
[Parameter()]
|
[Parameter()]
|
||||||
[ValidateSet(140, 150, 160)]
|
[ValidateSet(140, 150, 160, 170)]
|
||||||
[int] $vs = 140,
|
[int] $vs = 140,
|
||||||
|
|
||||||
[Parameter()]
|
[Parameter()]
|
||||||
[ValidateSet('build', 'rebuild', 'clean')]
|
[ValidateSet('build', 'rebuild', 'clean')]
|
||||||
[string] $action = 'build',
|
[string] $action = 'build',
|
||||||
|
|
||||||
[Parameter()]
|
[Parameter()]
|
||||||
[ValidateSet('shared', 'static_mt', 'static_md', 'all')]
|
[ValidateSet('shared', 'static_mt', 'static_md', 'all')]
|
||||||
[string] $linkmode = 'shared',
|
[string] $linkmode = 'shared',
|
||||||
|
|
||||||
[Parameter()]
|
[Parameter()]
|
||||||
[ValidateSet('release', 'debug', 'both')]
|
[ValidateSet('release', 'debug', 'both')]
|
||||||
[string] $config = 'release',
|
[string] $config = 'release',
|
||||||
|
|
||||||
[Parameter()]
|
[Parameter()]
|
||||||
[ValidateSet('Win32', 'x64', 'WinCE', 'WEC2013')]
|
[ValidateSet('Win32', 'x64', 'WinCE', 'WEC2013')]
|
||||||
[string] $platform = 'x64',
|
[string] $platform = 'x64',
|
||||||
|
|
||||||
[switch] $tests = $false,
|
[switch] $tests = $false,
|
||||||
[switch] $samples = $false,
|
[switch] $samples = $false,
|
||||||
[string] $omit,
|
[string] $omit,
|
||||||
|
|
||||||
[Parameter()]
|
[Parameter()]
|
||||||
[ValidateSet('msbuild', 'devenv')]
|
[ValidateSet('msbuild', 'devenv')]
|
||||||
[string] $tool = 'msbuild',
|
[string] $tool = 'msbuild',
|
||||||
|
|
||||||
[Parameter()]
|
[Parameter()]
|
||||||
[ValidateSet('env', 'noenv')]
|
[ValidateSet('env', 'noenv')]
|
||||||
[string] $useenv = 'env',
|
[string] $useenv = 'env',
|
||||||
|
|
||||||
[Parameter()]
|
[Parameter()]
|
||||||
[ValidateSet('quiet', 'm[inimal]', 'n[ormal]', 'd[etailed]', 'diag[nostic]')]
|
[ValidateSet('quiet', 'm[inimal]', 'n[ormal]', 'd[etailed]', 'diag[nostic]')]
|
||||||
[string] $verbosity = 'minimal',
|
[string] $verbosity = 'minimal',
|
||||||
|
|
||||||
[Parameter()]
|
[Parameter()]
|
||||||
[string] $openssl_base,
|
[string] $openssl_base,
|
||||||
|
|
||||||
[Parameter()]
|
[Parameter()]
|
||||||
[string] $mysql_base,
|
[string] $mysql_base,
|
||||||
|
|
||||||
[switch] $help
|
[switch] $help
|
||||||
)
|
)
|
||||||
|
|
||||||
function Add-VSCOMNTOOLS([int] $vsver)
|
function Add-VSCOMNTOOLS([int] $vsver)
|
||||||
@ -89,6 +89,10 @@ function Add-VSCOMNTOOLS([int] $vsver)
|
|||||||
{
|
{
|
||||||
$range='[16.0,17.0)'
|
$range='[16.0,17.0)'
|
||||||
}
|
}
|
||||||
|
if ($vsver -eq 170)
|
||||||
|
{
|
||||||
|
$range='[17.0,18.0)'
|
||||||
|
}
|
||||||
|
|
||||||
$installationPath = Get-VSSetupInstance | Select-VSSetupInstance -Version $range -Latest -Require Microsoft.VisualStudio.Component.VC.Tools.x86.x64 | select InstallationPath
|
$installationPath = Get-VSSetupInstance | Select-VSSetupInstance -Version $range -Latest -Require Microsoft.VisualStudio.Component.VC.Tools.x86.x64 | select InstallationPath
|
||||||
$vscomntools = $installationPath.psobject.properties.Value;
|
$vscomntools = $installationPath.psobject.properties.Value;
|
||||||
@ -102,399 +106,411 @@ function Add-VSCOMNTOOLS([int] $vsver)
|
|||||||
set-item -force -path "ENV:VS160COMNTOOLS" -value "$vscomntools\Common7\Tools\"
|
set-item -force -path "ENV:VS160COMNTOOLS" -value "$vscomntools\Common7\Tools\"
|
||||||
Write-Host "`nVS160COMNTOOLS=$env:VS160COMNTOOLS" -ForegroundColor Yellow
|
Write-Host "`nVS160COMNTOOLS=$env:VS160COMNTOOLS" -ForegroundColor Yellow
|
||||||
}
|
}
|
||||||
|
if ($vsver -eq 170)
|
||||||
|
{
|
||||||
|
set-item -force -path "ENV:VS170COMNTOOLS" -value "$vscomntools\Common7\Tools\"
|
||||||
|
Write-Host "`nVS170COMNTOOLS=$env:VS170COMNTOOLS" -ForegroundColor Yellow
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function Add-Env-Var([string] $lib, [string] $var)
|
function Add-Env-Var([string] $lib, [string] $var)
|
||||||
{
|
{
|
||||||
if ((${Env:$var} -eq $null) -or (-not ${Env:$var}.Contains(${Env:$lib_$var"})))
|
if ((${Env:$var} -eq $null) -or (-not ${Env:$var}.Contains(${Env:$lib_$var"})))
|
||||||
{
|
{
|
||||||
$libvar = "$lib" + "_" + "$var"
|
$libvar = "$lib" + "_" + "$var"
|
||||||
$envvar = [Environment]::GetEnvironmentVariable($var, "Process")
|
$envvar = [Environment]::GetEnvironmentVariable($var, "Process")
|
||||||
$envvar = $envvar + ';' + [Environment]::GetEnvironmentVariable($libvar, "Process")
|
$envvar = $envvar + ';' + [Environment]::GetEnvironmentVariable($libvar, "Process")
|
||||||
[Environment]::SetEnvironmentVariable($var, $envvar, "Process")
|
[Environment]::SetEnvironmentVariable($var, $envvar, "Process")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function Set-Environment
|
function Set-Environment
|
||||||
{
|
{
|
||||||
if ($poco_base -eq '') { $script:poco_base = Get-Location }
|
if ($poco_base -eq '') { $script:poco_base = Get-Location }
|
||||||
|
|
||||||
switch ( $vs )
|
switch ( $vs )
|
||||||
{
|
{
|
||||||
140 { }
|
140 { }
|
||||||
default { Add-VSCOMNTOOLS $vs }
|
default { Add-VSCOMNTOOLS $vs }
|
||||||
}
|
}
|
||||||
|
|
||||||
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"
|
||||||
Add-Env-Var "OPENSSL" "INCLUDE"
|
Add-Env-Var "OPENSSL" "INCLUDE"
|
||||||
Add-Env-Var "OPENSSL" "LIB"
|
Add-Env-Var "OPENSSL" "LIB"
|
||||||
|
|
||||||
if ($mysql_base -ne '')
|
if ($mysql_base -ne '')
|
||||||
{
|
{
|
||||||
$Env:MYSQL_DIR = "$mysql_base"
|
$Env:MYSQL_DIR = "$mysql_base"
|
||||||
$Env:MYSQL_INCLUDE = "$Env:MYSQL_DIR\include"
|
$Env:MYSQL_INCLUDE = "$Env:MYSQL_DIR\include"
|
||||||
$Env:MYSQL_LIB = "$Env:MYSQL_DIR\lib"
|
$Env:MYSQL_LIB = "$Env:MYSQL_DIR\lib"
|
||||||
Add-Env-Var "MYSQL" "INCLUDE"
|
Add-Env-Var "MYSQL" "INCLUDE"
|
||||||
Add-Env-Var "MYSQL" "LIB"
|
Add-Env-Var "MYSQL" "LIB"
|
||||||
}
|
}
|
||||||
|
|
||||||
$vsct = "VS$($vs)COMNTOOLS"
|
$vsct = "VS$($vs)COMNTOOLS"
|
||||||
$vsdir = ''
|
$vsdir = ''
|
||||||
$vsdir = (Get-Item Env:$vsct).Value
|
$vsdir = (Get-Item Env:$vsct).Value
|
||||||
$Command = ''
|
$Command = ''
|
||||||
$CommandArg = ''
|
$CommandArg = ''
|
||||||
if ($platform -eq 'x64') { $CommandArg = "amd64" }
|
if ($platform -eq 'x64') { $CommandArg = "amd64" }
|
||||||
else { $CommandArg = "x86" }
|
else { $CommandArg = "x86" }
|
||||||
if ($vs -eq 150)
|
if ($vs -eq 150)
|
||||||
{
|
{
|
||||||
$Command = Resolve-Path "$($vsdir)\..\..\VC\Auxiliary\Build\vcvarsall.bat"
|
$Command = Resolve-Path "$($vsdir)\..\..\VC\Auxiliary\Build\vcvarsall.bat"
|
||||||
$script:msbuild_exe = Resolve-Path "$($vsdir)\..\..\MSBuild\15.0\Bin\MSBuild.exe"
|
$script:msbuild_exe = Resolve-Path "$($vsdir)\..\..\MSBuild\15.0\Bin\MSBuild.exe"
|
||||||
} else {
|
} else {
|
||||||
if ($vs -eq 160)
|
if ($vs -eq 160)
|
||||||
{
|
{
|
||||||
$Command = Resolve-Path "$($vsdir)\..\..\VC\Auxiliary\Build\vcvarsall.bat"
|
$Command = Resolve-Path "$($vsdir)\..\..\VC\Auxiliary\Build\vcvarsall.bat"
|
||||||
$script:msbuild_exe = Resolve-Path "$($vsdir)\..\..\MSBuild\Current\Bin\MSBuild.exe"
|
$script:msbuild_exe = Resolve-Path "$($vsdir)\..\..\MSBuild\Current\Bin\MSBuild.exe"
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$Command = Resolve-Path "$($vsdir)\..\..\VC\vcvarsall.bat"
|
if ($vs -eq 170)
|
||||||
$script:msbuild_exe = "MSBuild.exe"
|
{
|
||||||
}}
|
$Command = Resolve-Path "$($vsdir)\..\..\VC\Auxiliary\Build\vcvarsall.bat"
|
||||||
|
$script:msbuild_exe = Resolve-Path "$($vsdir)\..\..\MSBuild\Current\Bin\MSBuild.exe"
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$Command = Resolve-Path "$($vsdir)\..\..\VC\vcvarsall.bat"
|
||||||
|
$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 {
|
||||||
if($_ -match "^(.*?)=(.*)$")
|
if($_ -match "^(.*?)=(.*)$")
|
||||||
{
|
{
|
||||||
Set-Content "Env:$($matches[1])" $matches[2]
|
Set-Content "Env:$($matches[1])" $matches[2]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Remove-Item $tempFile
|
Remove-Item $tempFile
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function Process-Input
|
function Process-Input
|
||||||
{
|
{
|
||||||
if ($help -eq $true)
|
if ($help -eq $true)
|
||||||
{
|
{
|
||||||
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 140 | 150 | 160]'
|
Write-Host ' [-vs 140 | 150 | 160 | 170]'
|
||||||
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]'
|
||||||
Write-Host ' [-platform Win32 | x64 | WinCE | WEC2013]'
|
Write-Host ' [-platform Win32 | x64 | WinCE | WEC2013]'
|
||||||
Write-Host ' [-samples]'
|
Write-Host ' [-samples]'
|
||||||
Write-Host ' [-tests]'
|
Write-Host ' [-tests]'
|
||||||
Write-Host ' [-omit "Lib1X;LibY;LibZ;..."]'
|
Write-Host ' [-omit "Lib1X;LibY;LibZ;..."]'
|
||||||
Write-Host ' [-tool msbuild | devenv]'
|
Write-Host ' [-tool msbuild | devenv]'
|
||||||
Write-Host ' [-useenv env | noenv]'
|
Write-Host ' [-useenv env | noenv]'
|
||||||
Write-Host ' [-verbosity minimal | quiet | normal | detailed | diagnostic'
|
Write-Host ' [-verbosity minimal | quiet | normal | detailed | diagnostic'
|
||||||
Write-Host ' [-openssl_base <dir>]'
|
Write-Host ' [-openssl_base <dir>]'
|
||||||
Write-Host ' [-mysql_base <dir>]'
|
Write-Host ' [-mysql_base <dir>]'
|
||||||
|
|
||||||
Exit
|
Exit
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Set-Environment
|
Set-Environment
|
||||||
|
|
||||||
Write-Host "Build configuration:"
|
Write-Host "Build configuration:"
|
||||||
Write-Host "--------------------"
|
Write-Host "--------------------"
|
||||||
Write-Host "Poco Base: $poco_base"
|
Write-Host "Poco Base: $poco_base"
|
||||||
Write-Host "Version: $vs"
|
Write-Host "Version: $vs"
|
||||||
Write-Host "Action: $action"
|
Write-Host "Action: $action"
|
||||||
Write-Host "Link Mode: $linkmode"
|
Write-Host "Link Mode: $linkmode"
|
||||||
Write-Host "Configuration: $config"
|
Write-Host "Configuration: $config"
|
||||||
Write-Host "Platform: $platform"
|
Write-Host "Platform: $platform"
|
||||||
Write-Host "Tests: $tests"
|
Write-Host "Tests: $tests"
|
||||||
Write-Host "Samples: $samples"
|
Write-Host "Samples: $samples"
|
||||||
Write-Host "Build Tool: $tool"
|
Write-Host "Build Tool: $tool"
|
||||||
|
|
||||||
if ($omit -ne '')
|
if ($omit -ne '')
|
||||||
{
|
{
|
||||||
Write-Host "Omit: $omit"
|
Write-Host "Omit: $omit"
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($openssl_base -ne '')
|
if ($openssl_base -ne '')
|
||||||
{
|
{
|
||||||
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")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function Exec-MSBuild([string] $vsProject, [string] $projectConfig)
|
function Exec-MSBuild([string] $vsProject, [string] $projectConfig)
|
||||||
{
|
{
|
||||||
if (!(Test-Path -Path $vsProject -PathType leaf)) {
|
if (!(Test-Path -Path $vsProject -PathType leaf)) {
|
||||||
Write-Host "Project $vsProject not found, skipping."
|
Write-Host "Project $vsProject not found, skipping."
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
$cmd = "&`"$script:msbuild_exe`" $vsProject /nologo /m /t:$action /p:Configuration=$projectConfig /p:BuildProjectReferences=false /p:Platform=$platform /p:useenv=$useenv /v:$verbosity"
|
$cmd = "&`"$script:msbuild_exe`" $vsProject /nologo /m /t:$action /p:Configuration=$projectConfig /p:BuildProjectReferences=false /p:Platform=$platform /p:useenv=$useenv /v:$verbosity"
|
||||||
Write-Host $cmd
|
Write-Host $cmd
|
||||||
Invoke-Expression $cmd
|
Invoke-Expression $cmd
|
||||||
if ($LastExitCode -ne 0) { Exit $LastExitCode }
|
if ($LastExitCode -ne 0) { Exit $LastExitCode }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function Build-MSBuild([string] $vsProject, [switch] $skipStatic)
|
function Build-MSBuild([string] $vsProject, [switch] $skipStatic)
|
||||||
{
|
{
|
||||||
if ($linkmode -contains "static" -and $skipStatic) { Return }
|
if ($linkmode -contains "static" -and $skipStatic) { Return }
|
||||||
|
|
||||||
if ($linkmode -eq 'all')
|
if ($linkmode -eq 'all')
|
||||||
{
|
{
|
||||||
$linkModeArr = @('shared')
|
$linkModeArr = @('shared')
|
||||||
if (-not $skipStatic)
|
if (-not $skipStatic)
|
||||||
{
|
{
|
||||||
$linkModeArr += 'static_mt', 'static_md'
|
$linkModeArr += 'static_mt', 'static_md'
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($mode in $linkModeArr)
|
foreach ($mode in $linkModeArr)
|
||||||
{
|
{
|
||||||
if ($config -eq 'both')
|
if ($config -eq 'both')
|
||||||
{
|
{
|
||||||
$configArr = 'release', 'debug'
|
$configArr = 'release', 'debug'
|
||||||
foreach ($cfg in $configArr)
|
foreach ($cfg in $configArr)
|
||||||
{
|
{
|
||||||
Exec-MSBuild $vsProject "$($cfg)_$($mode)"
|
Exec-MSBuild $vsProject "$($cfg)_$($mode)"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else #config
|
else #config
|
||||||
{
|
{
|
||||||
Exec-MSBuild $vsProject "$($config)_$($mode)"
|
Exec-MSBuild $vsProject "$($config)_$($mode)"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else #linkmode
|
else #linkmode
|
||||||
{
|
{
|
||||||
if ($config -eq 'both')
|
if ($config -eq 'both')
|
||||||
{
|
{
|
||||||
$configArr = 'release', 'debug'
|
$configArr = 'release', 'debug'
|
||||||
foreach ($cfg in $configArr)
|
foreach ($cfg in $configArr)
|
||||||
{
|
{
|
||||||
Exec-MSBuild $vsProject "$($cfg)_$($linkmode)"
|
Exec-MSBuild $vsProject "$($cfg)_$($linkmode)"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else #config
|
else #config
|
||||||
{
|
{
|
||||||
Exec-MSBuild $vsProject "$($config)_$($linkmode)"
|
Exec-MSBuild $vsProject "$($config)_$($linkmode)"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function Exec-Devenv([string] $projectConfig, [string] $vsProject)
|
function Exec-Devenv([string] $projectConfig, [string] $vsProject)
|
||||||
{
|
{
|
||||||
$cmd = "devenv /useenv /$action $projectConfig $vsProject"
|
$cmd = "devenv /useenv /$action $projectConfig $vsProject"
|
||||||
Write-Host $cmd
|
Write-Host $cmd
|
||||||
Invoke-Expression $cmd
|
Invoke-Expression $cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function Build-Devenv([string] $vsProject, [switch] $skipStatic)
|
function Build-Devenv([string] $vsProject, [switch] $skipStatic)
|
||||||
{
|
{
|
||||||
if ($linkmode -contains "static" -and $skipStatic) { Return }
|
if ($linkmode -contains "static" -and $skipStatic) { Return }
|
||||||
|
|
||||||
if ($linkmode -eq 'all')
|
if ($linkmode -eq 'all')
|
||||||
{
|
{
|
||||||
$linkModeArr = @('shared')
|
$linkModeArr = @('shared')
|
||||||
if (-not $skipStatic)
|
if (-not $skipStatic)
|
||||||
{
|
{
|
||||||
$linkModeArr += 'static_mt', 'static_md'
|
$linkModeArr += 'static_mt', 'static_md'
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($mode in $linkModeArr)
|
foreach ($mode in $linkModeArr)
|
||||||
{
|
{
|
||||||
if ($config -eq 'both')
|
if ($config -eq 'both')
|
||||||
{
|
{
|
||||||
$configArr = 'release', 'debug'
|
$configArr = 'release', 'debug'
|
||||||
foreach ($cfg in $configArr)
|
foreach ($cfg in $configArr)
|
||||||
{
|
{
|
||||||
Exec-Devenv "$($cfg)_$($mode)" $vsProject
|
Exec-Devenv "$($cfg)_$($mode)" $vsProject
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else #config
|
else #config
|
||||||
{
|
{
|
||||||
Exec-Devenv "$($config)_$($mode)" $vsProject
|
Exec-Devenv "$($config)_$($mode)" $vsProject
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else #linkmode
|
else #linkmode
|
||||||
{
|
{
|
||||||
if ($config -eq 'both')
|
if ($config -eq 'both')
|
||||||
{
|
{
|
||||||
$configArr = 'release', 'debug'
|
$configArr = 'release', 'debug'
|
||||||
foreach ($cfg in $configArr)
|
foreach ($cfg in $configArr)
|
||||||
{
|
{
|
||||||
Exec-Devenv "$($cfg)_$($linkmode)" $vsProject
|
Exec-Devenv "$($cfg)_$($linkmode)" $vsProject
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else #config
|
else #config
|
||||||
{
|
{
|
||||||
Exec-Devenv "$($config)_$($linkmode)" $vsProject
|
Exec-Devenv "$($config)_$($linkmode)" $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 }
|
||||||
elseif ($tool -eq 'msbuild') { Build-MSBuild $sampleProjName }
|
elseif ($tool -eq 'msbuild') { Build-MSBuild $sampleProjName }
|
||||||
else{ Write-Host "Tool not supported: $tool" }
|
else{ Write-Host "Tool not supported: $tool" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function Build-Exec([string] $tool, [string] $vsProject, [switch] $skipStatic)
|
function Build-Exec([string] $tool, [string] $vsProject, [switch] $skipStatic)
|
||||||
{
|
{
|
||||||
if (!(Test-Path -Path $vsProject)) # not found
|
if (!(Test-Path -Path $vsProject)) # not found
|
||||||
{
|
{
|
||||||
Write-Host "+------------------------------------------------------------------"
|
Write-Host "+------------------------------------------------------------------"
|
||||||
Write-Host "| VS project $vsProject not found, skipping."
|
Write-Host "| VS project $vsProject not found, skipping."
|
||||||
Write-Host "+------------------------------------------------------------------"
|
Write-Host "+------------------------------------------------------------------"
|
||||||
Return
|
Return
|
||||||
}
|
}
|
||||||
if ($tool -eq 'devenv') { Build-Devenv $vsProject -skipStatic:$skipStatic }
|
if ($tool -eq 'devenv') { Build-Devenv $vsProject -skipStatic:$skipStatic }
|
||||||
elseif ($tool -eq 'msbuild') { Build-MSBuild $vsProject -skipStatic:$skipStatic }
|
elseif ($tool -eq 'msbuild') { Build-MSBuild $vsProject -skipStatic:$skipStatic }
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Write-Host "Build tool $tool not supported. Exiting."
|
Write-Host "Build tool $tool not supported. Exiting."
|
||||||
Exit -1
|
Exit -1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function Build-Components([string] $extension, [string] $platformName, [string] $type)
|
function Build-Components([string] $extension, [string] $platformName, [string] $type)
|
||||||
{
|
{
|
||||||
|
|
||||||
Get-Content "$poco_base\components" | Foreach-Object {
|
Get-Content "$poco_base\components" | Foreach-Object {
|
||||||
|
|
||||||
$component = $_
|
$component = $_
|
||||||
$componentDir = $_.Replace("/", "\")
|
$componentDir = $_.Replace("/", "\")
|
||||||
$componentArr = $_.split('/')
|
$componentArr = $_.split('/')
|
||||||
$componentName = $componentArr[$componentArr.Length - 1]
|
$componentName = $componentArr[$componentArr.Length - 1]
|
||||||
$suffix = "_vs$vs"
|
$suffix = "_vs$vs"
|
||||||
|
|
||||||
$omitArray = @()
|
$omitArray = @()
|
||||||
$omit.Split(',;') | ForEach {
|
$omit.Split(',;') | ForEach {
|
||||||
$omitArray += $_.Trim()
|
$omitArray += $_.Trim()
|
||||||
}
|
}
|
||||||
|
|
||||||
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)"
|
||||||
if (!(Test-Path -Path $vsProject)) # not found
|
if (!(Test-Path -Path $vsProject)) # not found
|
||||||
{
|
{
|
||||||
Write-Host "+------------------------------------------------------------------"
|
Write-Host "+------------------------------------------------------------------"
|
||||||
Write-Host "| VS project $vsProject not found, skipping."
|
Write-Host "| VS project $vsProject not found, skipping."
|
||||||
Write-Host "+------------------------------------------------------------------"
|
Write-Host "+------------------------------------------------------------------"
|
||||||
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 ($type -eq "lib")
|
if ($type -eq "lib")
|
||||||
{
|
{
|
||||||
Build-Exec $tool $vsProject
|
Build-Exec $tool $vsProject
|
||||||
}
|
}
|
||||||
ElseIf ($tests -and ($type -eq "test"))
|
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 "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
|
||||||
Write-Host "| Building $vsTestProject"
|
Write-Host "| Building $vsTestProject"
|
||||||
Write-Host "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
|
Write-Host "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
|
||||||
Build-Exec $tool $vsTestProject
|
Build-Exec $tool $vsTestProject
|
||||||
|
|
||||||
if ($component -eq "Foundation") # special case for Foundation, which needs test app and dll
|
if ($component -eq "Foundation") # special case for Foundation, which needs test app and dll
|
||||||
{
|
{
|
||||||
$vsTestProject = "$poco_base\$componentDir\testsuite\TestApp$($platformName)$($suffix).$($extension)"
|
$vsTestProject = "$poco_base\$componentDir\testsuite\TestApp$($platformName)$($suffix).$($extension)"
|
||||||
Write-Host "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
|
Write-Host "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
|
||||||
Write-Host "| Building $vsTestProject"
|
Write-Host "| Building $vsTestProject"
|
||||||
Write-Host "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
|
Write-Host "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
|
||||||
Build-Exec $tool $vsTestProject
|
Build-Exec $tool $vsTestProject
|
||||||
|
|
||||||
$vsTestProject = "$poco_base\$componentDir\testsuite\TestLibrary$($platformName)$($suffix).$($extension)"
|
$vsTestProject = "$poco_base\$componentDir\testsuite\TestLibrary$($platformName)$($suffix).$($extension)"
|
||||||
Write-Host "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
|
Write-Host "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
|
||||||
Write-Host "| Building $vsTestProject"
|
Write-Host "| Building $vsTestProject"
|
||||||
Write-Host "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
|
Write-Host "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
|
||||||
Build-Exec $tool $vsTestProject -skipStatic
|
Build-Exec $tool $vsTestProject -skipStatic
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ElseIf ($samples -and ($type -eq "sample"))
|
ElseIf ($samples -and ($type -eq "sample"))
|
||||||
{
|
{
|
||||||
if ($platform -eq 'x64')
|
if ($platform -eq 'x64')
|
||||||
{
|
{
|
||||||
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)" } `
|
||||||
| Build-samples "$_"
|
| Build-samples "$_"
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Get-Childitem "$poco_base\$($componentDir)" -Recurse |`
|
Get-Childitem "$poco_base\$($componentDir)" -Recurse |`
|
||||||
Where {$_.Extension -Match $extension -And $_.DirectoryName -Like "*samples*" -And $_.BaseName -Like "*$($suffix)" -And $_.BaseName -NotLike "*_x64_*" } `
|
Where {$_.Extension -Match $extension -And $_.DirectoryName -Like "*samples*" -And $_.BaseName -Like "*$($suffix)" -And $_.BaseName -NotLike "*_x64_*" } `
|
||||||
| Build-samples "$_"
|
| Build-samples "$_"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Write-Host "-------------------------------"
|
Write-Host "-------------------------------"
|
||||||
Write-Host "# Skipping $componentDir"
|
Write-Host "# Skipping $componentDir"
|
||||||
Write-Host "-------------------------------"
|
Write-Host "-------------------------------"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function Build
|
function Build
|
||||||
{
|
{
|
||||||
Process-Input
|
Process-Input
|
||||||
|
|
||||||
if ($vs -lt 100) { $extension = 'vcproj' }
|
if ($vs -lt 100) { $extension = 'vcproj' }
|
||||||
else { $extension = 'vcxproj' }
|
else { $extension = 'vcxproj' }
|
||||||
|
|
||||||
$platformName = ''
|
$platformName = ''
|
||||||
if ($platform -eq 'x64') { $platformName = '_x64' }
|
if ($platform -eq 'x64') { $platformName = '_x64' }
|
||||||
elseif ($platform -eq 'WinCE') { $platformName = '_CE' }
|
elseif ($platform -eq 'WinCE') { $platformName = '_CE' }
|
||||||
|
|
||||||
Build-Components $extension $platformName "lib"
|
Build-Components $extension $platformName "lib"
|
||||||
Build-Components $extension $platformName "test"
|
Build-Components $extension $platformName "test"
|
||||||
Build-Components $extension $platformName "sample"
|
Build-Components $extension $platformName "sample"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user