Skip to content

Commit 8840477

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 14dd14d commit 8840477

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
@@ -2336,42 +2340,43 @@ function Build-FoundationMacros() {
23362340
}
23372341
}
23382342

2339-
function Build-XCTest([Platform]$Platform, $Arch, [switch]$Test = $false) {
2340-
$DispatchBinaryCache = Get-TargetProjectBinaryCache $Arch Dispatch
2341-
$FoundationBinaryCache = Get-TargetProjectBinaryCache $Arch DynamicFoundation
2342-
$XCTestBinaryCache = Get-TargetProjectBinaryCache $Arch XCTest
2343+
function Build-XCTest([Platform]$Platform, $Arch) {
2344+
Build-CMakeProject `
2345+
-Src $SourceCache\swift-corelibs-xctest `
2346+
-Bin $(Get-TargetProjectBinaryCache $Arch XCTest) `
2347+
-InstallTo "$($Arch.XCTestInstallRoot)\usr" `
2348+
-Arch $Arch `
2349+
-Platform $Platform `
2350+
-UseBuiltCompilers Swift `
2351+
-Defines @{
2352+
CMAKE_BUILD_WITH_INSTALL_RPATH = "YES";
2353+
ENABLE_TESTING = "NO";
2354+
dispatch_DIR = $(Get-TargetProjectCMakeModules $Arch Dispatch);
2355+
Foundation_DIR = $(Get-TargetProjectCMakeModules $Arch DynamicFoundation);
2356+
}
2357+
}
23432358

2359+
function Test-XCTest {
23442360
Isolate-EnvVars {
2345-
if ($Test) {
2346-
$TestingDefines = @{
2347-
ENABLE_TESTING = "YES";
2348-
LLVM_DIR = "$(Get-TargetProjectBinaryCache $Arch LLVM)/lib/cmake/llvm";
2349-
XCTEST_PATH_TO_LIBDISPATCH_BUILD = $DispatchBinaryCache;
2350-
XCTEST_PATH_TO_LIBDISPATCH_SOURCE = "$SourceCache\swift-corelibs-libdispatch";
2351-
XCTEST_PATH_TO_FOUNDATION_BUILD = $FoundationBinaryCache;
2352-
}
2353-
$Targets = @("default", "check-xctest")
2354-
$InstallPath = ""
2355-
$env:Path = "$XCTestBinaryCache;$FoundationBinaryCache\bin;$DispatchBinaryCache;$(Get-TargetProjectBinaryCache $Arch Runtime)\bin;$env:Path;$UnixToolsBinDir"
2356-
} else {
2357-
$TestingDefines = @{ ENABLE_TESTING = "NO" }
2358-
$Targets = @("install")
2359-
$InstallPath = "$($Arch.XCTestInstallRoot)\usr"
2360-
}
2361+
$env:Path = "$(Get-TargetProjectBinaryCache $BuildArch XCTest)\bin;$(Get-TargetProjectBinaryCache $BuildArch Dispatch);$(Get-TargetProjectBinaryCache $BuildArch Runtime)\bin;${env:Path};$UnixToolsBinDir"
23612362

23622363
Build-CMakeProject `
23632364
-Src $SourceCache\swift-corelibs-xctest `
2364-
-Bin $XCTestBinaryCache `
2365-
-InstallTo $InstallPath `
2366-
-Arch $Arch `
2367-
-Platform $Platform `
2365+
-Bin (Get-TargetProjectBinaryCache $BuildArch XCTest) `
2366+
-Arch $BuildArch `
2367+
-Platform Windows `
23682368
-UseBuiltCompilers Swift `
2369-
-BuildTargets $Targets `
2370-
-Defines (@{
2369+
-BuildTargets default,check-xctest `
2370+
-Defines @{
23712371
CMAKE_BUILD_WITH_INSTALL_RPATH = "YES";
2372-
dispatch_DIR = "$DispatchBinaryCache\cmake\modules";
2373-
Foundation_DIR = "$FoundationBinaryCache\cmake\modules";
2374-
} + $TestingDefines)
2372+
ENABLE_TESTING = "YES";
2373+
dispatch_DIR = $(Get-TargetProjectCMakeModules $BuildArch Dispatch);
2374+
Foundation_DIR = $(Get-TargetProjectCMakeModules $BuildArch DynamicFoundation);
2375+
LLVM_DIR = "$(Get-TargetProjectBinaryCache $BuildArch LLVM)\lib\cmake\llvm";
2376+
XCTEST_PATH_TO_FOUNDATION_BUILD = $(Get-TargetProjectBinaryCache $BuildArch DynamicFoundation);
2377+
XCTEST_PATH_TO_LIBDISPATCH_BUILD = $(Get-TargetProjectBinaryCache $BuildArch Dispatch);
2378+
XCTEST_PATH_TO_LIBDISPATCH_SOURCE = "$SourceCache\swift-corelibs-libdispatch";
2379+
}
23752380
}
23762381
}
23772382

@@ -3309,7 +3314,7 @@ if (-not $IsCrossCompiling) {
33093314
Build-Foundation Windows $HostArch -Test
33103315
}
33113316
if ($Test -contains "xctest") {
3312-
Build-XCTest Windows $HostArch -Test
3317+
Test-XCTest
33133318
}
33143319
if ($Test -contains "testing") {
33153320
Build-Testing Windows $HostArch -Test

0 commit comments

Comments
 (0)