Skip to content

Commit f11ef1e

Browse files
committed
[Windows] Build and install swift-testing in Windows toolchains
* Basically following XCTest scheme. * Build TestingMacro separately from Testing library and install it to the toolchain's `bin` * Testing swift-testing itself is TODO
1 parent befbbe0 commit f11ef1e

File tree

1 file changed

+77
-13
lines changed

1 file changed

+77
-13
lines changed

utils/build.ps1

+77-13
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ $ArchX64 = @{
215215
PlatformInstallRoot = "$BinaryCache\x64\Windows.platform";
216216
SDKInstallRoot = "$BinaryCache\x64\Windows.platform\Developer\SDKs\Windows.sdk";
217217
XCTestInstallRoot = "$BinaryCache\x64\Windows.platform\Developer\Library\XCTest-development";
218+
SwiftTestingInstallRoot = "$BinaryCache\x64\Windows.platform\Developer\Library\Testing-development";
218219
ToolchainInstallRoot = "$BinaryCache\x64\toolchains\$ProductVersion+Asserts";
219220
}
220221

@@ -230,6 +231,7 @@ $ArchX86 = @{
230231
PlatformInstallRoot = "$BinaryCache\x86\Windows.platform";
231232
SDKInstallRoot = "$BinaryCache\x86\Windows.platform\Developer\SDKs\Windows.sdk";
232233
XCTestInstallRoot = "$BinaryCache\x86\Windows.platform\Developer\Library\XCTest-development";
234+
SwiftTestingInstallRoot = "$BinaryCache\x86\Windows.platform\Developer\Library\Testing-development";
233235
}
234236

