Skip to content

Commit 4b7de1e

Browse files
committed
utils: split Build-XCTest into Build-XCTest and Test-XCTest
This split reduces the logic and changes nearly all the handling into path computation. It also will enable us to migrate towards avoiding a separate staging step.
1 parent f5dd557 commit 4b7de1e

File tree

1 file changed

+35
-30
lines changed

1 file changed

+35
-30
lines changed

utils/build.ps1

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,10 @@ function Get-TargetProjectBinaryCache($Arch, [TargetComponent]$Project) {
442442
return "$BinaryCache\$($Arch.LLVMTarget)\$Project"
443443
}
444444

445+
function Get-TargetProjectCMakeModules($Arch, [TargetComponent]$Project) {
446+
return "$Binarycache\$($Arch.LLVMTarget)\$Project\cmake\modules"
447+
}
448+
445449
enum HostComponent {
446450
Compilers
447451
FoundationMacros
@@ -2316,42 +2320,43 @@ function Build-FoundationMacros() {
23162320
}
23172321
}
23182322

2319-
function Build-XCTest([Platform]$Platform, $Arch, [switch]$Test = $false) {
2320-
$DispatchBinaryCache = Get-TargetProjectBinaryCache $Arch Dispatch
2321-
$FoundationBinaryCache = Get-TargetProjectBinaryCache $Arch DynamicFoundation
2322-
$XCTestBinaryCache = Get-TargetProjectBinaryCache $Arch XCTest
2323+
function Build-XCTest([Platform]$Platform, $Arch) {
2324+
Build-CMakeProject `
2325+
-Src $SourceCache\swift-corelibs-xctest `
2326+
-Bin $(Get-TargetProjectBinaryCache $Arch XCTest) `
2327+
-InstallTo "$($Arch.XCTestInstallRoot)\usr" `
2328+
-Arch $Arch `
2329+
-Platform $Platform `
2330+
-UseBuiltCompilers Swift `
2331+
-Defines @{
2332+
CMAKE_BUILD_WITH_INSTALL_RPATH = "YES";
2333+
ENABLE_TESTING = "NO";
2334+
dispatch_DIR = $(Get-TargetProjectCMakeModules $Arch Dispatch);
2335+
Foundation_DIR = $(Get-TargetProjectCMakeModules $Arch DynamicFoundation);
2336+
}
2337+
}
23232338

2339+
function Test-XCTest {
23242340
Isolate-EnvVars {
2325-
if ($Test) {
2326-
$TestingDefines = @{
2327-
ENABLE_TESTING = "YES";
2328-
LLVM_DIR = "$(Get-TargetProjectBinaryCache $Arch LLVM)/lib/cmake/llvm";
2329-
XCTEST_PATH_TO_LIBDISPATCH_BUILD = $DispatchBinaryCache;
2330-
XCTEST_PATH_TO_LIBDISPATCH_SOURCE = "$SourceCache\swift-corelibs-libdispatch";
2331-
XCTEST_PATH_TO_FOUNDATION_BUILD = $FoundationBinaryCache;
2332-
}
2333-
$Targets = @("default", "check-xctest")
2334-
$InstallPath = ""
2335-
$env:Path = "$XCTestBinaryCache;$FoundationBinaryCache\bin;$DispatchBinaryCache;$(Get-TargetProjectBinaryCache $Arch Runtime)\bin;$env:Path;$UnixToolsBinDir"
2336-
} else {
2337-
$TestingDefines = @{ ENABLE_TESTING = "NO" }
2338-
$Targets = @("install")
2339-
$InstallPath = "$($Arch.XCTestInstallRoot)\usr"
2340-
}
2341+
$env:Path = "$(Get-TargetProjectBinaryCache $BuildArch XCTest)\bin;$(Get-TargetProjectBinaryCache $BuildArch Dispatch);$(Get-TargetProjectBinaryCache $BuildArch Runtime)\bin;${env:Path};$UnixToolsBinDir"
23412342

23422343
Build-CMakeProject `
23432344
-Src $SourceCache\swift-corelibs-xctest `
2344-
-Bin $XCTestBinaryCache `
2345-
-InstallTo $InstallPath `
2346-
-Arch $Arch `
2347-
-Platform $Platform `
2345+
-Bin (Get-TargetProjectBinaryCache $BuildArch XCTest) `
2346+
-Arch $BuildArch `
2347+
-Platform Windows `
23482348
-UseBuiltCompilers Swift `
2349-
-BuildTargets $Targets `
2350-
-Defines (@{
2349+
-BuildTargets default,check-xctest `
2350+
-Defines @{
23512351
CMAKE_BUILD_WITH_INSTALL_RPATH = "YES";
2352-
dispatch_DIR = "$DispatchBinaryCache\cmake\modules";
2353-
Foundation_DIR = "$FoundationBinaryCache\cmake\modules";
2354-
} + $TestingDefines)
2352+
ENABLE_TESTING = "YES";
2353+
dispatch_DIR = $(Get-TargetProjectBinaryCache $BuildArch Dispatch);
2354+
Foundation_DIR = $(Get-TargetProjectBinaryCache $BuildArch DynamicFoundation);
2355+
LLVM_DIR = "$(Get-TargetProjectBinaryCache $BuildArch LLVM)\lib\cmake\llvm";
2356+
XCTEST_PATH_TO_FOUNDATION_BUILD = $(Get-TargetProjectBinaryCache $BuildArch DynamicFoundation);
2357+
XCTEST_PATH_TO_LIBDISPATCH_BUILD = $(Get-TargetProjectBinaryCache $BuildArch Dispatch);
2358+
XCTEST_PATH_TO_LIBDISPATCH_SOURCE = "$SourceCache\swift-corelibs-libdispatch";
2359+
}
23552360
}
23562361
}
23572362

@@ -3280,7 +3285,7 @@ if (-not $IsCrossCompiling) {
32803285
Build-Foundation Windows $HostArch -Test
32813286
}
32823287
if ($Test -contains "xctest") {
3283-
Build-XCTest Windows $HostArch -Test
3288+
Test-XCTest
32843289
}
32853290
if ($Test -contains "testing") {
32863291
Build-Testing Windows $HostArch -Test

0 commit comments

Comments
 (0)