Quiet platform and Apple validation wrappers
This commit is contained in:
@@ -80,7 +80,10 @@ param(
|
||||
"pp_app_core_main_toolbar_tests",
|
||||
"pp_app_core_quick_ui_tests",
|
||||
"pp_app_core_tools_menu_tests"
|
||||
)
|
||||
),
|
||||
[switch]$Quiet,
|
||||
[string]$LogDir = "out/logs/platform-build",
|
||||
[int]$FailureTailLines = 0
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
@@ -100,6 +103,64 @@ function Expand-ArgumentList {
|
||||
return $expanded
|
||||
}
|
||||
|
||||
function Limit-LogSlug {
|
||||
param(
|
||||
[string]$Value,
|
||||
[int]$MaxLength = 96
|
||||
)
|
||||
|
||||
if ($Value.Length -le $MaxLength) {
|
||||
return $Value
|
||||
}
|
||||
return $Value.Substring(0, $MaxLength)
|
||||
}
|
||||
|
||||
function Invoke-LoggedCommand {
|
||||
param(
|
||||
[string]$Command,
|
||||
[string[]]$Arguments,
|
||||
[string]$LogPath,
|
||||
[int]$FailureTailLines
|
||||
)
|
||||
|
||||
$started = Get-Date
|
||||
$exitCode = 0
|
||||
$restoreNativeCommandPreference = $false
|
||||
if (Get-Variable -Name PSNativeCommandUseErrorActionPreference -ErrorAction SilentlyContinue) {
|
||||
$previousNativeCommandPreference = $PSNativeCommandUseErrorActionPreference
|
||||
$PSNativeCommandUseErrorActionPreference = $false
|
||||
$restoreNativeCommandPreference = $true
|
||||
}
|
||||
try {
|
||||
& $Command @Arguments *> $LogPath
|
||||
$exitCode = $LASTEXITCODE
|
||||
if ($null -eq $exitCode) {
|
||||
$exitCode = 0
|
||||
}
|
||||
}
|
||||
catch {
|
||||
$_ | Out-File -LiteralPath $LogPath -Append -Encoding utf8
|
||||
$exitCode = 1
|
||||
}
|
||||
finally {
|
||||
if ($restoreNativeCommandPreference) {
|
||||
$PSNativeCommandUseErrorActionPreference = $previousNativeCommandPreference
|
||||
}
|
||||
}
|
||||
|
||||
$result = [ordered]@{
|
||||
exitCode = $exitCode
|
||||
elapsedMs = [int]((Get-Date) - $started).TotalMilliseconds
|
||||
log = $LogPath
|
||||
}
|
||||
|
||||
if ($exitCode -ne 0 -and $FailureTailLines -gt 0 -and (Test-Path -LiteralPath $LogPath)) {
|
||||
$result.failureTail = @(Get-Content -LiteralPath $LogPath -Tail $FailureTailLines | ForEach-Object { [string]$_ })
|
||||
}
|
||||
|
||||
return $result
|
||||
}
|
||||
|
||||
function Get-VcpkgRoot {
|
||||
$candidates = @()
|
||||
if ($env:VCPKG_ROOT) {
|
||||
@@ -153,6 +214,11 @@ if ($Presets | Where-Object { $_ -like "android-*" }) {
|
||||
$started = Get-Date
|
||||
$results = @()
|
||||
$overallExitCode = 0
|
||||
$runId = Get-Date -Format "yyyyMMdd-HHmmss"
|
||||
|
||||
if ($Quiet) {
|
||||
New-Item -ItemType Directory -Force -Path $LogDir | Out-Null
|
||||
}
|
||||
|
||||
foreach ($preset in $Presets) {
|
||||
$presetCmakeCommand = $cmakeCommand
|
||||
@@ -160,15 +226,35 @@ foreach ($preset in $Presets) {
|
||||
$presetCmakeCommand = "cmake"
|
||||
}
|
||||
|
||||
& $presetCmakeCommand --preset $preset
|
||||
$configureExitCode = $LASTEXITCODE
|
||||
$configureExitCode = 0
|
||||
$configureLog = $null
|
||||
if ($Quiet) {
|
||||
$configureLog = Join-Path -Path $LogDir -ChildPath ("{0}-configure-{1}.log" -f $runId, (Limit-LogSlug (($preset -replace "[^A-Za-z0-9_.-]", "_"))))
|
||||
$configureResult = Invoke-LoggedCommand `
|
||||
-Command $presetCmakeCommand `
|
||||
-Arguments @("--preset", $preset) `
|
||||
-LogPath $configureLog `
|
||||
-FailureTailLines $FailureTailLines
|
||||
$configureExitCode = $configureResult.exitCode
|
||||
}
|
||||
else {
|
||||
& $presetCmakeCommand --preset $preset
|
||||
$configureExitCode = $LASTEXITCODE
|
||||
}
|
||||
if ($configureExitCode -ne 0) {
|
||||
$overallExitCode = $configureExitCode
|
||||
$results += [ordered]@{
|
||||
$result = [ordered]@{
|
||||
preset = $preset
|
||||
stage = "configure"
|
||||
exitCode = $configureExitCode
|
||||
}
|
||||
if ($Quiet) {
|
||||
$result.log = $configureLog
|
||||
if ($configureResult.Contains("failureTail")) {
|
||||
$result.failureTail = $configureResult.failureTail
|
||||
}
|
||||
}
|
||||
$results += $result
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -177,18 +263,39 @@ foreach ($preset in $Presets) {
|
||||
$buildArgs += @("--target", $target)
|
||||
}
|
||||
|
||||
& $presetCmakeCommand @buildArgs
|
||||
$buildExitCode = $LASTEXITCODE
|
||||
$buildExitCode = 0
|
||||
$buildLog = $null
|
||||
if ($Quiet) {
|
||||
$safeTargets = Limit-LogSlug (($Targets -join "_") -replace "[^A-Za-z0-9_.-]", "_")
|
||||
$buildLog = Join-Path -Path $LogDir -ChildPath ("{0}-build-{1}-{2}.log" -f $runId, ($preset -replace "[^A-Za-z0-9_.-]", "_"), $safeTargets)
|
||||
$buildResult = Invoke-LoggedCommand `
|
||||
-Command $presetCmakeCommand `
|
||||
-Arguments $buildArgs `
|
||||
-LogPath $buildLog `
|
||||
-FailureTailLines $FailureTailLines
|
||||
$buildExitCode = $buildResult.exitCode
|
||||
}
|
||||
else {
|
||||
& $presetCmakeCommand @buildArgs
|
||||
$buildExitCode = $LASTEXITCODE
|
||||
}
|
||||
if ($buildExitCode -ne 0 -and $overallExitCode -eq 0) {
|
||||
$overallExitCode = $buildExitCode
|
||||
}
|
||||
|
||||
$results += [ordered]@{
|
||||
$result = [ordered]@{
|
||||
preset = $preset
|
||||
stage = "build"
|
||||
targets = $Targets
|
||||
exitCode = $buildExitCode
|
||||
}
|
||||
if ($Quiet) {
|
||||
$result.log = $buildLog
|
||||
if ($buildResult.Contains("failureTail")) {
|
||||
$result.failureTail = $buildResult.failureTail
|
||||
}
|
||||
}
|
||||
$results += $result
|
||||
}
|
||||
|
||||
$elapsed = [int]((Get-Date) - $started).TotalMilliseconds
|
||||
|
||||
Reference in New Issue
Block a user