235237
$ArchARM64 = @{
@@ -245,6 +247,7 @@ $ArchARM64 = @{
245247
SDKInstallRoot = "$BinaryCache\arm64\Windows.platform\Developer\SDKs\Windows.sdk";
246248
XCTestInstallRoot = "$BinaryCache\arm64\Windows.platform\Developer\Library\XCTest-development";
247249
ToolchainInstallRoot = "$BinaryCache\arm64\toolchains\$ProductVersion+Asserts";
250+
SwiftTestingInstallRoot = "$BinaryCache\arm64\Windows.platform\Developer\Library\Testing-development";
248251
}
249252

250253
$AndroidARM64 = @{
@@ -258,6 +261,7 @@ $AndroidARM64 = @{
258261
PlatformInstallRoot = "$BinaryCache\arm64\Android.platform";
259262
SDKInstallRoot = "$BinaryCache\arm64\Android.platform\Developer\SDKs\Android.sdk";
260263
XCTestInstallRoot = "$BinaryCache\arm64\Android.platform\Developer\Library\XCTest-development";
264+
SwiftTestingInstallRoot = "$BinaryCache\arm64\Android.platform\Developer\Library\Testing-development";
261265
}
262266

263267
$AndroidARMv7 = @{
@@ -271,6 +275,7 @@ $AndroidARMv7 = @{
271275
PlatformInstallRoot = "$BinaryCache\armv7\Android.platform";
272276
SDKInstallRoot = "$BinaryCache\armv7\Android.platform\Developer\SDKs\Android.sdk";
273277
XCTestInstallRoot = "$BinaryCache\armv7\Android.platform\Developer\Library\XCTest-development";
278+
SwiftTestingInstallRoot = "$BinaryCache\armv7\Android.platform\Developer\Library\Testing-development";
274279
}
275280

276281
$AndroidX86 = @{
@@ -284,6 +289,7 @@ $AndroidX86 = @{
284289
PlatformInstallRoot = "$BinaryCache\x86\Android.platform";
285290
SDKInstallRoot = "$BinaryCache\x86\Android.platform\Developer\SDKs\Android.sdk";
286291
XCTestInstallRoot = "$BinaryCache\x86\Android.platform\Developer\Library\XCTest-development";
292+
SwiftTestingInstallRoot = "$BinaryCache\x86\Android.platform\Developer\Library\Testing-development";
287293
}
288294

289295
$AndroidX64 = @{
@@ -297,6 +303,7 @@ $AndroidX64 = @{
297303
PlatformInstallRoot = "$BinaryCache\x64\Android.platform";
298304
SDKInstallRoot = "$BinaryCache\x64\Android.platform\Developer\SDKs\Android.sdk";
299305
XCTestInstallRoot = "$BinaryCache\x64\Android.platform\Developer\Library\XCTest-development";
306+
SwiftTestingInstallRoot = "$BinaryCache\x64\Android.platform\Developer\Library\Testing-development";
300307
}
301308

302309
$HostArch = switch ($HostArchName) {
@@ -387,6 +394,7 @@ enum TargetComponent {
387394
Dispatch
388395
Foundation
389396
XCTest
397+
SwiftTesting
390398
}
391399

392400
function Get-TargetProjectBinaryCache($Arch, [TargetComponent]$Project) {
@@ -413,6 +421,7 @@ enum HostComponent {
413421
LMDB
414422
SymbolKit
415423
DocC
424+
SwiftTestingMacros
416425
}
417426

418427
function Get-HostProjectBinaryCache([HostComponent]$Project) {
@@ -1731,11 +1740,43 @@ function Build-XCTest([Platform]$Platform, $Arch, [switch]$Test = $false) {
17311740
dispatch_DIR = "$DispatchBinaryCache\cmake\modules";
17321741
Foundation_DIR = "$FoundationBinaryCache\cmake\modules";
17331742
} + $TestingDefines)
1743+
}
1744+
}
1745+
1746+
function Build-SwiftTesting([Platform]$Platform, $Arch, [switch]$Test = $false) {
1747+
$SwiftTestingBinaryCache = Get-TargetProjectBinaryCache $Arch SwiftTesting
1748+
1749+
Isolate-EnvVars {
1750+
if ($Test) {
1751+
# TODO: Test
1752+
return
1753+
} else {
1754+
$Targets = @("default")
1755+
$InstallPath = "$($Arch.SwiftTestingInstallRoot)\usr"
1756+
}
17341757

1758+
Build-CMakeProject `
1759+
-Src $SourceCache\swift-testing `
1760+
-Bin $SwiftTestingBinaryCache `
1761+
-InstallTo $InstallPath `
1762+
-Arch $Arch `
1763+
-Platform $Platform `
1764+
-UseBuiltCompilers C,CXX,Swift `
1765+
-BuildTargets $Targets `
1766+
-Defines (@{
1767+
BUILD_SHARED_LIBS = "YES";
1768+
CMAKE_BUILD_WITH_INSTALL_RPATH = "YES";
1769+
SwiftSyntax_DIR = (Get-HostProjectCMakeModules Compilers);
1770+
# FIXME: Build the plugin for the builder and specify the path.
1771+
SwiftTesting_MACRO = "NO";
1772+
})
1773+
}
1774+
}
1775+
1776+
function Write-PlatformInfoPlist($Arch) {
17351777
$PList = Join-Path -Path $Arch.PlatformInstallRoot -ChildPath "Info.plist"
1736-
Invoke-Program $python -c "import plistlib; print(str(plistlib.dumps({ 'DefaultProperties': { 'XCTEST_VERSION': 'development', 'SWIFTC_FLAGS': ['-use-ld=lld'] } }), encoding='utf-8'))" `
1778+
Invoke-Program $python -c "import plistlib; print(str(plistlib.dumps({ 'DefaultProperties': { 'XCTEST_VERSION': 'development', 'SWIFT_TESTING_VERSION': 'development', 'SWIFTC_FLAGS': ['-use-ld=lld'] } }), encoding='utf-8'))" `
17371779
-OutFile "$PList"
1738-
}
17391780
}
17401781

17411782
# Copies files installed by CMake from the arch-specific platform root,
@@ -2165,6 +2206,21 @@ function Build-SourceKitLSP($Arch) {
21652206
}
21662207
}
21672208

2209+
function Build-SwiftTestingMacros($Arch) {
2210+
Build-CMakeProject `
2211+
-Src $SourceCache\swift-testing\Sources\TestingMacros `
2212+
-Bin (Get-HostProjectBinaryCache SwiftTestingMacros) `
2213+
-InstallTo "$($Arch.ToolchainInstallRoot)\usr" `
2214+
-Arch $Arch `
2215+
-Platform Windows `
2216+
-UseBuiltCompilers Swift `
2217+
-SwiftSDK (Get-HostSwiftSDK) `
2218+
-BuildTargets default `
2219+
-Defines @{
2220+
SwiftSyntax_DIR = (Get-HostProjectCMakeModules Compilers);
2221+
}
2222+
}
2223+
21682224
function Install-HostToolchain() {
21692225
if ($ToBatch) { return }
21702226

@@ -2323,20 +2379,24 @@ if (-not $SkipBuild) {
23232379
Invoke-BuildStep Build-Dispatch Windows $Arch
23242380
Invoke-BuildStep Build-Foundation Windows $Arch
23252381
Invoke-BuildStep Build-XCTest Windows $Arch
2382+
Invoke-BuildStep Build-SwiftTesting Windows $Arch
2383+
Invoke-BuildStep Write-PlatformInfoPlist $Arch
23262384
}
23272385

2328-
foreach ($Arch in $AndroidSDKArchs) {
2329-
Invoke-BuildStep Build-ZLib Android $Arch
2330-
Invoke-BuildStep Build-XML2 Android $Arch
2331-
Invoke-BuildStep Build-CURL Android $Arch
2332-
Invoke-BuildStep Build-LLVM Android $Arch
2386+
foreach ($Arch in $AndroidSDKArchs) {
2387+
Invoke-BuildStep Build-ZLib Android $Arch
2388+
Invoke-BuildStep Build-XML2 Android $Arch
2389+
Invoke-BuildStep Build-CURL Android $Arch
2390+
Invoke-BuildStep Build-LLVM Android $Arch
23332391

2334-
# Build platform: SDK, Redist and XCTest
2335-
Invoke-BuildStep Build-Runtime Android $Arch
2336-
Invoke-BuildStep Build-Dispatch Android $Arch
2337-
Invoke-BuildStep Build-Foundation Android $Arch
2338-
Invoke-BuildStep Build-XCTest Android $Arch
2339-
}
2392+
# Build platform: SDK, Redist and XCTest
2393+
Invoke-BuildStep Build-Runtime Android $Arch
2394+
Invoke-BuildStep Build-Dispatch Android $Arch
2395+
Invoke-BuildStep Build-Foundation Android $Arch
2396+
Invoke-BuildStep Build-XCTest Android $Arch
2397+
Invoke-BuildStep Build-SwiftTesting Android $Arch
2398+
Invoke-BuildStep Write-PlatformInfoPlist $Arch
2399+
}
23402400
}
23412401

23422402
if (-not $ToBatch) {
@@ -2358,6 +2418,7 @@ if (-not $ToBatch) {
23582418
}
23592419

23602420
if (-not $SkipBuild) {
2421+
Invoke-BuildStep Build-SwiftTestingMacros $HostArch
23612422
Invoke-BuildStep Build-SQLite $HostArch
23622423
Invoke-BuildStep Build-System $HostArch
23632424
Invoke-BuildStep Build-ToolsSupportCore $HostArch
@@ -2412,6 +2473,9 @@ if (-not $IsCrossCompiling) {
24122473
if ($Test -contains "xctest") {
24132474
Build-XCTest Windows $HostArch -Test
24142475
}
2476+
if ($Test -contains "testing") {
2477+
Build-SwiftTesting Windows $HostArch -Test
2478+
}
24152479
if ($Test -contains "llbuild") { Build-LLBuild $HostArch -Test }
24162480
if ($Test -contains "swiftpm") { Test-PackageManager $HostArch }
24172481
}

0 commit comments

Comments
 (0)