Skip to content

Commit f9587f3

Browse files
committed
build.ps1: extract XCTest from Build-SDK
Strip out `Build-XCTest` from `Build-SDK`. This is done against the default SDK now for each architecture after the full SDK is built.
1 parent ba62465 commit f9587f3

File tree

1 file changed

+49
-37
lines changed

1 file changed

+49
-37
lines changed

utils/build.ps1

Lines changed: 49 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -188,13 +188,15 @@ param
188188
[string] $AndroidNDKVersion = "r27c",
189189
[ValidateRange(1, 36)]
190190
[int] $AndroidAPILevel = 28,
191+
[string] $AndroidSDKDefault = "Android",
191192
[string[]] $AndroidSDKVersions = @("Android", "AndroidExperimental"),
192193
[string[]] $AndroidSDKArchitectures = @("aarch64", "armv7", "i686", "x86_64"),
193194

194195
# Windows SDK Options
195196
[switch] $Windows = $true,
196197
[ValidatePattern("^\d+\.\d+\.\d+(?:-\w+)?")]
197198
[string] $WinSDKVersion = "",
199+
[string] $WindowsSDKDefault = "Windows",
198200
[string[]] $WindowsSDKVersions = @("Windows", "WindowsExperimental"),
199201
[string[]] $WindowsSDKArchitectures = @("X64","X86","Arm64"),
200202

@@ -291,6 +293,7 @@ $KnownPlatforms = @{
291293
};
292294
BinaryDir = "bin64a";
293295
Cache = @{};
296+
DefaultSDK = $WindowsSDKDefault;
294297
};
295298

296299
WindowsX64 = @{
@@ -304,6 +307,7 @@ $KnownPlatforms = @{
304307
};
305308
BinaryDir = "bin64";
306309
Cache = @{};
310+
DefaultSDK = $WindowsSDKDefault;
307311
};
308312

309313
WindowsX86 = @{
@@ -317,6 +321,7 @@ $KnownPlatforms = @{
317321
};
318322
BinaryDir = "bin32";
319323
Cache = @{};
324+
DefaultSDK = $WindowsSDKDefault;
320325
};
321326

322327
AndroidARMv7 = @{
@@ -330,6 +335,7 @@ $KnownPlatforms = @{
330335
};
331336
BinaryDir = "bin32a";
332337
Cache = @{};
338+
DefaultSDK = $AndroidSDKDefault;
333339
};
334340

335341
AndroidARM64 = @{
@@ -343,6 +349,7 @@ $KnownPlatforms = @{
343349
};
344350
BinaryDir = "bin64a";
345351
Cache = @{};
352+
DefaultSDK = $AndroidSDKDefault;
346353
};
347354

348355
AndroidX86 = @{
@@ -356,6 +363,7 @@ $KnownPlatforms = @{
356363
};
357364
BinaryDir = "bin32";
358365
Cache = @{};
366+
DefaultSDK = $AndroidSDKDefault;
359367
};
360368

361369
AndroidX64 = @{
@@ -369,6 +377,7 @@ $KnownPlatforms = @{
369377
};
370378
BinaryDir = "bin64";
371379
Cache = @{};
380+
DefaultSDK = $AndroidSDKDefault;
372381
};
373382
}
374383

