Skip to content

Commit ebe1769

Browse files
authored
Merge pull request swiftlang#75949 from compnerd/testing-macros
utils: improve testing macro setup for Windows
2 parents 5ba41e3 + 2d0c707 commit ebe1769

File tree

1 file changed

+44
-11
lines changed

1 file changed

+44
-11
lines changed

utils/build.ps1

Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,7 @@ function Get-TargetProjectBinaryCache($Arch, [TargetComponent]$Project) {
408408
enum HostComponent {
409409
Compilers = 5
410410
FoundationMacros = 10
411+
TestingMacros
411412
System
412413
ToolsSupportCore
413414
LLBuild
@@ -426,7 +427,6 @@ enum HostComponent {
426427
LMDB
427428
SymbolKit
428429
DocC
429-
SwiftTestingMacros
430430
}
431431

432432
function Get-HostProjectBinaryCache([HostComponent]$Project) {
@@ -441,6 +441,7 @@ enum BuildComponent {
441441
BuildTools
442442
Compilers
443443
FoundationMacros
444+
TestingMacros
444445
}
445446

446447
function Get-BuildProjectBinaryCache([BuildComponent]$Project) {
@@ -1854,8 +1855,7 @@ function Build-SwiftTesting([Platform]$Platform, $Arch, [switch]$Test = $false)
18541855
BUILD_SHARED_LIBS = "YES";
18551856
CMAKE_BUILD_WITH_INSTALL_RPATH = "YES";
18561857
SwiftSyntax_DIR = (Get-HostProjectCMakeModules Compilers);
1857-
# FIXME: Build the plugin for the builder and specify the path.
1858-
SwiftTesting_MACRO = "NO";
1858+
SwiftTesting_MACRO = "$(Get-BuildProjectBinaryCache TestingMacros)\TestingMacros.dll";
18591859
})
18601860
}
18611861
}
@@ -2261,16 +2261,48 @@ function Build-SourceKitLSP($Arch) {
22612261
}
22622262
}
22632263

2264-
function Build-SwiftTestingMacros($Arch) {
2264+
function Build-TestingMacros() {
2265+
[CmdletBinding(PositionalBinding = $false)]
2266+
param
2267+
(
2268+
[Parameter(Position = 0, Mandatory = $true)]
2269+
[Platform]$Platform,
2270+
[Parameter(Position = 1, Mandatory = $true)]
2271+
[hashtable]$Arch,
2272+
[switch] $Build = $false
2273+
)
2274+
2275+
$TestingMacrosBinaryCache = if ($Build) {
2276+
Get-BuildProjectBinaryCache TestingMacros
2277+
} else {
2278+
Get-HostProjectBinaryCache TestingMacros
2279+
}
2280+
2281+
$SwiftSDK = $null
2282+
if ($Build) {
2283+
$SwiftSDK = $HostArch.SDKInstallRoot
2284+
}
2285+
2286+
$Targets = if ($Build) {
2287+
@("default")
2288+
} else {
2289+
@("default", "install")
2290+
}
2291+
2292+
$InstallDir = $null
2293+
if (-not $Build) {
2294+
$InstallDir = "$($Arch.ToolchainInstallRoot)\usr"
2295+
}
2296+
22652297
Build-CMakeProject `
22662298
-Src $SourceCache\swift-testing\Sources\TestingMacros `
2267-
-Bin (Get-HostProjectBinaryCache SwiftTestingMacros) `
2268-
-InstallTo "$($Arch.ToolchainInstallRoot)\usr" `
2299+
-Bin $TestingMacrosBinaryCache `
2300+
-InstallTo:$InstallDir `
22692301
-Arch $Arch `
2270-
-Platform Windows `
2302+
-Platform $Platform `
22712303
-UseBuiltCompilers Swift `
2272-
-SwiftSDK (Get-HostSwiftSDK) `
2273-
-BuildTargets default `
2304+
-SwiftSDK:$SwiftSDK `
2305+
-BuildTargets $Targets `
22742306
-Defines @{
22752307
SwiftSyntax_DIR = (Get-HostProjectCMakeModules Compilers);
22762308
}
@@ -2430,7 +2462,9 @@ if (-not $SkipBuild) {
24302462
# Build platform: SDK, Redist and XCTest
24312463
Invoke-BuildStep Build-Runtime Windows $Arch
24322464
Invoke-BuildStep Build-Dispatch Windows $Arch
2465+
# FIXME(compnerd) ensure that the _build_ is the first arch and don't rebuild on each arch
24332466
Invoke-BuildStep Build-FoundationMacros -Build Windows $BuildArch
2467+
Invoke-BuildStep Build-TestingMacros -Build Windows $BuildArch
24342468
Invoke-BuildStep Build-Foundation Windows $Arch
24352469
Invoke-BuildStep Build-XCTest Windows $Arch
24362470
Invoke-BuildStep Build-SwiftTesting Windows $Arch
@@ -2456,6 +2490,7 @@ if (-not $SkipBuild) {
24562490
if (-not $SkipBuild) {
24572491
# Build Macros for distribution
24582492
Invoke-BuildStep Build-FoundationMacros Windows $HostArch
2493+
Invoke-BuildStep Build-TestingMacros Windows $HostArch
24592494
}
24602495

24612496
if (-not $ToBatch) {
@@ -2477,8 +2512,6 @@ if (-not $ToBatch) {
24772512
}
24782513

24792514
if (-not $SkipBuild) {
2480-
# TestingMacros can't be built before the standard library for the host as it is required for the Swift code.
2481-
Invoke-BuildStep Build-SwiftTestingMacros $HostArch
24822515
Invoke-BuildStep Build-SQLite $HostArch
24832516
Invoke-BuildStep Build-System $HostArch
24842517
Invoke-BuildStep Build-ToolsSupportCore $HostArch

0 commit comments

Comments
 (0)