2023-11-08 15:12:16 +01:00
|
|
|
#
|
|
|
|
# POCO progen automation script
|
|
|
|
#
|
|
|
|
# Usage:
|
|
|
|
# ------
|
|
|
|
# progen.ps1 [-poco_base dir]
|
2024-01-31 22:07:07 +01:00
|
|
|
# [-vs 160| 170]
|
2023-11-08 15:12:16 +01:00
|
|
|
# [-omit "Lib1X,LibY,LibZ,..."]
|
2023-11-13 22:34:45 +01:00
|
|
|
# [-components "Lib1X,LibY,LibZ,..."]
|
2023-12-14 00:25:04 +01:00
|
|
|
# [-platform Win32 | x64 | ARM64 | WEC2013]
|
2023-11-09 09:10:34 +01:00
|
|
|
# [-samples]
|
|
|
|
# [-tests]
|
2023-11-13 22:34:45 +01:00
|
|
|
# [-nobuild]
|
2023-11-08 15:12:16 +01:00
|
|
|
|
|
|
|
[CmdletBinding()]
|
|
|
|
Param
|
|
|
|
(
|
|
|
|
[Parameter()]
|
2023-11-13 22:34:45 +01:00
|
|
|
[string] $poco_base = $([System.Environment]::GetEnvironmentVariable('POCO_BASE')),
|
2023-11-08 15:12:16 +01:00
|
|
|
|
|
|
|
[Parameter()]
|
2024-01-31 22:07:07 +01:00
|
|
|
[ValidateSet(160, 170)]
|
2023-11-13 22:34:45 +01:00
|
|
|
[int] $vs = 170,
|
2023-11-08 15:12:16 +01:00
|
|
|
|
|
|
|
[string] $omit,
|
2023-11-13 22:34:45 +01:00
|
|
|
[string] $components,
|
|
|
|
|
|
|
|
[Parameter()]
|
2023-12-14 00:25:04 +01:00
|
|
|
[ValidateSet('Win32', 'x64', 'ARM64', 'WEC2013')]
|
2023-11-13 22:34:45 +01:00
|
|
|
[string] $platform = 'x64',
|
|
|
|
|
2023-11-09 09:10:34 +01:00
|
|
|
[switch] $samples = $false,
|
|
|
|
[switch] $tests = $false,
|
2023-11-13 22:34:45 +01:00
|
|
|
[switch] $nobuild = $false,
|
|
|
|
|
2023-11-08 15:12:16 +01:00
|
|
|
|
|
|
|
[switch] $help
|
|
|
|
)
|
|
|
|
|
2023-11-13 22:34:45 +01:00
|
|
|
function ProcessInput
|
2023-11-08 15:12:16 +01:00
|
|
|
{
|
|
|
|
if ($help -eq $true)
|
|
|
|
{
|
|
|
|
Write-Host 'Usage:'
|
|
|
|
Write-Host '------'
|
|
|
|
Write-Host 'progen.ps1 [-poco_base <dir>]'
|
2024-01-31 22:07:07 +01:00
|
|
|
Write-Host ' [-vs 160 | 170]'
|
2023-11-08 15:12:16 +01:00
|
|
|
Write-Host ' [-omit "Lib1X,LibY,LibZ,..."]'
|
2023-11-13 22:34:45 +01:00
|
|
|
Write-Host ' [-components "Lib1X,LibY,LibZ,..."]'
|
2023-11-09 09:10:34 +01:00
|
|
|
Write-Host ' [-samples]'
|
|
|
|
Write-Host ' [-tests]'
|
2023-11-13 22:34:45 +01:00
|
|
|
Write-Host ' [-nobuild]'
|
2023-11-08 15:12:16 +01:00
|
|
|
Exit
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-11-13 22:34:45 +01:00
|
|
|
if($components -ne '' -and $omit -ne '') {
|
|
|
|
Write-Host "-components and -omit cannot be used simultaneously, exiting..."
|
|
|
|
Exit
|
|
|
|
}
|
2023-11-08 15:12:16 +01:00
|
|
|
Write-Host ""
|
|
|
|
Write-Host "--------------------"
|
|
|
|
Write-Host "Progen configuration:"
|
|
|
|
Write-Host "--------------------"
|
|
|
|
Write-Host "Poco Base: $poco_base"
|
|
|
|
Write-Host "Version: $vs"
|
2023-11-09 09:10:34 +01:00
|
|
|
Write-Host "Samples: $samples"
|
|
|
|
Write-Host "Tests: $tests"
|
2023-11-13 22:34:45 +01:00
|
|
|
Write-Host "No Build: $nobuild"
|
2023-11-08 15:12:16 +01:00
|
|
|
|
|
|
|
if ($omit -ne '')
|
|
|
|
{
|
|
|
|
Write-Host "Omit: $omit"
|
|
|
|
}
|
|
|
|
|
2023-11-13 22:34:45 +01:00
|
|
|
if ($components -ne '')
|
|
|
|
{
|
|
|
|
Write-Host "Components: $components"
|
|
|
|
}
|
|
|
|
|
2023-11-08 15:12:16 +01:00
|
|
|
Write-Host "----------------------------------------"
|
|
|
|
Write-Host ""
|
|
|
|
|
|
|
|
# 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")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-11-13 22:34:45 +01:00
|
|
|
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
|
2023-11-09 09:10:34 +01:00
|
|
|
{
|
|
|
|
process {
|
|
|
|
$sampleName = $_.BaseName.split(".")[0]
|
|
|
|
if($_.Name -eq "samples.progen") {
|
|
|
|
Write-Host "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
|
|
|
|
Write-Host "| Running Progen for $componentDir\$sampleName"
|
|
|
|
Write-Host "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
|
|
|
|
$sampleProgenPath = "$($poco_base)\$($componentDir)\$($sampleName)\$($_)"
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
Write-Host "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
|
|
|
|
Write-Host "| Running Progen for $componentDir\samples\$sampleName"
|
|
|
|
Write-Host "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
|
|
|
|
$sampleProgenPath = "$($poco_base)\$($componentDir)\samples\$($sampleName)\$($_)"
|
|
|
|
}
|
2023-11-13 22:34:45 +01:00
|
|
|
InvokeProcess $progenPath "/tool=vs$vs $sampleProgenPath"
|
2023-11-09 09:10:34 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-11-13 22:34:45 +01:00
|
|
|
function InvokeProgenComponents([string] $type)
|
2023-11-08 15:12:16 +01:00
|
|
|
{
|
2023-11-08 15:34:35 +01:00
|
|
|
if(Test-Path "$poco_base\ProGen\bin64\static_mt\progen.exe") {
|
|
|
|
$progenPath = Resolve-Path "$poco_base\ProGen\bin64\static_mt\progen.exe"
|
|
|
|
}
|
|
|
|
elseif(Test-Path "$poco_base\ProGen\bin64\static_md\progen.exe") {
|
|
|
|
$progenPath = Resolve-Path "$poco_base\ProGen\bin64\static_md\progen.exe"
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$progenPath = Resolve-Path "$poco_base\ProGen\bin64\progen.exe"
|
|
|
|
}
|
2023-11-13 22:34:45 +01:00
|
|
|
$exists = Test-Path "$poco_base\ProGen\bin64\static_mt\progen.exe"
|
|
|
|
if (-not $exists) {
|
|
|
|
Write-Error "Progen not found, exiting..."
|
|
|
|
Exit -1
|
|
|
|
}
|
|
|
|
|
2023-11-08 15:12:16 +01:00
|
|
|
Get-Content "$poco_base\components" | Foreach-Object {
|
|
|
|
|
|
|
|
$component = $_
|
|
|
|
$componentDir = $_.Replace("/", "\")
|
|
|
|
$componentArr = $_.split('/')
|
|
|
|
$componentName = $componentArr[$componentArr.Length - 1]
|
|
|
|
|
|
|
|
$omitArray = @()
|
|
|
|
$omit.Split(',') | ForEach-Object {
|
|
|
|
$omitArray += $_.Trim()
|
|
|
|
}
|
|
|
|
|
2023-11-13 22:34:45 +01:00
|
|
|
$componentsArray = @()
|
|
|
|
$components.Split(',') | ForEach-Object {
|
|
|
|
$componentsArray += $_.Trim()
|
|
|
|
}
|
2023-11-08 15:12:16 +01:00
|
|
|
|
2023-11-13 22:34:45 +01:00
|
|
|
if ($omitArray -NotContains $component -and (-not ($component -Contains "Foundation")) -and (($componentsArray -Contains $component) -or ($components -eq '')))
|
|
|
|
{
|
2023-11-09 09:10:34 +01:00
|
|
|
if($type -eq "lib") {
|
2023-11-13 22:34:45 +01:00
|
|
|
Write-Host "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
|
|
|
|
Write-Host "| Running ProGen for $componentDir"
|
|
|
|
Write-Host "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
|
|
|
|
$componentProgenPath = "$poco_base\$componentDir\$componentName.progen"
|
|
|
|
InvokeProcess $progenPath "/tool=vs$vs $componentProgenPath"
|
2023-11-09 09:10:34 +01:00
|
|
|
}
|
|
|
|
ElseIf ($tests -and ($type -eq "test")) {
|
|
|
|
$componentTestProgenPath = "$poco_base\$componentDir\testsuite\TestSuite.Progen"
|
|
|
|
Write-Host "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
|
|
|
|
Write-Host "| Running Progen for $componentDir\testsuite"
|
|
|
|
Write-Host "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
|
2023-11-13 22:34:45 +01:00
|
|
|
InvokeProcess $progenPath "/tool=vs$vs $componentTestProgenPath"
|
|
|
|
|
|
|
|
if ($component -eq "Data") # special case for Data
|
|
|
|
{
|
2024-02-19 09:58:05 +01:00
|
|
|
$componentTestProgenPath = "$poco_base\$componentDir\DataTest\DataTest.progen"
|
2023-11-13 22:34:45 +01:00
|
|
|
Write-Host "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
|
2024-02-19 09:58:05 +01:00
|
|
|
Write-Host "| Running Progen for $componentDir\DataTest"
|
2023-11-13 22:34:45 +01:00
|
|
|
Write-Host "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
|
|
|
|
InvokeProcess $progenPath "/tool=vs$vs $componentTestProgenPath"
|
|
|
|
}
|
2023-11-09 09:10:34 +01:00
|
|
|
}
|
|
|
|
ElseIf ($samples -and ($type -eq "sample")) {
|
|
|
|
Get-Childitem "$poco_base\$($componentDir)" -Recurse |`
|
|
|
|
Where-Object {$_.Extension -Match ".progen" -And $_.DirectoryName -Like "*samples*" } `
|
2023-11-13 22:34:45 +01:00
|
|
|
| InvokeProgenSamples "$_"
|
2023-11-09 09:10:34 +01:00
|
|
|
}
|
2023-11-08 15:12:16 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Write-Host "-------------------------------"
|
|
|
|
Write-Host "# Skipping $componentDir"
|
|
|
|
Write-Host "-------------------------------"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-11-13 22:34:45 +01:00
|
|
|
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 "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
|
|
|
|
}
|
|
|
|
|
2023-11-08 15:12:16 +01:00
|
|
|
function Run
|
|
|
|
{
|
2023-11-13 22:34:45 +01:00
|
|
|
ProcessInput
|
|
|
|
|
|
|
|
if($nobuild -eq $false) {
|
|
|
|
InvokeBuildWin
|
|
|
|
}
|
2023-11-08 15:12:16 +01:00
|
|
|
|
2023-11-13 22:34:45 +01:00
|
|
|
InvokeProgenComponents "lib"
|
|
|
|
InvokeProgenComponents "test"
|
|
|
|
InvokeProgenComponents "sample"
|
2023-11-08 15:12:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Run
|