@@ -1865,8 +1874,13 @@ function Build-SPMProject {
18651874
$Stopwatch = [Diagnostics.Stopwatch]::StartNew()
18661875

18671876
Invoke-IsolatingEnvVars {
1868-
$RuntimeInstallRoot = [IO.Path]::Combine((Get-InstallDir $BuildPlatform), "Runtimes", $ProductVersion)
1877+
$RuntimeInstallRoot = if ($BuildPlatform.DefaultSDK -match "Experimental") {
1878+
[IO.Path]::Combine((Get-InstallDir $Build), "Runtimes", "$ProductVersion.experimental");
1879+
} else {
1880+
[IO.Path]::Combine((Get-InstallDir $Build), "Runtimes", "$ProductVersion");
1881+
}
18691882

1883+
Write-Host "Path = $RuntimeInstallRoot\usr\bin;$($BuildPlatform.ToolchainInstallRoot)\usr\bin;${env:Path}"
18701884
$env:Path = "$RuntimeInstallRoot\usr\bin;$($BuildPlatform.ToolchainInstallRoot)\usr\bin;${env:Path}"
18711885
$env:SDKROOT = (Get-SwiftSDK $Platform.OS)
18721886
$env:SWIFTCI_USE_LOCAL_DEPS = "1"
@@ -2988,7 +3002,7 @@ function Build-FoundationMacros([Hashtable] $Platform) {
29883002
-InstallTo "$($Platform.ToolchainInstallRoot)\usr" `
29893003
-Platform $Platform `
29903004
-UseBuiltCompilers Swift `
2991-
-SwiftSDK (Get-SwiftSDK $Platform.OS) `
3005+
-SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) `
29923006
-Defines @{
29933007
SwiftSyntax_DIR = $SwiftSyntaxDir;
29943008
}
@@ -3001,40 +3015,31 @@ function Build-XCTest([Hashtable] $Platform) {
30013015
-InstallTo "$([IO.Path]::Combine((Get-PlatformRoot $Platform.OS), "Developer", "Library", "XCTest-$ProductVersion", "usr"))" `
30023016
-Platform $Platform `
30033017
-UseBuiltCompilers Swift `
3004-
-SwiftSDK (Get-SwiftSDK $Platform.OS) `
3018+
-SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) `
30053019
-Defines @{
30063020
BUILD_SHARED_LIBS = "YES";
30073021
CMAKE_INSTALL_BINDIR = $Platform.BinaryDir;
30083022
ENABLE_TESTING = "NO";
3009-
dispatch_DIR = $(Get-ProjectCMakeModules $Platform Dispatch);
3010-
Foundation_DIR = $(Get-ProjectCMakeModules $Platform DynamicFoundation);
30113023
XCTest_INSTALL_NESTED_SUBDIR = "YES";
30123024
}
30133025
}
30143026

30153027
function Test-XCTest {
30163028
Invoke-IsolatingEnvVars {
3029+
$env:SDKROOT = Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK
30173030
$env:Path = "$(Get-ProjectBinaryCache $BuildPlatform XCTest);$(Get-ProjectBinaryCache $BuildPlatform DynamicFoundation)\bin;$(Get-ProjectBinaryCache $BuildPlatform Dispatch);$(Get-ProjectBinaryCache $BuildPlatform Runtime)\bin;${env:Path};$UnixToolsBinDir"
30183031

3019-
$RuntimeBinaryCache = Get-ProjectBinaryCache $BuildPlatform Runtime
3020-
$SwiftRuntimeDirectory = "${RuntimeBinaryCache}\lib\swift"
3021-
30223032
Build-CMakeProject `
30233033
-Src $SourceCache\swift-corelibs-xctest `
30243034
-Bin (Get-ProjectBinaryCache $BuildPlatform XCTest) `
30253035
-Platform $BuildPlatform `
30263036
-UseBuiltCompilers C,CXX,Swift `
3027-
-SwiftSDK $null `
3037+
-SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) `
30283038
-BuildTargets default,check-xctest `
30293039
-Defines @{
3030-
CMAKE_Swift_FLAGS = @("-resource-dir", $SwiftRuntimeDirectory, "-vfsoverlay", "${RuntimeBinaryCache}\stdlib\windows-vfs-overlay.yaml");
3040+
BUILD_SHARED_LIBS = "YES";
30313041
ENABLE_TESTING = "YES";
3032-
dispatch_DIR = $(Get-ProjectCMakeModules $BuildPlatform Dispatch);
3033-
Foundation_DIR = $(Get-ProjectCMakeModules $BuildPlatform DynamicFoundation);
3034-
LLVM_DIR = "$(Get-ProjectBinaryCache $BuildPlatform LLVM)\lib\cmake\llvm";
3035-
XCTEST_PATH_TO_FOUNDATION_BUILD = $(Get-ProjectBinaryCache $BuildPlatform DynamicFoundation);
3036-
XCTEST_PATH_TO_LIBDISPATCH_BUILD = $(Get-ProjectBinaryCache $BuildPlatform Dispatch);
3037-
XCTEST_PATH_TO_LIBDISPATCH_SOURCE = "$SourceCache\swift-corelibs-libdispatch";
3042+
LLVM_MAIN_SRC_DIR = "$SourceCache/llvm-project/llvm";
30383043
}
30393044
}
30403045
}
@@ -3111,8 +3116,7 @@ function Build-SDK([Hashtable] $Platform) {
31113116
Invoke-BuildStep Build-Runtime $Platform
31123117
Invoke-BuildStep Build-Dispatch $Platform
31133118
Invoke-BuildStep Build-Foundation $Platform
3114-
Invoke-BuildStep Build-CompilerRuntime $Platform
3115-
Invoke-BuildStep Build-XCTest $Platform
3119+
31163120
Invoke-BuildStep Build-Testing $Platform
31173121
}
31183122

