Skip to content

Commit f306f92

Browse files
build.ps1: extract normalized toolchain name
1 parent 3545603 commit f306f92

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

utils/build.ps1

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,8 @@ if (-not $PinnedBuild) {
571571
}
572572

573573
$PinnedToolchain = [IO.Path]::GetFileNameWithoutExtension($PinnedBuild)
574+
# Use a shorter name in paths to avoid going over the path length limit.
575+
$NormalizedToolchainName = $PinnedToolchain -replace 'swift-(.+?)-a-windows10.*', '$1'
574576

575577
if ($EnableCAS -and ($UseHostToolchain -or ($PinnedVersion -ne "0.0.0"))) {
576578
throw "CAS currently requires using a main-branch pinned toolchain."
@@ -1400,7 +1402,7 @@ function Get-Dependencies {
14001402

14011403
# TODO(compnerd) stamp/validate that we need to re-extract
14021404
New-Item -ItemType Directory -ErrorAction Ignore $BinaryCache\toolchains | Out-Null
1403-
Extract-Toolchain "$PinnedToolchain.exe" $BinaryCache $PinnedToolchain.TrimStart("swift-").TrimEnd("-arm64").TrimEnd("-a-windows10")
1405+
Extract-Toolchain "$PinnedToolchain.exe" $BinaryCache $NormalizedToolchainName
14041406
Write-Success "Swift Toolchain $PinnedVersion"
14051407

14061408
if ($Android) {
@@ -1454,9 +1456,7 @@ function Get-Dependencies {
14541456
}
14551457

14561458
function Get-PinnedToolchainToolsDir() {
1457-
$ToolchainName = $PinnedToolchain.TrimStart("swift-").TrimEnd("-a-windows10")
1458-
1459-
$ToolchainsRoot = [IO.Path]::Combine("$BinaryCache\toolchains", "$ToolchainName", "LocalApp", "Programs", "Swift", "Toolchains")
1459+
$ToolchainsRoot = [IO.Path]::Combine("$BinaryCache\toolchains", "$NormalizedToolchainName", "LocalApp", "Programs", "Swift", "Toolchains")
14601460

14611461
# NOTE: Add a workaround for the main snapshots that inadvertently used the
14621462
# wrong version when they were built. This allows use of the nightly snapshot
@@ -1481,17 +1481,13 @@ function Get-PinnedToolchainToolsDir() {
14811481
}
14821482

14831483
function Get-PinnedToolchainSDK([OS] $OS = $BuildPlatform.OS, [string] $Identifier = $OS.ToString()) {
1484-
$ToolchainName = $PinnedToolchain.TrimStart("swift-").TrimEnd("-a-windows10")
1485-
1486-
return [IO.Path]::Combine("$BinaryCache\", "toolchains", $ToolchainName,
1484+
return [IO.Path]::Combine("$BinaryCache\", "toolchains", $NormalizedToolchainName,
14871485
"LocalApp", "Programs", "Swift", "Platforms", (Get-PinnedToolchainVersion),
14881486
"$($OS.ToString()).platform", "Developer", "SDKs", "$Identifier.sdk")
14891487
}
14901488

14911489
function Get-PinnedToolchainRuntime() {
1492-
$ToolchainName = $PinnedToolchain.TrimStart("swift-").TrimEnd("-a-windows10")
1493-
1494-
return [IO.Path]::Combine("$BinaryCache\", "toolchains", $ToolchainName,
1490+
return [IO.Path]::Combine("$BinaryCache\", "toolchains", $NormalizedToolchainName,
14951491
"LocalApp", "Programs", "Swift", "Runtimes", (Get-PinnedToolchainVersion),
14961492
"usr", "bin")
14971493
}

0 commit comments

Comments
 (0)