Skip to content

Commit 9ffa7da

Browse files
authored
Merge pull request #79362 from compnerd/collision-insurance
utils: adjust build.ps1 to work with nightly snapshots
2 parents 8c8d573 + cf6a893 commit 9ffa7da

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

utils/build.ps1

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,6 @@ function Fetch-Dependencies {
736736
Expand-Archive -Path $source -DestinationPath $destination -Force
737737
}
738738

739-
740739
function Extract-Toolchain {
741740
param
742741
(
@@ -766,7 +765,7 @@ function Fetch-Dependencies {
766765
Get-ChildItem "$BinaryCache\toolchains\WixAttachedContainer" -Filter "*.msi" | ForEach-Object {
767766
$LogFile = [System.IO.Path]::ChangeExtension($_.Name, "log")
768767
$TARGETDIR = if ($_.Name -eq "rtl.msi") { "$BinaryCache\toolchains\$ToolchainName\LocalApp\Programs\Swift\Runtimes\$(Get-PinnedToolchainVersion)\usr\bin" } else { "$BinaryCache\toolchains\$ToolchainName" }
769-
Invoke-Program -OutNull msiexec.exe /lvx! $BinaryCache\toolchains\$LogFile /qn /a $BinaryCache\toolchains\WixAttachedContainer\$($_.Name) ALLUSERS=0 TARGETDIR=$TARGETDIR
768+
Invoke-Program -OutNull msiexec.exe /lvx! $BinaryCache\toolchains\$LogFile /qn /a $BinaryCache\toolchains\WixAttachedContainer\$($_.Name) ALLUSERS=0 TARGETDIR=$TARGETDIR
770769
}
771770
}
772771

@@ -933,7 +932,17 @@ function Fetch-Dependencies {
933932
}
934933
}
935934

936-
function Get-PinnedToolchainTool() {
935+
function Get-PinnedToolchainToolsDir() {
936+
# NOTE: add a workaround for the main snapshots that used the wrong version
937+
# when building that was not noticed. This allows use of the nightly snapshot
938+
# as a pinned toolchain.
939+
if ((Get-PinnedToolchainVersion) -eq "0.0.0") {
940+
if (-not (Test-Path "$BinaryCache\toolchains\${PinnedToolchain}\LocalApp\Programs\Swift\Toolchains\0.0.0+Asserts\usr\bin")) {
941+
if (Test-Path "$BinaryCache\toolchains\${PinnedToolchain}\LocalApp\Programs\Swift\Toolchains\6.0.0+Asserts\usr\bin") {
942+
return "$BinaryCache\toolchains\${PinnedToolchain}\LocalApp\Programs\Swift\Toolchains\6.0.0+Asserts\usr\bin"
943+
}
944+
}
945+
}
937946
if (Test-Path "$BinaryCache\toolchains\${PinnedToolchain}\LocalApp\Programs\Swift\Toolchains\$(Get-PinnedToolchainVersion)+Asserts\usr\bin") {
938947
return "$BinaryCache\toolchains\${PinnedToolchain}\LocalApp\Programs\Swift\Toolchains\$(Get-PinnedToolchainVersion)+Asserts\usr\bin"
939948
}
@@ -1156,7 +1165,7 @@ function Build-CMakeProject {
11561165
if ($UseBuiltCompilers.Contains("ASM")) {
11571166
TryAdd-KeyValue $Defines CMAKE_ASM_COMPILER ([IO.Path]::Combine($CompilersBinaryCache, "bin", $Driver))
11581167
} else {
1159-
TryAdd-KeyValue $Defines CMAKE_ASM_COMPILER (Join-Path -Path (Get-PinnedToolchainTool) -ChildPath $Driver)
1168+
TryAdd-KeyValue $Defines CMAKE_ASM_COMPILER (Join-Path -Path (Get-PinnedToolchainToolsDir) -ChildPath $Driver)
11601169
}
11611170
Append-FlagsDefine $Defines CMAKE_ASM_FLAGS "--target=$($Arch.LLVMTarget)"
11621171
if ($Platform -eq "Windows") {
@@ -1168,7 +1177,7 @@ function Build-CMakeProject {
11681177
if ($UseBuiltCompilers.Contains("C")) {
11691178
TryAdd-KeyValue $Defines CMAKE_C_COMPILER ([IO.Path]::Combine($CompilersBinaryCache, "bin", $Driver))
11701179
} else {
1171-
TryAdd-KeyValue $Defines CMAKE_C_COMPILER (Join-Path -Path (Get-PinnedToolchainTool) -ChildPath $Driver)
1180+
TryAdd-KeyValue $Defines CMAKE_C_COMPILER (Join-Path -Path (Get-PinnedToolchainToolsDir) -ChildPath $Driver)
11721181
}
11731182
TryAdd-KeyValue $Defines CMAKE_C_COMPILER_TARGET $Arch.LLVMTarget
11741183

@@ -1182,7 +1191,7 @@ function Build-CMakeProject {
11821191
if ($UseBuiltCompilers.Contains("CXX")) {
11831192
TryAdd-KeyValue $Defines CMAKE_CXX_COMPILER ([IO.Path]::Combine($CompilersBinaryCache, "bin", $Driver))
11841193
} else {
1185-
TryAdd-KeyValue $Defines CMAKE_CXX_COMPILER (Join-Path -Path (Get-PinnedToolchainTool) -ChildPath $Driver)
1194+
TryAdd-KeyValue $Defines CMAKE_CXX_COMPILER (Join-Path -Path (Get-PinnedToolchainToolsDir) -ChildPath $Driver)
11861195
}
11871196
TryAdd-KeyValue $Defines CMAKE_CXX_COMPILER_TARGET $Arch.LLVMTarget
11881197

@@ -1199,7 +1208,7 @@ function Build-CMakeProject {
11991208
} elseif ($UseBuiltCompilers.Contains("Swift")) {
12001209
TryAdd-KeyValue $Defines CMAKE_Swift_COMPILER ([IO.Path]::Combine($CompilersBinaryCache, "bin", "swiftc.exe"))
12011210
} else {
1202-
TryAdd-KeyValue $Defines CMAKE_Swift_COMPILER (Join-Path -Path (Get-PinnedToolchainTool) -ChildPath "swiftc.exe")
1211+
TryAdd-KeyValue $Defines CMAKE_Swift_COMPILER (Join-Path -Path (Get-PinnedToolchainToolsDir) -ChildPath "swiftc.exe")
12031212
}
12041213
if (-not ($Platform -eq "Windows")) {
12051214
TryAdd-KeyValue $Defines CMAKE_Swift_COMPILER_WORKS = "YES"
@@ -1680,7 +1689,7 @@ function Build-Compilers() {
16801689
Python3_LIBRARY = "$PythonRoot\libs\$PythonLibName.lib";
16811690
Python3_ROOT_DIR = $PythonRoot;
16821691
SWIFT_BUILD_SWIFT_SYNTAX = "YES";
1683-
SWIFT_CLANG_LOCATION = (Get-PinnedToolchainTool);
1692+
SWIFT_CLANG_LOCATION = (Get-PinnedToolchainToolsDir);
16841693
SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY = "YES";
16851694
SWIFT_ENABLE_EXPERIMENTAL_CXX_INTEROP = "YES";
16861695
SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING = "YES";

0 commit comments

Comments
 (0)