Skip to content

Commit 261a412

Browse files
authored
Merge pull request #84425 from compnerd/default
build.ps1: allow building Testing, XCTest against a different SDK
2 parents 4ef8487 + 86c0b39 commit 261a412

File tree

1 file changed

+41
-15
lines changed

1 file changed

+41
-15
lines changed

utils/build.ps1

Lines changed: 41 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -189,13 +189,15 @@ param
189189
[ValidateRange(1, 36)]
190190
[int] $AndroidAPILevel = 28,
191191
[string[]] $AndroidSDKVersions = @("Android", "AndroidExperimental"),
192+
[string] $AndroidSDKVersionDefault = "Android",
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 = "",
198199
[string[]] $WindowsSDKVersions = @("Windows", "WindowsExperimental"),
200+
[string] $WindowsSDKVersionDefault = "Windows",
199201
[string[]] $WindowsSDKArchitectures = @("X64","X86","Arm64"),
200202

201203
# Incremental Build Support
@@ -291,6 +293,7 @@ $KnownPlatforms = @{
291293
};
292294
BinaryDir = "bin64a";
293295
Cache = @{};
296+
DefaultSDK = $WindowsSDKVersionDefault;
294297
};
295298

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

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

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

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

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

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

@@ -3105,36 +3114,47 @@ function Build-XCTest([Hashtable] $Platform) {
31053114
-InstallTo "$([IO.Path]::Combine((Get-PlatformRoot $Platform.OS), "Developer", "Library", "XCTest-$ProductVersion", "usr"))" `
31063115
-Platform $Platform `
31073116
-UseBuiltCompilers Swift `
3108-
-SwiftSDK (Get-SwiftSDK $Platform.OS) `
3117+
-SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) `
31093118
-Defines @{
31103119
BUILD_SHARED_LIBS = "YES";
31113120
CMAKE_INSTALL_BINDIR = $Platform.BinaryDir;
31123121
ENABLE_TESTING = "NO";
3113-
dispatch_DIR = $(Get-ProjectCMakeModules $Platform Dispatch);
3114-
Foundation_DIR = $(Get-ProjectCMakeModules $Platform DynamicFoundation);
31153122
XCTest_INSTALL_NESTED_SUBDIR = "YES";
31163123
}
31173124
}
31183125

31193126
function Test-XCTest {
31203127
Invoke-IsolatingEnvVars {
3121-
$env:Path = "$(Get-ProjectBinaryCache $BuildPlatform XCTest);$(Get-ProjectBinaryCache $BuildPlatform DynamicFoundation)\bin;$(Get-ProjectBinaryCache $BuildPlatform Dispatch);$(Get-ProjectBinaryCache $BuildPlatform Runtime)\bin;${env:Path};$UnixToolsBinDir"
3128+
$SwiftRuntime = if ($BuildPlatform.DefaultSDK -match "Experimental") {
3129+
[IO.Path]::Combine((Get-InstallDir $BuildPlatform), "Runtimes", "$ProductVersion.experimental");
3130+
} else {
3131+
[IO.Path]::Combine((Get-InstallDir $BuildPlatform), "Runtimes", "$ProductVersion");
3132+
}
3133+
3134+
$DispatchBinaryCache = if ($BuildPlatform.DefaultSDK -match "Experimental") {
3135+
Get-ProjectBinaryCache $BuildPlatform ExperimentalDynamicDispatch
3136+
} else {
3137+
Get-ProjectBinaryCache $BuildPlatform Dispatch
3138+
}
3139+
3140+
$FoundationBinaryCache = if ($BuildPlatform.DefaultSDK -match "Experimental") {
3141+
Get-ProjectBinaryCache $BuildPlatform ExperimentalDynamicFoundation
3142+
} else {
3143+
Get-ProjectBinaryCache $BuildPlatform DynamicFoundation
3144+
}
31223145

3123-
$RuntimeBinaryCache = Get-ProjectBinaryCache $BuildPlatform Runtime
3124-
$SwiftRuntimeDirectory = "${RuntimeBinaryCache}\lib\swift"
3146+
$env:Path = "$(Get-ProjectBinaryCache $BuildPlatform XCTest);${FoundationBinaryCache}\bin;${DispatchBinaryCache};${SwiftRuntime}\usr\bin;${env:Path};$UnixToolsBinDir"
3147+
$env:SDKROOT = Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK
31253148

31263149
Build-CMakeProject `
31273150
-Src $SourceCache\swift-corelibs-xctest `
31283151
-Bin (Get-ProjectBinaryCache $BuildPlatform XCTest) `
31293152
-Platform $BuildPlatform `
31303153
-UseBuiltCompilers C,CXX,Swift `
3131-
-SwiftSDK $null `
3154+
-SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) `
31323155
-BuildTargets default,check-xctest `
31333156
-Defines @{
3134-
CMAKE_Swift_FLAGS = @("-resource-dir", $SwiftRuntimeDirectory, "-vfsoverlay", "${RuntimeBinaryCache}\stdlib\windows-vfs-overlay.yaml");
31353157
ENABLE_TESTING = "YES";
3136-
dispatch_DIR = $(Get-ProjectCMakeModules $BuildPlatform Dispatch);
3137-
Foundation_DIR = $(Get-ProjectCMakeModules $BuildPlatform DynamicFoundation);
31383158
LLVM_DIR = "$(Get-ProjectBinaryCache $BuildPlatform LLVM)\lib\cmake\llvm";
31393159
XCTEST_PATH_TO_FOUNDATION_BUILD = $(Get-ProjectBinaryCache $BuildPlatform DynamicFoundation);
31403160
XCTEST_PATH_TO_LIBDISPATCH_BUILD = $(Get-ProjectBinaryCache $BuildPlatform Dispatch);
@@ -3150,12 +3170,10 @@ function Build-Testing([Hashtable] $Platform) {
31503170
-InstallTo "$([IO.Path]::Combine((Get-PlatformRoot $Platform.OS), "Developer", "Library", "Testing-$ProductVersion", "usr"))" `
31513171
-Platform $Platform `
31523172
-UseBuiltCompilers CXX,Swift `
3153-
-SwiftSDK (Get-SwiftSDK $Platform.OS) `
3173+
-SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) `
31543174
-Defines @{
31553175
BUILD_SHARED_LIBS = "YES";
31563176
CMAKE_INSTALL_BINDIR = $Platform.BinaryDir;
3157-
dispatch_DIR = (Get-ProjectCMakeModules $Platform Dispatch);
3158-
Foundation_DIR = (Get-ProjectCMakeModules $Platform DynamicFoundation);
31593177
SwiftTesting_MACRO = "$(Get-ProjectBinaryCache $BuildPlatform BootstrapTestingMacros)\TestingMacros.dll";
31603178
SwiftTesting_INSTALL_NESTED_SUBDIR = "YES";
31613179
}
@@ -3216,8 +3234,6 @@ function Build-SDK([Hashtable] $Platform) {
32163234
Invoke-BuildStep Build-Dispatch $Platform
32173235
Invoke-BuildStep Build-Foundation $Platform
32183236
Invoke-BuildStep Build-CompilerRuntime $Platform
3219-
Invoke-BuildStep Build-XCTest $Platform
3220-
Invoke-BuildStep Build-Testing $Platform
32213237
}
32223238

32233239
function Build-ExperimentalSDK([Hashtable] $Platform) {
@@ -4144,6 +4160,11 @@ if (-not $SkipBuild) {
41444160
}
41454161
}
41464162

4163+
foreach ($Build in $WindowsSDKBuilds) {
4164+
Invoke-BuildStep Build-XCTest $Build
4165+
Invoke-BuildStep Build-Testing $Build
4166+
}
4167+
41474168
Write-PlatformInfoPlist Windows
41484169
}
41494170

@@ -4197,6 +4218,11 @@ if (-not $SkipBuild) {
41974218
}
41984219
}
41994220

4221+
foreach ($Build in $AndroidSDKBuilds) {
4222+
Invoke-BuildStep Build-XCTest $Build
4223+
Invoke-BuildStep Build-Testing $Build
4224+
}
4225+
42004226
Write-PlatformInfoPlist Android
42014227

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

0 commit comments

Comments
 (0)