Skip to content

Commit c80b750

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 acbae0c commit c80b750

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
@@ -2333,42 +2337,43 @@ function Build-FoundationMacros() {
23332337
}
23342338
}
23352339

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

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

23592360
Build-CMakeProject `
23602361
-Src $SourceCache\swift-corelibs-xctest `
2361-
-Bin $XCTestBinaryCache `
2362-
-InstallTo $InstallPath `
2363-
-Arch $Arch `
2364-
-Platform $Platform `
2362+
-Bin (Get-TargetProjectBinaryCache $BuildArch XCTest) `
2363+
-Arch $BuildArch `
2364+
-Platform Windows `
23652365
-UseBuiltCompilers Swift `
2366-
-BuildTargets $Targets `
2367-
-Defines (@{
2366+
-BuildTargets default,check-xctest `
2367+
-Defines @{
23682368
CMAKE_BUILD_WITH_INSTALL_RPATH = "YES";
2369-
dispatch_DIR = "$DispatchBinaryCache\cmake\modules";
2370-
Foundation_DIR = "$FoundationBinaryCache\cmake\modules";
2371-
} + $TestingDefines)
2369+
ENABLE_TESTING = "YES";
2370+
dispatch_DIR = $(Get-TargetProjectCMakeModules $BuildArch Dispatch);
2371+
Foundation_DIR = $(Get-TargetProjectCMakeModules $BuildArch DynamicFoundation);
2372+
LLVM_DIR = "$(Get-TargetProjectBinaryCache $BuildArch LLVM)\lib\cmake\llvm";
2373+
XCTEST_PATH_TO_FOUNDATION_BUILD = $(Get-TargetProjectBinaryCache $BuildArch DynamicFoundation);
2374+
XCTEST_PATH_TO_LIBDISPATCH_BUILD = $(Get-TargetProjectBinaryCache $BuildArch Dispatch);
2375+
XCTEST_PATH_TO_LIBDISPATCH_SOURCE = "$SourceCache\swift-corelibs-libdispatch";
2376+
}
23722377
}
23732378
}
23742379

@@ -3300,7 +3305,7 @@ if (-not $IsCrossCompiling) {
33003305
Build-Foundation Windows $HostArch -Test
33013306
}
33023307
if ($Test -contains "xctest") {
3303-
Build-XCTest Windows $HostArch -Test
3308+
Test-XCTest
33043309
}
33053310
if ($Test -contains "testing") {
33063311
Build-Testing Windows $HostArch -Test

0 commit comments

Comments
 (0)