Skip to content

Commit 86803aa

Browse files
committed
util: Add -Variant param to build.ps1 for building Asserts | NoAsserts.
1 parent d9b6a82 commit 86803aa

File tree

1 file changed

+33
-14
lines changed

1 file changed

+33
-14
lines changed

utils/build.ps1

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ The toolchain snapshot to build the early components with.
5454
.PARAMETER PinnedSHA256
5555
The SHA256 for the pinned toolchain.
5656
57+
.PARAMETER PinnedToolchainVariant
58+
The toolchain variant to use while building the toolchain. Defaults to
59+
`Asserts`.
60+
5761
.PARAMETER AndroidNDKVersion
5862
The version number of the Android NDK to be used.
5963
@@ -102,6 +106,9 @@ in batch file format instead of executing them.
102106
.PARAMETER HostArchName
103107
The architecture where the toolchain will execute.
104108
109+
.PARAMETER Variant
110+
The toolchain variant to build. Defaults to `Asserts`.
111+
105112
.EXAMPLE
106113
PS> .\Build.ps1
107114
@@ -128,6 +135,8 @@ param
128135
[ValidatePattern("^[A-Fa-f0-9]{64}$")]
129136
[string] $PinnedSHA256 = "",
130137
[string] $PinnedVersion = "",
138+
[ValidateSet("Asserts", "NoAsserts")]
139+
[string] $PinnedToolchainVariant = "Asserts",
131140
[string] $PythonVersion = "3.9.10",
132141
[ValidatePattern("^r(?:[1-9]|[1-9][0-9])(?:[a-z])?$")]
133142
[string] $AndroidNDKVersion = "r26b",
@@ -150,6 +159,8 @@ param
150159
[string] $BuildTo = "",
151160
[ValidateSet("AMD64", "ARM64")]
152161
[string] $HostArchName = $(if ($env:PROCESSOR_ARCHITEW6432 -ne $null) { "$env:PROCESSOR_ARCHITEW6432" } else { "$env:PROCESSOR_ARCHITECTURE" }),
162+
[ValidateSet("Asserts", "NoAsserts")]
163+
[string] $Variant = "Asserts",
153164
[switch] $Clean,
154165
[switch] $DebugInfo,
155166
[switch] $EnableCaching,
@@ -238,7 +249,7 @@ $ArchX64 = @{
238249
ExperimentalSDKInstallRoot = "$BinaryCache\x64\Windows.platform\Developer\SDKs\WindowsExperimental.sdk";
239250
XCTestInstallRoot = "$BinaryCache\x64\Windows.platform\Developer\Library\XCTest-development";
240251
SwiftTestingInstallRoot = "$BinaryCache\x64\Windows.platform\Developer\Library\Testing-development";
241-
ToolchainInstallRoot = "$BinaryCache\x64\toolchains\$ProductVersion+Asserts";
252+
ToolchainInstallRoot = "$BinaryCache\x64\toolchains\$ProductVersion+$Variant";
242253
Cache = @{};
243254
}
244255

@@ -272,7 +283,7 @@ $ArchARM64 = @{
272283
SDKInstallRoot = "$BinaryCache\arm64\Windows.platform\Developer\SDKs\Windows.sdk";
273284
ExperimentalSDKInstallRoot = "$BinaryCache\arm64\Windows.platform\Developer\SDKs\WindowsExperimental.sdk";
274285
XCTestInstallRoot = "$BinaryCache\arm64\Windows.platform\Developer\Library\XCTest-development";
275-
ToolchainInstallRoot = "$BinaryCache\arm64\toolchains\$ProductVersion+Asserts";
286+
ToolchainInstallRoot = "$BinaryCache\arm64\toolchains\$ProductVersion+$Variant";
276287
SwiftTestingInstallRoot = "$BinaryCache\arm64\Windows.platform\Developer\Library\Testing-development";
277288
Cache = @{};
278289
}
@@ -405,7 +416,7 @@ $LibraryRoot = "$ImageRoot\Library"
405416

406417
# For dev productivity, install the host toolchain directly using CMake.
407418
# This allows iterating on the toolchain using ninja builds.
408-
$HostArch.ToolchainInstallRoot = "$(Get-InstallDir $HostArch)\Toolchains\$ProductVersion+Asserts"
419+
$HostArch.ToolchainInstallRoot = "$(Get-InstallDir $HostArch)\Toolchains\$ProductVersion+$Variant"
409420

