Skip to content

Commit 62b7fe5

Browse files
authored
Merge pull request #85493 from speednoisemovement/normalize_tc_dir
build.ps1: extract normalized toolchain name
2 parents 2211824 + c975f1b commit 62b7fe5

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+
$ToolchainVersionIdentifier = $PinnedToolchain -replace 'swift-(.+?)-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."
@@ -1390,7 +1392,7 @@ function Get-Dependencies {
13901392

13911393
# TODO(compnerd) stamp/validate that we need to re-extract
13921394
New-Item -ItemType Directory -ErrorAction Ignore $BinaryCache\toolchains | Out-Null
1393-
Extract-Toolchain "$PinnedToolchain.exe" $BinaryCache $PinnedToolchain.TrimStart("swift-").TrimEnd("-arm64").TrimEnd("-a-windows10")
1395+
Extract-Toolchain "$PinnedToolchain.exe" $BinaryCache $ToolchainVersionIdentifier
13941396
Write-Success "Swift Toolchain $PinnedVersion"
13951397

13961398
if ($Android) {
@@ -1444,9 +1446,7 @@ function Get-Dependencies {
14441446
}
14451447

14461448
function Get-PinnedToolchainToolsDir() {
1447-
$ToolchainName = $PinnedToolchain.TrimStart("swift-").TrimEnd("-a-windows10")
1448-
1449-
$ToolchainsRoot = [IO.Path]::Combine("$BinaryCache\toolchains", "$ToolchainName", "LocalApp", "Programs", "Swift", "Toolchains")
1449+
$ToolchainsRoot = [IO.Path]::Combine("$BinaryCache\toolchains", "$ToolchainVersionIdentifier", "LocalApp", "Programs", "Swift", "Toolchains")
14501450

14511451
# NOTE: Add a workaround for the main snapshots that inadvertently used the
14521452
# wrong version when they were built. This allows use of the nightly snapshot
@@ -1471,17 +1471,13 @@ function Get-PinnedToolchainToolsDir() {
14711471
}
14721472

14731473
function Get-PinnedToolchainSDK([OS] $OS = $BuildPlatform.OS, [string] $Identifier = $OS.ToString()) {
1474-
$ToolchainName = $PinnedToolchain.TrimStart("swift-").TrimEnd("-a-windows10")
1475-
1476-
return [IO.Path]::Combine("$BinaryCache\", "toolchains", $ToolchainName,
1474+
return [IO.Path]::Combine("$BinaryCache\", "toolchains", $ToolchainVersionIdentifier,
14771475
"LocalApp", "Programs", "Swift", "Platforms", (Get-PinnedToolchainVersion),
14781476
"$($OS.ToString()).platform", "Developer", "SDKs", "$Identifier.sdk")
14791477
}
14801478

14811479
function Get-PinnedToolchainRuntime() {
1482-
$ToolchainName = $PinnedToolchain.TrimStart("swift-").TrimEnd("-a-windows10")
1483-
1484-
return [IO.Path]::Combine("$BinaryCache\", "toolchains", $ToolchainName,
1480+
return [IO.Path]::Combine("$BinaryCache\", "toolchains", $ToolchainVersionIdentifier,
14851481
"LocalApp", "Programs", "Swift", "Runtimes", (Get-PinnedToolchainVersion),
14861482
"usr", "bin")
14871483
}

0 commit comments

Comments
 (0)