4248 additional progen script feature (#4265)

* feat: add components argument to progen.ps1 #4248

* feat: add components argument to buildwin.ps1 #4248

* fix: fix buildwin output #4248

* fix: fix buildwin components argument check #4248

* feat: add calling buildwin to progen.ps1 #4248

* fix: fix progen build output #4248

* fix: call buildwin with static_mt linkmode #4248

* feat: run progen for Data/testsuite/DataTest #4248

* fix(progen.ps1): default poco_base; fix buildwin path; use Start-Process (to get exit code); rename non-name-compliant cmdlets

* fix(PS scripts): rename functions to comply with cmdlets names; add platform to progen

---------

Co-authored-by: Aleksandar Fabijanic <aleks-f@users.noreply.github.com>
This commit is contained in:
Nino Belušić 2023-11-13 22:34:45 +01:00 committed by GitHub
parent daeb9d7301
commit b8d9eab0b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 133 additions and 51 deletions

View File

@ -12,6 +12,7 @@
# [-samples]
# [-tests]
# [-omit "Lib1X,LibY,LibZ,..."]
# [-components "Lib1X,LibY,LibZ,..."]
# [-tool msbuild | devenv]
# [-useenv env | noenv]
# [-verbosity minimal | quiet | normal | detailed | diagnostic]
@ -22,7 +23,7 @@
Param
(
[Parameter()]
[string] $poco_base,
[string] $poco_base = $([System.Environment]::GetEnvironmentVariable('POCO_BASE')),
[Parameter()]
[ValidateSet(140, 150, 160, 170)]
@ -47,6 +48,7 @@ Param
[switch] $tests = $false,
[switch] $samples = $false,
[string] $omit,
[string] $components,
[Parameter()]
[ValidateSet('msbuild', 'devenv')]
@ -240,6 +242,7 @@ function Process-Input
Write-Host ' [-samples]'
Write-Host ' [-tests]'
Write-Host ' [-omit "Lib1X,LibY,LibZ,..."]'
Write-Host ' [-components "Lib1X,LibY,LibZ,..."]'
Write-Host ' [-tool msbuild | devenv]'
Write-Host ' [-useenv env | noenv]'
Write-Host ' [-verbosity minimal | quiet | normal | detailed | diagnostic'
@ -249,6 +252,10 @@ function Process-Input
}
else
{
if($components -ne '' -and $omit -ne '') {
Write-Host "-components and -omit cannot be used simultaneously, exiting..."
Exit 1
}
Set-Environment
Write-Host ""
@ -275,6 +282,11 @@ function Process-Input
Write-Host "Omit: $omit"
}
if ($components -ne '')
{
Write-Host "Components: $components"
}
if ($openssl_base -ne '')
{
Write-Host "OpenSSL: $openssl_base"
@ -295,7 +307,7 @@ function Process-Input
}
function Exec-MSBuild([string] $vsProject, [string] $projectConfig)
function ExecuteMSBuild([string] $vsProject, [string] $projectConfig)
{
if (!(Test-Path -Path $vsProject -PathType leaf)) {
Write-Host "Project $vsProject not found, skipping."
@ -309,7 +321,7 @@ function Exec-MSBuild([string] $vsProject, [string] $projectConfig)
}
function Build-MSBuild([string] $vsProject, [switch] $skipStatic)
function RunMSBuild([string] $vsProject, [switch] $skipStatic)
{
if ($linkmode -contains "static" -and $skipStatic) { Return }
if ($linkmode.Contains("static") -and $vsProject.Contains("TestLibrary"))
@ -333,12 +345,12 @@ function Build-MSBuild([string] $vsProject, [switch] $skipStatic)
$configArr = 'release', 'debug'
foreach ($cfg in $configArr)
{
Exec-MSBuild $vsProject "$($cfg)_$($mode)"
ExecuteMSBuild $vsProject "$($cfg)_$($mode)"
}
}
else #config
{
Exec-MSBuild $vsProject "$($config)_$($mode)"
ExecuteMSBuild $vsProject "$($config)_$($mode)"
}
}
}
@ -349,18 +361,18 @@ function Build-MSBuild([string] $vsProject, [switch] $skipStatic)
$configArr = 'release', 'debug'
foreach ($cfg in $configArr)
{
Exec-MSBuild $vsProject "$($cfg)_$($linkmode)"
ExecuteMSBuild $vsProject "$($cfg)_$($linkmode)"
}
}
else #config
{
Exec-MSBuild $vsProject "$($config)_$($linkmode)"
ExecuteMSBuild $vsProject "$($config)_$($linkmode)"
}
}
}
function Exec-Devenv([string] $projectConfig, [string] $vsProject)
function ExecuteDevenv([string] $projectConfig, [string] $vsProject)
{
$cmd = "devenv /useenv /$action $projectConfig $vsProject"
Write-Host $cmd
@ -368,7 +380,7 @@ function Exec-Devenv([string] $projectConfig, [string] $vsProject)
}
function Build-Devenv([string] $vsProject, [switch] $skipStatic)
function BuildDevenv([string] $vsProject, [switch] $skipStatic)
{
if ($linkmode -contains "static" -and $skipStatic) { Return }
@ -387,12 +399,12 @@ function Build-Devenv([string] $vsProject, [switch] $skipStatic)
$configArr = 'release', 'debug'
foreach ($cfg in $configArr)
{
Exec-Devenv "$($cfg)_$($mode)" $vsProject
ExecuteDevenv "$($cfg)_$($mode)" $vsProject
}
}
else #config
{
Exec-Devenv "$($config)_$($mode)" $vsProject
ExecuteDevenv "$($config)_$($mode)" $vsProject
}
}
}
@ -403,30 +415,30 @@ function Build-Devenv([string] $vsProject, [switch] $skipStatic)
$configArr = 'release', 'debug'
foreach ($cfg in $configArr)
{
Exec-Devenv "$($cfg)_$($linkmode)" $vsProject
ExecuteDevenv "$($cfg)_$($linkmode)" $vsProject
}
}
else #config
{
Exec-Devenv "$($config)_$($linkmode)" $vsProject
ExecuteDevenv "$($config)_$($linkmode)" $vsProject
}
}
}
function Build-samples
function BuildSamples
{
process {
$sampleName = $_.BaseName.split("_")[0]
$sampleProjName = "$($poco_base)\$($componentDir)\samples\$($sampleName)\$($_)"
if ($tool -eq 'devenv') { Build-Devenv $sampleProjName }
elseif ($tool -eq 'msbuild') { Build-MSBuild $sampleProjName }
if ($tool -eq 'devenv') { BuildDevenv $sampleProjName }
elseif ($tool -eq 'msbuild') { RunMSBuild $sampleProjName }
else{ Write-Host "Tool not supported: $tool" }
}
}
function Build-Exec([string] $tool, [string] $vsProject, [switch] $skipStatic)
function BuildExecute([string] $tool, [string] $vsProject, [switch] $skipStatic)
{
if (!(Test-Path -Path $vsProject)) # not found
{
@ -435,8 +447,8 @@ function Build-Exec([string] $tool, [string] $vsProject, [switch] $skipStatic)
Write-Host "+------------------------------------------------------------------"
Return
}
if ($tool -eq 'devenv') { Build-Devenv $vsProject -skipStatic:$skipStatic }
elseif ($tool -eq 'msbuild') { Build-MSBuild $vsProject -skipStatic:$skipStatic }
if ($tool -eq 'devenv') { BuildDevenv $vsProject -skipStatic:$skipStatic }
elseif ($tool -eq 'msbuild') { RunMSBuild $vsProject -skipStatic:$skipStatic }
else
{
Write-Host "Build tool $tool not supported. Exiting."
@ -445,7 +457,7 @@ function Build-Exec([string] $tool, [string] $vsProject, [switch] $skipStatic)
}
function Build-Components([string] $extension, [string] $type)
function BuildComponents([string] $extension, [string] $type)
{
Get-Content "$poco_base\components" | Foreach-Object {
@ -460,7 +472,12 @@ function Build-Components([string] $extension, [string] $type)
$omitArray += $_.Trim()
}
if ($omitArray -NotContains $component)
$componentsArray = @()
$components.Split(',') | ForEach-Object {
$componentsArray += $_.Trim()
}
if ($omitArray -NotContains $component -and (($componentsArray -Contains $component) -or ($components -eq '')))
{
$vsProject = "$poco_base\$componentDir\$componentName$($suffix).$($extension)"
@ -482,7 +499,7 @@ function Build-Components([string] $extension, [string] $type)
if ($type -eq "lib")
{
Build-Exec $tool $vsProject
BuildExecute $tool $vsProject
}
ElseIf ($tests -and ($type -eq "test"))
{
@ -490,7 +507,7 @@ function Build-Components([string] $extension, [string] $type)
Write-Host "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
Write-Host "| Building $vsTestProject"
Write-Host "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
Build-Exec $tool $vsTestProject
BuildExecute $tool $vsTestProject
if ($component -eq "Foundation") # special case for Foundation, which needs test app and dll
{
@ -498,13 +515,13 @@ function Build-Components([string] $extension, [string] $type)
Write-Host "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
Write-Host "| Building $vsTestProject"
Write-Host "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
Build-Exec $tool $vsTestProject
BuildExecute $tool $vsTestProject
$vsTestProject = "$poco_base\$componentDir\testsuite\TestLibrary$($suffix).$($extension)"
Write-Host "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
Write-Host "| Building $vsTestProject"
Write-Host "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
Build-Exec $tool $vsTestProject -skipStatic
BuildExecute $tool $vsTestProject -skipStatic
}
elseif ($component -eq "Data") # special case for Data, which needs DataTest lib
{
@ -512,7 +529,7 @@ function Build-Components([string] $extension, [string] $type)
Write-Host "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
Write-Host "| Building $vsTestProject"
Write-Host "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
Build-Exec $tool $vsTestProject
BuildExecute $tool $vsTestProject
}
}
ElseIf ($samples -and ($type -eq "sample"))
@ -521,13 +538,13 @@ function Build-Components([string] $extension, [string] $type)
{
Get-Childitem "$poco_base\$($componentDir)" -Recurse |`
Where-Object {$_.Extension -Match $extension -And $_.DirectoryName -Like "*samples*" -And $_.BaseName -Like "*$($suffix)" } `
| Build-samples "$_"
| BuildSamples "$_"
}
else
{
Get-Childitem "$poco_base\$($componentDir)" -Recurse |`
Where-Object {$_.Extension -Match $extension -And $_.DirectoryName -Like "*samples*" -And $_.BaseName -Like "*$($suffix)" -And $_.BaseName -NotLike "*_x64_*" } `
| Build-samples "$_"
| BuildSamples "$_"
}
}
}
@ -548,9 +565,9 @@ function Build
if ($vs -lt 100) { $extension = 'vcproj' }
else { $extension = 'vcxproj' }
Build-Components $extension "lib"
Build-Components $extension "test"
Build-Components $extension "sample"
BuildComponents $extension "lib"
BuildComponents $extension "test"
BuildComponents $extension "sample"
}

