Skip to content

Commit e774ff1

Browse files
committed
utils: Make build.ps1 work with PowerShell Core
Windows PowerShell (version 5) and PowerShell Core (versions 6+) do not handle escaping parameters for external programs invocation in the same manner. In order to keep the script compatible with both editions of PowerShell, these changes use the appropriate quote escaping style depending on the PowerShell edition. This also clears out the progress bars that can ghost in following a call to `Remove-Item` in PowerShell Core.
1 parent f3ae536 commit e774ff1

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

utils/build.ps1

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1678,8 +1678,10 @@ function Build-CMakeProject {
16781678

16791679
$ArgWithForwardSlashes = $Arg.Replace("\", "/")
16801680
if ($ArgWithForwardSlashes.Contains(" ")) {
1681-
# Quote and escape the quote so it makes it through
1682-
$Value += "\""$ArgWithForwardSlashes\"""
1681+
# Escape the quote so it makes it through. PowerShell 5 and Core
1682+
# handle quotes differently, so we need to check the version.
1683+
$quote = if ($PSEdition -eq "Core") { '"' } else { '\"' }
1684+
$Value += "$quote$ArgWithForwardSlashes$quote"
16831685
} else {
16841686
$Value += $ArgWithForwardSlashes
16851687
}
@@ -3693,6 +3695,9 @@ if (-not $SkipBuild) {
36933695

36943696
Remove-Item -Force -Recurse ([IO.Path]::Combine((Get-InstallDir $HostPlatform), "Platforms")) -ErrorAction Ignore
36953697

3698+
# Clear the progress bar from the output or it keeps ghosting.
3699+
1..10 | ForEach-Object { Write-Progress -Id $_ -Activity "Removing previous Platforms directory" -Completed }
3700+
36963701
Invoke-BuildStep Build-CMark $BuildPlatform
36973702
Invoke-BuildStep Build-BuildTools $BuildPlatform
36983703
if ($IsCrossCompiling) {

0 commit comments

Comments
 (0)