Skip to content

Commit

Permalink
4248 additional progen script feature (#4265)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
cunj123 and aleks-f authored Nov 13, 2023
1 parent daeb9d7 commit b8d9eab
Show file tree
Hide file tree
Showing 2 changed files with 133 additions and 51 deletions.
79 changes: 48 additions & 31 deletions buildwin.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -22,7 +23,7 @@
Param
(
[Parameter()]
[string] $poco_base,
[string] $poco_base = $([System.Environment]::GetEnvironmentVariable('POCO_BASE')),

[Parameter()]
[ValidateSet(140, 150, 160, 170)]
Expand All @@ -47,6 +48,7 @@ Param
[switch] $tests = $false,
[switch] $samples = $false,
[string] $omit,
[string] $components,

[Parameter()]
[ValidateSet('msbuild', 'devenv')]
Expand Down Expand Up @@ -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'
Expand All @@ -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 ""
Expand All @@ -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"
Expand All @@ -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."
Expand All @@ -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"))
Expand All @@ -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)"
}
}
}
Expand All @@ -349,26 +361,26 @@ 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
Invoke-Expression $cmd
}


function Build-Devenv([string] $vsProject, [switch] $skipStatic)
function BuildDevenv([string] $vsProject, [switch] $skipStatic)
{
if ($linkmode -contains "static" -and $skipStatic) { Return }

Expand All @@ -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
}
}
}
Expand All @@ -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
{
Expand All @@ -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."
Expand All @@ -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 {

Expand All @@ -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)"

Expand All @@ -482,37 +499,37 @@ function Build-Components([string] $extension, [string] $type)

if ($type -eq "lib")
{
Build-Exec $tool $vsProject
BuildExecute $tool $vsProject
}
ElseIf ($tests -and ($type -eq "test"))
{
$vsTestProject = "$poco_base\$componentDir\testsuite\TestSuite$($suffix).$($extension)"
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
{
$vsTestProject = "$poco_base\$componentDir\testsuite\TestApp$($suffix).$($extension)"
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
{
$vsTestProject = "$poco_base\$componentDir\testsuite\DataTest\DataTest$($suffix).$($extension)"
Write-Host "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
Write-Host "| Building $vsTestProject"
Write-Host "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
Build-Exec $tool $vsTestProject
BuildExecute $tool $vsTestProject
}
}
ElseIf ($samples -and ($type -eq "sample"))
Expand All @@ -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 "$_"
}
}
}
Expand All @@ -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"
}


Expand Down
Loading

0 comments on commit b8d9eab

Please sign in to comment.