@@ -3241,7 +3245,7 @@ function Build-System([Hashtable] $Platform) {
32413245
-Bin (Get-ProjectBinaryCache $Platform System) `
32423246
-Platform $Platform `
32433247
-UseBuiltCompilers C,Swift `
3244-
-SwiftSDK (Get-SwiftSDK $Platform.OS) `
3248+
-SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) `
32453249
-BuildTargets default `
32463250
-Defines @{
32473251
BUILD_SHARED_LIBS = "NO";
@@ -3255,7 +3259,7 @@ function Build-Subprocess([Hashtable] $Platform) {
32553259
-Bin (Get-ProjectBinaryCache $Platform Subprocess) `
32563260
-Platform $Platform `
32573261
-UseBuiltCompilers C,Swift `
3258-
-SwiftSDK (Get-SwiftSDK $Platform.OS) `
3262+
-SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) `
32593263
-Defines @{
32603264
BUILD_SHARED_LIBS = "NO";
32613265
CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib";
@@ -3273,7 +3277,7 @@ function Build-Build([Hashtable] $Platform) {
32733277
-InstallTo "$($Platform.ToolchainInstallRoot)\usr" `
32743278
-Platform $Platform `
32753279
-UseBuiltCompilers C,CXX,Swift `
3276-
-SwiftSDK (Get-SwiftSDK $Platform.OS) `
3280+
-SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) `
32773281
-Defines (@{
32783282
BUILD_SHARED_LIBS = "YES";
32793283
CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib";
@@ -3294,7 +3298,7 @@ function Build-ToolsSupportCore([Hashtable] $Platform) {
32943298
-InstallTo "$($Platform.ToolchainInstallRoot)\usr" `
32953299
-Platform $Platform `
32963300
-UseBuiltCompilers C,Swift `
3297-
-SwiftSDK (Get-SwiftSDK $Platform.OS) `
3301+
-SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) `
32983302
-Defines @{
32993303
BUILD_SHARED_LIBS = "YES";
33003304
CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib";
@@ -3313,7 +3317,7 @@ function Build-LLBuild([Hashtable] $Platform) {
33133317
-UseMSVCCompilers $(if ($UseHostToolchain) { @("CXX") } else { @("") }) `
33143318
-UsePinnedCompilers $(if ($UseHostToolchain) { @("") } else { @("CXX") }) `
33153319
-UseBuiltCompilers Swift `
3316-
-SwiftSDK (Get-SwiftSDK $Platform.OS) `
3320+
-SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) `
33173321
-Defines @{
33183322
BUILD_SHARED_LIBS = "YES";
33193323
LLBUILD_SUPPORT_BINDINGS = "Swift";
@@ -3341,7 +3345,7 @@ function Test-LLBuild {
33413345
-UseMSVCCompilers $(if ($UseHostToolchain) { @("CXX") } else { @("") }) `
33423346
-UsePinnedCompilers $(if ($UseHostToolchain) { @("") } else { @("CXX") }) `
33433347
-UseBuiltCompilers Swift `
3344-
-SwiftSDK (Get-SwiftSDK $BuildPlatform.OS) `
3348+
-SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) `
33453349
-BuildTargets default,test-llbuild `
33463350
-Defines = @{
33473351
BUILD_SHARED_LIBS = "YES";
@@ -3361,7 +3365,7 @@ function Build-ArgumentParser([Hashtable] $Platform) {
33613365
-InstallTo "$($Platform.ToolchainInstallRoot)\usr" `
33623366
-Platform $Platform `
33633367
-UseBuiltCompilers Swift `
3364-
-SwiftSDK (Get-SwiftSDK $Platform.OS) `
3368+
-SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) `
33653369
-Defines @{
33663370
BUILD_SHARED_LIBS = "YES";
33673371
BUILD_TESTING = "NO";
@@ -3376,7 +3380,7 @@ function Build-Driver([Hashtable] $Platform) {
33763380
-InstallTo "$($Platform.ToolchainInstallRoot)\usr" `
33773381
-Platform $Platform `
33783382
-UseBuiltCompilers C,CXX,Swift `
3379-
-SwiftSDK (Get-SwiftSDK $Platform.OS) `
3383+
-SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) `
33803384
-Defines @{
33813385
BUILD_SHARED_LIBS = "YES";
33823386
CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib";
@@ -3398,7 +3402,7 @@ function Build-Crypto([Hashtable] $Platform) {
33983402
-Bin (Get-ProjectBinaryCache $Platform Crypto) `
33993403
-Platform $Platform `
34003404
-UseBuiltCompilers ASM, C, CXX, Swift `
3401-
-SwiftSDK (Get-SwiftSDK $Platform.OS) `
3405+
-SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) `
34023406
-BuildTargets default `
34033407
-Defines @{
34043408
BUILD_SHARED_LIBS = "NO";
@@ -3414,7 +3418,7 @@ function Build-Collections([Hashtable] $Platform) {
34143418
-InstallTo "$($Platform.ToolchainInstallRoot)\usr" `
34153419
-Platform $Platform `
34163420
-UseBuiltCompilers C,Swift `
3417-
-SwiftSDK (Get-SwiftSDK $Platform.OS) `
3421+
-SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) `
34183422
-Defines @{
34193423
BUILD_SHARED_LIBS = "YES";
34203424
CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib";
@@ -3427,7 +3431,7 @@ function Build-ASN1([Hashtable] $Platform) {
34273431
-Bin (Get-ProjectBinaryCache $Platform ASN1) `
34283432
-Platform $Platform `
34293433
-UseBuiltCompilers Swift `
3430-
-SwiftSDK (Get-SwiftSDK $Platform.OS) `
3434+
-SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) `
34313435
-BuildTargets default `
34323436
-Defines @{
34333437
BUILD_SHARED_LIBS = "NO";
@@ -3441,7 +3445,7 @@ function Build-Certificates([Hashtable] $Platform) {
34413445
-Bin (Get-ProjectBinaryCache $Platform Certificates) `
34423446
-Platform $Platform `
34433447
-UseBuiltCompilers Swift `
3444-
-SwiftSDK (Get-SwiftSDK $Platform.OS) `
3448+
-SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) `
34453449
-BuildTargets default `
34463450
-Defines @{
34473451
BUILD_SHARED_LIBS = "NO";
@@ -3464,7 +3468,7 @@ function Build-PackageManager([Hashtable] $Platform) {
34643468
-InstallTo "$($Platform.ToolchainInstallRoot)\usr" `
34653469
-Platform $Platform `
34663470
-UseBuiltCompilers C,Swift `
3467-
-SwiftSDK (Get-SwiftSDK $Platform.OS) `
3471+
-SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) `
34683472
-Defines @{
34693473
BUILD_SHARED_LIBS = "YES";
34703474
CMAKE_Swift_FLAGS = @("-DCRYPTO_v2");
@@ -3492,7 +3496,7 @@ function Build-Markdown([Hashtable] $Platform) {
34923496
-InstallTo "$($Platform.ToolchainInstallRoot)\usr" `
34933497
-Platform $Platform `
34943498
-UseBuiltCompilers C,Swift `
3495-
-SwiftSDK (Get-SwiftSDK $Platform.OS) `
3499+
-SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) `
34963500
-Defines @{
34973501
BUILD_SHARED_LIBS = "NO";
34983502
CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib";
@@ -3510,7 +3514,7 @@ function Build-Format([Hashtable] $Platform) {
35103514
-UseMSVCCompilers $(if ($UseHostToolchain) { @("C") } else { @("") }) `
35113515
-UsePinnedCompilers $(if ($UseHostToolchain) { @("") } else { @("C") }) `
35123516
-UseBuiltCompilers Swift `
3513-
-SwiftSDK (Get-SwiftSDK $Platform.OS) `
3517+
-SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) `
35143518
-Defines @{
35153519
BUILD_SHARED_LIBS = "YES";
35163520
ArgumentParser_DIR = (Get-ProjectCMakeModules $Platform ArgumentParser);
@@ -3569,7 +3573,7 @@ function Build-LMDB([Hashtable] $Platform) {
35693573
}
35703574

35713575
function Build-IndexStoreDB([Hashtable] $Platform) {
3572-
$SDKROOT = Get-SwiftSDK $Platform.OS
3576+
$SDKROOT = Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK
35733577
Build-CMakeProject `
35743578
-Src $SourceCache\indexstore-db `
35753579
-Bin (Get-ProjectBinaryCache $Platform IndexStoreDB) `
@@ -3593,7 +3597,7 @@ function Build-SourceKitLSP([Hashtable] $Platform) {
35933597
-InstallTo "$($Platform.ToolchainInstallRoot)\usr" `
35943598
-Platform $Platform `
35953599
-UseBuiltCompilers C,Swift `
3596-
-SwiftSDK (Get-SwiftSDK $Platform.OS) `
3600+
-SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) `
35973601
-Defines @{
35983602
CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib";
35993603
SwiftSyntax_DIR = (Get-ProjectCMakeModules $Platform Compilers);
@@ -3705,7 +3709,7 @@ function Build-TestingMacros([Hashtable] $Platform) {
37053709
-InstallTo "$($Platform.ToolchainInstallRoot)\usr" `
37063710
-Platform $Platform `
37073711
-UseBuiltCompilers Swift `
3708-
-SwiftSDK (Get-SwiftSDK $Platform.OS) `
3712+
-SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) `
37093713
-Defines @{
37103714
SwiftSyntax_DIR = (Get-ProjectCMakeModules $Platform Compilers);
37113715
}
@@ -3749,7 +3753,7 @@ function Build-Inspect([Hashtable] $Platform) {
37493753
$InstallPath = "$(Get-PlatformRoot $Platform.OS)\Developer\Library\$(Get-ModuleTriple $Platform)"
37503754
}
37513755

3752-
$SDKROOT = Get-SwiftSDK $Platform.OS
3756+
$SDKROOT = Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK
37533757

37543758
Build-CMakeProject `
37553759
-Src $SourceCache\swift\tools\swift-inspect `
@@ -4009,6 +4013,10 @@ if (-not $SkipBuild) {
40094013
}
40104014
}
40114015

4016+
foreach ($Build in $WindowsSDKBuilds) {
4017+
Invoke-BuildStep Build-XCTest $Build
4018+
}
4019+
40124020
Write-PlatformInfoPlist Windows
40134021
}
40144022

@@ -4062,6 +4070,10 @@ if (-not $SkipBuild) {
40624070
}
40634071
}
40644072

4073+
foreach ($Build in $AndroidSDKBuilds) {
4074+
Invoke-BuildStep Build-XCTest $Build
4075+
}
4076+
40654077
Write-PlatformInfoPlist Android
40664078

40674079
# Android swift-inspect only supports 64-bit platforms.

0 commit comments

Comments
 (0)