Skip to content

Commit a7ec9e1

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

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

utils/build.ps1

Lines changed: 26 additions & 9 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
@@ -127,6 +134,8 @@ param(
127134
[ValidatePattern("^[A-Fa-f0-9]{64}$")]
128135
[string] $PinnedSHA256 = "",
129136
[string] $PinnedVersion = "",
137+
[ValidateSet("Asserts", "NoAsserts")]
138+
[string] $PinnedToolchainVariant = "Asserts",
130139
[string] $PythonVersion = "3.9.10",
131140
[ValidatePattern("^r(?:[1-9]|[1-9][0-9])(?:[a-z])?$")]
132141
[string] $AndroidNDKVersion = "r26b",
@@ -149,6 +158,8 @@ param(
149158
[string] $BuildTo = "",
150159
[ValidateSet("AMD64", "ARM64")]
151160
[string] $HostArchName = $(if ($env:PROCESSOR_ARCHITEW6432 -ne $null) { "$env:PROCESSOR_ARCHITEW6432" } else { "$env:PROCESSOR_ARCHITECTURE" }),
161+
[ValidateSet("Asserts", "NoAsserts")]
162+
[string] $Variant = "Asserts",
152163
[switch] $Clean,
153164
[switch] $DebugInfo,
154165
[switch] $EnableCaching,
@@ -237,7 +248,7 @@ $ArchX64 = @{
237248
ExperimentalSDKInstallRoot = "$BinaryCache\x64\Windows.platform\Developer\SDKs\WindowsExperimental.sdk";
238249
XCTestInstallRoot = "$BinaryCache\x64\Windows.platform\Developer\Library\XCTest-development";
239250
SwiftTestingInstallRoot = "$BinaryCache\x64\Windows.platform\Developer\Library\Testing-development";
240-
ToolchainInstallRoot = "$BinaryCache\x64\toolchains\$ProductVersion+Asserts";
251+
ToolchainInstallRoot = "$BinaryCache\x64\toolchains\$ProductVersion+$Variant";
241252
Cache = @{};
242253
}
243254

@@ -271,7 +282,7 @@ $ArchARM64 = @{
271282
SDKInstallRoot = "$BinaryCache\arm64\Windows.platform\Developer\SDKs\Windows.sdk";
272283
ExperimentalSDKInstallRoot = "$BinaryCache\arm64\Windows.platform\Developer\SDKs\WindowsExperimental.sdk";
273284
XCTestInstallRoot = "$BinaryCache\arm64\Windows.platform\Developer\Library\XCTest-development";
274-
ToolchainInstallRoot = "$BinaryCache\arm64\toolchains\$ProductVersion+Asserts";
285+
ToolchainInstallRoot = "$BinaryCache\arm64\toolchains\$ProductVersion+$Variant";
275286
SwiftTestingInstallRoot = "$BinaryCache\arm64\Windows.platform\Developer\Library\Testing-development";
276287
Cache = @{};
277288
}
@@ -404,7 +415,7 @@ $LibraryRoot = "$ImageRoot\Library"
404415

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

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

936947
function Get-PinnedToolchainTool() {
937-
if (Test-Path "$BinaryCache\toolchains\${PinnedToolchain}\LocalApp\Programs\Swift\Toolchains\$(Get-PinnedToolchainVersion)+Asserts\usr\bin") {
938-
return "$BinaryCache\toolchains\${PinnedToolchain}\LocalApp\Programs\Swift\Toolchains\$(Get-PinnedToolchainVersion)+Asserts\usr\bin"
948+
$ToolchainsRoot = [IO.Path]::Combine("$BinaryCache", "toolchains", "$PinnedToolchain", "LocalApp", "Programs", "Swift", "Toolchains")
949+
$VariantToolchainPath = [IO.Path]::Combine($ToolchainsRoot, "$(Get-PinnedToolchainVersion)+$PinnedToolchainVariant", "usr", "bin")
950+
if (Test-Path $VariantToolchainPath) {
951+
return $VariantToolchainPath
939952
}
940-
return "$BinaryCache\toolchains\${PinnedToolchain}\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin"
953+
954+
return "$BinaryCache\toolchains\${PinnedToolchain}\Library\Developer\Toolchains\unknown-$PinnedToolchainVariant-development.xctoolchain\usr\bin"
941955
}
942956

943957
function Get-PinnedToolchainSDK() {
@@ -1670,9 +1684,10 @@ function Build-Compilers() {
16701684
LLDB_TABLEGEN = (Join-Path -Path $BuildTools -ChildPath "lldb-tblgen.exe");
16711685
LLDB_TEST_MAKE = "$BinaryCache\GnuWin32Make-4.4.1\bin\make.exe";
16721686
LLVM_CONFIG_PATH = (Join-Path -Path $BuildTools -ChildPath "llvm-config.exe");
1687+
LLVM_ENABLE_ASSERTIONS = $(if ($Variant -eq "Asserts") { "YES" } else { "NO" })
16731688
LLVM_EXTERNAL_SWIFT_SOURCE_DIR = "$SourceCache\swift";
1674-
LLVM_NATIVE_TOOL_DIR = $BuildTools;
16751689
LLVM_HOST_TRIPLE = $BuildArch.LLVMTarget;
1690+
LLVM_NATIVE_TOOL_DIR = $BuildTools;
16761691
LLVM_TABLEGEN = (Join-Path $BuildTools -ChildPath "llvm-tblgen.exe");
16771692
LLVM_USE_HOST_TOOLS = "NO";
16781693
Python3_EXECUTABLE = (Get-PythonExecutable);
@@ -1690,9 +1705,11 @@ function Build-Compilers() {
16901705
SWIFT_ENABLE_SYNCHRONIZATION = "YES";
16911706
SWIFT_ENABLE_VOLATILE = "YES";
16921707
SWIFT_PATH_TO_LIBDISPATCH_SOURCE = "$SourceCache\swift-corelibs-libdispatch";
1693-
SWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE = "$SourceCache\swift-syntax";
16941708
SWIFT_PATH_TO_STRING_PROCESSING_SOURCE = "$SourceCache\swift-experimental-string-processing";
16951709
SWIFT_PATH_TO_SWIFT_SDK = (Get-PinnedToolchainSDK);
1710+
SWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE = "$SourceCache\swift-syntax";
1711+
SWIFT_STDLIB_ASSERTIONS = "NO";
1712+
SWIFTSYNTAX_ENABLE_ASSERTIONS = "NO";
16961713
"cmark-gfm_DIR" = "$($Arch.ToolchainInstallRoot)\usr\lib\cmake";
16971714
})
16981715
}
@@ -3102,7 +3119,7 @@ Fetch-Dependencies
31023119
if ($Clean) {
31033120
10..[HostComponent].getEnumValues()[-1] | ForEach-Object { Remove-Item -Force -Recurse "$BinaryCache\$_" -ErrorAction Ignore }
31043121
# In case of a previous test run, clear out the swiftmodules as they are not a stable format.
3105-
Remove-Item -Force -Recurse -Path "$($HostARch.ToolchainInstallRoot)\usr\lib\swift\windows\*.swiftmodule" -ErrorAction Ignore
3122+
Remove-Item -Force -Recurse -Path "$($HostArch.ToolchainInstallRoot)\usr\lib\swift\windows\*.swiftmodule" -ErrorAction Ignore
31063123
foreach ($Arch in $WindowsSDKArchs) {
31073124
0..[TargetComponent].getEnumValues()[-1] | ForEach-Object { Remove-Item -Force -Recurse "$BinaryCache\$($Arch.BuildID + $_)" -ErrorAction Ignore }
31083125
}

0 commit comments

Comments
 (0)