410421
# Resolve the architectures received as argument
411422
$AndroidSDKArchs = @($AndroidSDKs | ForEach-Object {
@@ -934,20 +945,25 @@ function Fetch-Dependencies {
934945
}
935946

936947
function Get-PinnedToolchainToolsDir() {
937-
# NOTE: add a workaround for the main snapshots that used the wrong version
938-
# when building that was not noticed. This allows use of the nightly snapshot
948+
$ToolchainsRoot = [IO.Path]::Combine("$BinaryCache", "toolchains", "$PinnedToolchain", "LocalApp", "Programs", "Swift", "Toolchains")
949+
$VariantToolchainPath = [IO.Path]::Combine($ToolchainsRoot, "$(Get-PinnedToolchainVersion)+$PinnedToolchainVariant", "usr", "bin")
950+
951+
# NOTE: Add a workaround for the main snapshots that inadvertently used the
952+
# wrong version when they were built. This allows use of the nightly snapshot
939953
# as a pinned toolchain.
940954
if ((Get-PinnedToolchainVersion) -eq "0.0.0") {
941-
if (-not (Test-Path "$BinaryCache\toolchains\${PinnedToolchain}\LocalApp\Programs\Swift\Toolchains\0.0.0+Asserts\usr\bin")) {
942-
if (Test-Path "$BinaryCache\toolchains\${PinnedToolchain}\LocalApp\Programs\Swift\Toolchains\6.0.0+Asserts\usr\bin") {
943-
return "$BinaryCache\toolchains\${PinnedToolchain}\LocalApp\Programs\Swift\Toolchains\6.0.0+Asserts\usr\bin"
955+
if (-not (Test-Path "$ToolchainsRoot\0.0.0+Asserts\usr\bin")) {
956+
if (Test-Path "$ToolchainsRoot\6.0.0+Asserts\usr\bin") {
957+
return "$ToolchainsRoot\6.0.0+Asserts\usr\bin"
944958
}
945959
}
946960
}
947-
if (Test-Path "$BinaryCache\toolchains\${PinnedToolchain}\LocalApp\Programs\Swift\Toolchains\$(Get-PinnedToolchainVersion)+Asserts\usr\bin") {
948-
return "$BinaryCache\toolchains\${PinnedToolchain}\LocalApp\Programs\Swift\Toolchains\$(Get-PinnedToolchainVersion)+Asserts\usr\bin"
961+
962+
if (Test-Path $VariantToolchainPath) {
963+
return $VariantToolchainPath
949964
}
950-
return "$BinaryCache\toolchains\${PinnedToolchain}\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin"
965+
966+
return "$BinaryCache\toolchains\${PinnedToolchain}\Library\Developer\Toolchains\unknown-$PinnedToolchainVariant-development.xctoolchain\usr\bin"
951967
}
952968

953969
function Get-PinnedToolchainSDK() {
@@ -1680,9 +1696,10 @@ function Build-Compilers() {
16801696
LLDB_TABLEGEN = (Join-Path -Path $BuildTools -ChildPath "lldb-tblgen.exe");
16811697
LLDB_TEST_MAKE = "$BinaryCache\GnuWin32Make-4.4.1\bin\make.exe";
16821698
LLVM_CONFIG_PATH = (Join-Path -Path $BuildTools -ChildPath "llvm-config.exe");
1699+
LLVM_ENABLE_ASSERTIONS = $(if ($Variant -eq "Asserts") { "YES" } else { "NO" })
16831700
LLVM_EXTERNAL_SWIFT_SOURCE_DIR = "$SourceCache\swift";
1684-
LLVM_NATIVE_TOOL_DIR = $BuildTools;
16851701
LLVM_HOST_TRIPLE = $BuildArch.LLVMTarget;
1702+
LLVM_NATIVE_TOOL_DIR = $BuildTools;
16861703
LLVM_TABLEGEN = (Join-Path $BuildTools -ChildPath "llvm-tblgen.exe");
16871704
LLVM_USE_HOST_TOOLS = "NO";
16881705
Python3_EXECUTABLE = (Get-PythonExecutable);
@@ -1700,9 +1717,11 @@ function Build-Compilers() {
17001717
SWIFT_ENABLE_SYNCHRONIZATION = "YES";
17011718
SWIFT_ENABLE_VOLATILE = "YES";
17021719
SWIFT_PATH_TO_LIBDISPATCH_SOURCE = "$SourceCache\swift-corelibs-libdispatch";
1703-
SWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE = "$SourceCache\swift-syntax";
17041720
SWIFT_PATH_TO_STRING_PROCESSING_SOURCE = "$SourceCache\swift-experimental-string-processing";
17051721
SWIFT_PATH_TO_SWIFT_SDK = (Get-PinnedToolchainSDK);
1722+
SWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE = "$SourceCache\swift-syntax";
1723+
SWIFT_STDLIB_ASSERTIONS = "NO";
1724+
SWIFTSYNTAX_ENABLE_ASSERTIONS = "NO";
17061725
"cmark-gfm_DIR" = "$($Arch.ToolchainInstallRoot)\usr\lib\cmake";
17071726
})
17081727
}
@@ -3112,7 +3131,7 @@ Fetch-Dependencies
31123131
if ($Clean) {
31133132
10..[HostComponent].getEnumValues()[-1] | ForEach-Object { Remove-Item -Force -Recurse "$BinaryCache\$_" -ErrorAction Ignore }
31143133
# In case of a previous test run, clear out the swiftmodules as they are not a stable format.
3115-
Remove-Item -Force -Recurse -Path "$($HostARch.ToolchainInstallRoot)\usr\lib\swift\windows\*.swiftmodule" -ErrorAction Ignore
3134+
Remove-Item -Force -Recurse -Path "$($HostArch.ToolchainInstallRoot)\usr\lib\swift\windows\*.swiftmodule" -ErrorAction Ignore
31163135
foreach ($Arch in $WindowsSDKArchs) {
31173136
0..[TargetComponent].getEnumValues()[-1] | ForEach-Object { Remove-Item -Force -Recurse "$BinaryCache\$($Arch.BuildID + $_)" -ErrorAction Ignore }
31183137
}

0 commit comments

Comments
 (0)