View File

@ -6,27 +6,38 @@
# progen.ps1 [-poco_base dir]
# [-vs 140 | 150 | 160| 170]
# [-omit "Lib1X,LibY,LibZ,..."]
# [-components "Lib1X,LibY,LibZ,..."]
# [-platform Win32 | x64 | ARM64 | WinCE | WEC2013]
# [-samples]
# [-tests]
# [-nobuild]
[CmdletBinding()]
Param
(
[Parameter()]
[string] $poco_base,
[string] $poco_base = $([System.Environment]::GetEnvironmentVariable('POCO_BASE')),
[Parameter()]
[ValidateSet(140, 150, 160, 170)]
[int] $vs = 140,
[int] $vs = 170,
[string] $omit,
[string] $components,
[Parameter()]
[ValidateSet('Win32', 'x64', 'ARM64', 'WinCE', 'WEC2013')]
[string] $platform = 'x64',
[switch] $samples = $false,
[switch] $tests = $false,
[switch] $nobuild = $false,
[switch] $help
)
function Process-Input
function ProcessInput
{
if ($help -eq $true)
{
@ -35,12 +46,18 @@ function Process-Input
Write-Host 'progen.ps1 [-poco_base <dir>]'
Write-Host ' [-vs 140 | 150 | 160 | 170]'
Write-Host ' [-omit "Lib1X,LibY,LibZ,..."]'
Write-Host ' [-components "Lib1X,LibY,LibZ,..."]'
Write-Host ' [-samples]'
Write-Host ' [-tests]'
Write-Host ' [-nobuild]'
Exit
}
else
{
if($components -ne '' -and $omit -ne '') {
Write-Host "-components and -omit cannot be used simultaneously, exiting..."
Exit
}
Write-Host ""
Write-Host "--------------------"
Write-Host "Progen configuration:"
@ -49,12 +66,18 @@ function Process-Input
Write-Host "Version: $vs"
Write-Host "Samples: $samples"
Write-Host "Tests: $tests"
Write-Host "No Build: $nobuild"
if ($omit -ne '')
{
Write-Host "Omit: $omit"
}
if ($components -ne '')
{
Write-Host "Components: $components"
}
Write-Host "----------------------------------------"
Write-Host ""
@ -64,7 +87,17 @@ function Process-Input
}
}
function Run-Progen-Samples
function InvokeProcess([string] $exe, [string] $arguments)
{
$proc = Start-Process -NoNewWindow -FilePath $exe -ArgumentList $arguments -PassThru
$handle = $proc.Handle # cache proc.Handle, necessary to get exit code
$proc.WaitForExit();
if ($proc.ExitCode -ne 0) {
Write-Warning "$_ exited with status code $($proc.ExitCode)"
}
}
function InvokeProgenSamples
{
process {
$sampleName = $_.BaseName.split(".")[0]
@ -80,11 +113,11 @@ function Run-Progen-Samples
Write-Host "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
$sampleProgenPath = "$($poco_base)\$($componentDir)\samples\$($sampleName)\$($_)"
}
Invoke-Expression "$progenPath /tool=vs$vs $sampleProgenPath"
InvokeProcess $progenPath "/tool=vs$vs $sampleProgenPath"
}
}
function Run-Progen-Components([string] $type)
function InvokeProgenComponents([string] $type)
{
if(Test-Path "$poco_base\ProGen\bin64\static_mt\progen.exe") {
$progenPath = Resolve-Path "$poco_base\ProGen\bin64\static_mt\progen.exe"
@ -95,6 +128,12 @@ function Run-Progen-Components([string] $type)
else {
$progenPath = Resolve-Path "$poco_base\ProGen\bin64\progen.exe"
}
$exists = Test-Path "$poco_base\ProGen\bin64\static_mt\progen.exe"
if (-not $exists) {
Write-Error "Progen not found, exiting..."
Exit -1
}
Get-Content "$poco_base\components" | Foreach-Object {
$component = $_
@ -107,28 +146,40 @@ function Run-Progen-Components([string] $type)
$omitArray += $_.Trim()
}
if ($omitArray -NotContains $component)
$componentsArray = @()
$components.Split(',') | ForEach-Object {
$componentsArray += $_.Trim()
}
if ($omitArray -NotContains $component -and (-not ($component -Contains "Foundation")) -and (($componentsArray -Contains $component) -or ($components -eq '')))
{
Write-Host "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
Write-Host "| Running ProGen for $componentDir"
Write-Host "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
if($type -eq "lib") {
$componentProgenPath = "$poco_base\$componentDir\$componentName.Progen"
Invoke-Expression "$progenPath /tool=vs$vs $componentProgenPath"
Write-Host "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
Write-Host "| Running ProGen for $componentDir"
Write-Host "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
$componentProgenPath = "$poco_base\$componentDir\$componentName.progen"
InvokeProcess $progenPath "/tool=vs$vs $componentProgenPath"
}
ElseIf ($tests -and ($type -eq "test")) {
$componentTestProgenPath = "$poco_base\$componentDir\testsuite\TestSuite.Progen"
Write-Host "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
Write-Host "| Running Progen for $componentDir\testsuite"
Write-Host "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
Invoke-Expression "$progenPath /tool=vs$vs $componentTestProgenPath"
InvokeProcess $progenPath "/tool=vs$vs $componentTestProgenPath"
if ($component -eq "Data") # special case for Data
{
$componentTestProgenPath = "$poco_base\$componentDir\testsuite\DataTest\DataTest.progen"
Write-Host "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
Write-Host "| Running Progen for $componentDir\testsuite\DataTest"
Write-Host "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
InvokeProcess $progenPath "/tool=vs$vs $componentTestProgenPath"
}
}
ElseIf ($samples -and ($type -eq "sample")) {
Get-Childitem "$poco_base\$($componentDir)" -Recurse |`
Where-Object {$_.Extension -Match ".progen" -And $_.DirectoryName -Like "*samples*" } `
| Run-Progen-Samples "$_"
| InvokeProgenSamples "$_"
}
}
else
@ -140,13 +191,27 @@ function Run-Progen-Components([string] $type)
}
}
function InvokeBuildWin {
Write-Host "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
Write-Host "| Building Foundation,XML,JSON,Util,Progen"
Write-Host "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
Invoke-Expression "$poco_base\buildwin.ps1 -poco_base $poco_base -platform $platform -linkmode static_mt -vs $vs -action build -components `"Foundation,XML,JSON,Util,Progen`" "
Write-Host "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
Write-Host "| Build finished."
Write-Host "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
}
function Run
{
Process-Input
ProcessInput
Run-Progen-Components "lib"
Run-Progen-Components "test"
Run-Progen-Components "sample"
if($nobuild -eq $false) {
InvokeBuildWin
}
InvokeProgenComponents "lib"
InvokeProgenComponents "test"
InvokeProgenComponents "sample"
}