Skip to content

Commit c6b0084

Browse files
committed
utils: add support for testing self-hosted SPM
`-Test swiftpm` will use the self-hosted build of SPM to run the test suite. By using the `SWIFTCI_USE_LOCAL_DEPS=1` environment variable, we do reduce some of the cost of this by not recloning the repositories, but the entire dependency tree must be built a second time due to the switch in the build system.
1 parent 17c1f4b commit c6b0084

File tree

1 file changed

+28
-6
lines changed

1 file changed

+28
-6
lines changed

utils/build.ps1

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,7 @@ function Build-SPMProject {
780780
[string] $Src,
781781
[string] $Bin,
782782
[hashtable] $Arch,
783+
[switch] $Test = $false,
783784
[Parameter(ValueFromRemainingArguments)]
784785
[string[]] $AdditionalArguments
785786
)
@@ -816,7 +817,8 @@ function Build-SPMProject {
816817
$Arguments += @("-debug-info-format", "none")
817818
}
818819

819-
Invoke-Program "$ToolchainInstallRoot\usr\bin\swift.exe" "build" @Arguments @AdditionalArguments
820+
$Action = if ($Test) { "test" } else { "build" }
821+
Invoke-Program "$ToolchainInstallRoot\usr\bin\swift.exe" $Action @Arguments @AdditionalArguments
820822
}
821823

822824
if (-not $ToBatch) {
@@ -1601,14 +1603,14 @@ function Build-Certificates($Arch) {
16011603
}
16021604

16031605
function Build-PackageManager($Arch) {
1604-
$SrcPath = "$SourceCache\swift-package-manager"
1605-
if (-not (Test-Path -PathType Container $SrcPath)) {
1606-
# The Apple CI clones this repo as "swiftpm"
1607-
$SrcPath = "$SourceCache\swiftpm"
1606+
$SrcDir = if (Test-Path -Path "$SourceCache\swift-package-manager" -PathType Container) {
1607+
"$SourceCache\swift-package-manager"
1608+
} else {
1609+
"$SourceCache\swiftpm"
16081610
}
16091611

16101612
Build-CMakeProject `
1611-
-Src $SrcPath `
1613+
-Src $SrcDir `
16121614
-Bin $BinaryCache\12 `
16131615
-InstallTo "$($Arch.ToolchainInstallRoot)\usr" `
16141616
-Arch $Arch `
@@ -1749,6 +1751,25 @@ function Build-DocC() {
17491751
}
17501752
}
17511753

1754+
function Test-PackageManager() {
1755+
$OutDir = Join-Path -Path $HostArch.BinaryCache -ChildPath swift-package-manager
1756+
$SrcDir = if (Test-Path -Path "$SourceCache\swift-package-manager" -PathType Container) {
1757+
"$SourceCache\swift-package-manager"
1758+
} else {
1759+
"$SourceCache\swiftpm"
1760+
}
1761+
1762+
Isolate-EnvVars {
1763+
$env:SWIFTCI_USE_LOCAL_DEPS=1
1764+
Build-SPMProject `
1765+
-Test `
1766+
-Src $SrcDir `
1767+
-Bin $OutDir `
1768+
-Arch $HostArch `
1769+
-Xcc -Xclang -Xcc -fno-split-cold-code -Xcc "-I$LibraryRoot\sqlite-3.43.2\usr\include" -Xlinker "-L$LibraryRoot\sqlite-3.43.2\usr\lib"
1770+
}
1771+
}
1772+
17521773
function Build-Installer($Arch) {
17531774
$Properties = @{
17541775
BundleFlavor = "offline";
@@ -1900,6 +1921,7 @@ if ($Test -contains "dispatch") { Build-Dispatch $HostArch -Test }
19001921
if ($Test -contains "foundation") { Build-Foundation $HostArch -Test }
19011922
if ($Test -contains "xctest") { Build-XCTest $HostArch -Test }
19021923
if ($Test -contains "llbuild") { Build-LLBuild $HostArch -Test }
1924+
if ($Test -contains "swiftpm") { Test-PackageManager $HostArch }
19031925

19041926
# Custom exception printing for more detailed exception information
19051927
} catch {

0 commit comments

Comments
 (0)