Skip to content

Commit 643f904

Browse files
committed
utils: Handle additional args to Invoke-BuildStep in build.ps1.
1 parent ad74442 commit 643f904

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

utils/build.ps1

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -558,12 +558,34 @@ function Get-InstallDir([Hashtable] $Platform) {
558558
$HostPlatform.ToolchainInstallRoot = "$(Get-InstallDir $HostPlatform)\Toolchains\$ProductVersion+$Variant"
559559

560560
# Build functions
561-
function Invoke-BuildStep([string] $Name, [Hashtable] $Platform) {
561+
function Invoke-BuildStep {
562+
[CmdletBinding(PositionalBinding = $false)]
563+
param
564+
(
565+
[Parameter(Position=0, Mandatory)]
566+
[string] $Name,
567+
[Parameter(Position=1, Mandatory)]
568+
[Hashtable] $Platform,
569+
[Parameter(ValueFromRemainingArguments)]
570+
$RemainingArgs
571+
)
572+
562573
if ($Summary) {
563574
$Stopwatch = [Diagnostics.Stopwatch]::StartNew()
564575
}
565576

566-
& $Name $Platform @Args
577+
$SplatArgs = @{}
578+
foreach ($Arg in $RemainingArgs) {
579+
if ($Arg -is [Hashtable]) {
580+
$SplatArgs += $Arg
581+
} elseif ($Arg -is [string]) {
582+
$SplatArgs[$Arg.TrimStart('-')] = $true
583+
} else {
584+
throw "$Arg is unknown type: $($Arg.GetType())"
585+
}
586+
}
587+
588+
& $Name $Platform @SplatArgs
567589

568590
if ($Summary) {
569591
Add-TimingData $Platform $Name $Stopwatch.Elapsed
@@ -3273,9 +3295,7 @@ if (-not $IsCrossCompiling) {
32733295
"-TestLLVM" = $Test -contains "llvm";
32743296
"-TestSwift" = $Test -contains "swift";
32753297
}
3276-
Write-Host "`$HostPlatform = $($HostPlatform | ConvertTo-Json)" -ForegroundColor Blue
3277-
Write-Host "`$Tests = $($Tests)" -ForegroundColor Magenta
3278-
Invoke-BuildStep Build-Compilers $HostPlatform @Tests
3298+
Invoke-BuildStep Build-Compilers $HostPlatform $Tests
32793299
}
32803300

32813301
if ($Test -contains "dispatch") { Invoke-BuildStep Test-Dispatch }

0 commit comments

Comments
 (0)