Skip to content

Commit f7e0caa

Browse files
authored
Merge pull request #71192 from compnerd/enumerate
utils: use named enumerator for target libraries
2 parents 3682d8e + 81edeb1 commit f7e0caa

File tree

1 file changed

+24
-21
lines changed

1 file changed

+24
-21
lines changed

utils/build.ps1

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,16 @@ function Invoke-BuildStep([string]$Name) {
251251
}
252252
}
253253

254-
function Get-ProjectBinaryCache($Arch, $ID) {
255-
return "$BinaryCache\" + ($Arch.BuildID + $ID)
254+
enum Target {
255+
LLVM
256+
Runtime
257+
Dispatch
258+
Foundation
259+
XCTest
260+
}
261+
262+
function Get-ProjectBinaryCache($Arch, [Target]$Target) {
263+
return "$BinaryCache\" + ($Arch.BuildID + $Target.value__)
256264
}
257265

258266
function Copy-File($Src, $Dst) {
@@ -657,7 +665,7 @@ function Build-CMakeProject {
657665
if ($SwiftSDK -ne "") {
658666
$SwiftArgs += @("-sdk", $SwiftSDK)
659667
} else {
660-
$RuntimeBinaryCache = Get-ProjectBinaryCache $Arch 1
668+
$RuntimeBinaryCache = Get-ProjectBinaryCache $Arch Runtime
661669
$SwiftResourceDir = "${RuntimeBinaryCache}\lib\swift"
662670

663671
$SwiftArgs += @("-resource-dir", "$SwiftResourceDir")
@@ -982,7 +990,7 @@ function Build-Compilers() {
982990
function Build-LLVM($Arch) {
983991
Build-CMakeProject `
984992
-Src $SourceCache\llvm-project\llvm `
985-
-Bin (Get-ProjectBinaryCache $Arch 0) `
993+
-Bin (Get-ProjectBinaryCache $Arch LLVM) `
986994
-Arch $Arch `
987995
-Defines @{
988996
LLVM_HOST_TRIPLE = $Arch.LLVMTarget;
@@ -1155,14 +1163,12 @@ function Build-ICU($Arch) {
11551163
}
11561164

11571165
function Build-Runtime($Arch) {
1158-
$LLVMBinaryCache = Get-ProjectBinaryCache $Arch 0
1159-
11601166
Isolate-EnvVars {
11611167
$env:Path = "$($HostArch.BinaryCache)\cmark-gfm-0.29.0.gfm.13\src;$(Get-PinnedToolchainRuntime);${env:Path}"
11621168

11631169
Build-CMakeProject `
11641170
-Src $SourceCache\swift `
1165-
-Bin (Get-ProjectBinaryCache $Arch 1) `
1171+
-Bin (Get-ProjectBinaryCache $Arch Runtime) `
11661172
-InstallTo "$($Arch.SDKInstallRoot)\usr" `
11671173
-Arch $Arch `
11681174
-CacheScript $SourceCache\swift\cmake\caches\Runtime-Windows-$($Arch.LLVMName).cmake `
@@ -1171,7 +1177,7 @@ function Build-Runtime($Arch) {
11711177
-Defines @{
11721178
CMAKE_Swift_COMPILER_TARGET = $Arch.LLVMTarget;
11731179
CMAKE_Swift_COMPILER_WORKS = "YES";
1174-
LLVM_DIR = "$LLVMBinaryCache\lib\cmake\llvm";
1180+
LLVM_DIR = "$(Get-ProjectBinaryCache $Arch LLVM)\lib\cmake\llvm";
11751181
SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY = "YES";
11761182
SWIFT_ENABLE_EXPERIMENTAL_CXX_INTEROP = "YES";
11771183
SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING = "YES";
@@ -1195,7 +1201,7 @@ function Build-Dispatch($Arch, [switch]$Test = $false) {
11951201

11961202
Build-CMakeProject `
11971203
-Src $SourceCache\swift-corelibs-libdispatch `
1198-
-Bin (Get-ProjectBinaryCache $Arch 2) `
1204+
-Bin (Get-ProjectBinaryCache $Arch Dispatch) `
11991205
-InstallTo "$($Arch.SDKInstallRoot)\usr" `
12001206
-Arch $Arch `
12011207
-UseBuiltCompilers C,CXX,Swift `
@@ -1208,20 +1214,19 @@ function Build-Dispatch($Arch, [switch]$Test = $false) {
12081214
}
12091215

12101216
function Build-Foundation($Arch, [switch]$Test = $false) {
1211-
$DispatchBinaryCache = Get-ProjectBinaryCache $Arch 2
1212-
$FoundationBinaryCache = Get-ProjectBinaryCache $Arch 3
1217+
$DispatchBinaryCache = Get-ProjectBinaryCache $Arch Dispatch
1218+
$FoundationBinaryCache = Get-ProjectBinaryCache $Arch Foundation
12131219
$ShortArch = $Arch.ShortName
12141220

12151221
Isolate-EnvVars {
12161222
if ($Test) {
1217-
$RuntimeBinaryCache = Get-ProjectBinaryCache $Arch 1
1218-
$XCTestBinaryCache = Get-ProjectBinaryCache $Arch 4
1223+
$XCTestBinaryCache = Get-ProjectBinaryCache $Arch XCTest
12191224
$TestingDefines = @{
12201225
ENABLE_TESTING = "YES";
12211226
XCTest_DIR = "$XCTestBinaryCache\cmake\modules";
12221227
}
12231228
$Targets = @("default", "test")
1224-
$env:Path = "$XCTestBinaryCache;$FoundationBinaryCache\bin;$DispatchBinaryCache;$RuntimeBinaryCache\bin;$env:Path"
1229+
$env:Path = "$XCTestBinaryCache;$FoundationBinaryCache\bin;$DispatchBinaryCache;$(Get-ProjectBinaryCache $Arch Runtime)\bin;$env:Path"
12251230
} else {
12261231
$TestingDefines = @{ ENABLE_TESTING = "NO" }
12271232
$Targets = @("default", "install")
@@ -1258,23 +1263,21 @@ function Build-Foundation($Arch, [switch]$Test = $false) {
12581263
}
12591264

12601265
function Build-XCTest($Arch, [switch]$Test = $false) {
1261-
$LLVMBinaryCache = Get-ProjectBinaryCache $Arch 0
1262-
$DispatchBinaryCache = Get-ProjectBinaryCache $Arch 2
1263-
$FoundationBinaryCache = Get-ProjectBinaryCache $Arch 3
1264-
$XCTestBinaryCache = Get-ProjectBinaryCache $Arch 4
1266+
$DispatchBinaryCache = Get-ProjectBinaryCache $Arch Dispatch
1267+
$FoundationBinaryCache = Get-ProjectBinaryCache $Arch Foundation
1268+
$XCTestBinaryCache = Get-ProjectBinaryCache $Arch XCTest
12651269

12661270
Isolate-EnvVars {
12671271
if ($Test) {
1268-
$RuntimeBinaryCache = Get-ProjectBinaryCache $Arch 1
12691272
$TestingDefines = @{
12701273
ENABLE_TESTING = "YES";
1271-
LLVM_DIR = "$LLVMBinaryCache/lib/cmake/llvm";
1274+
LLVM_DIR = "$(Get-ProjectBinaryCache $Arch LLVM)/lib/cmake/llvm";
12721275
XCTEST_PATH_TO_LIBDISPATCH_BUILD = $DispatchBinaryCache;
12731276
XCTEST_PATH_TO_LIBDISPATCH_SOURCE = "$SourceCache\swift-corelibs-libdispatch";
12741277
XCTEST_PATH_TO_FOUNDATION_BUILD = $FoundationBinaryCache;
12751278
}
12761279
$Targets = @("default", "check-xctest")
1277-
$env:Path = "$XCTestBinaryCache;$FoundationBinaryCache\bin;$DispatchBinaryCache;$RuntimeBinaryCache\bin;$env:Path;$UnixToolsBinDir"
1280+
$env:Path = "$XCTestBinaryCache;$FoundationBinaryCache\bin;$DispatchBinaryCache;$(Get-ProjectBinaryCache $Arch Runtime)\bin;$env:Path;$UnixToolsBinDir"
12781281
} else {
12791282
$TestingDefines = @{ ENABLE_TESTING = "NO" }
12801283
$Targets = @("default", "install")

0 commit comments

Comments
 (0)