Skip to content

utils: add support for testing self-hosted SPM #71341

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 28 additions & 6 deletions utils/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,7 @@ function Build-SPMProject {
[string] $Src,
[string] $Bin,
[hashtable] $Arch,
[switch] $Test = $false,
[Parameter(ValueFromRemainingArguments)]
[string[]] $AdditionalArguments
)
Expand Down Expand Up @@ -816,7 +817,8 @@ function Build-SPMProject {
$Arguments += @("-debug-info-format", "none")
}

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

if (-not $ToBatch) {
Expand Down Expand Up @@ -1601,14 +1603,14 @@ function Build-Certificates($Arch) {
}

function Build-PackageManager($Arch) {
$SrcPath = "$SourceCache\swift-package-manager"
if (-not (Test-Path -PathType Container $SrcPath)) {
# The Apple CI clones this repo as "swiftpm"
$SrcPath = "$SourceCache\swiftpm"
$SrcDir = if (Test-Path -Path "$SourceCache\swift-package-manager" -PathType Container) {
"$SourceCache\swift-package-manager"
} else {
"$SourceCache\swiftpm"
}

Build-CMakeProject `
-Src $SrcPath `
-Src $SrcDir `
-Bin $BinaryCache\12 `
-InstallTo "$($Arch.ToolchainInstallRoot)\usr" `
-Arch $Arch `
Expand Down Expand Up @@ -1749,6 +1751,25 @@ function Build-DocC() {
}
}

function Test-PackageManager() {
$OutDir = Join-Path -Path $HostArch.BinaryCache -ChildPath swift-package-manager
$SrcDir = if (Test-Path -Path "$SourceCache\swift-package-manager" -PathType Container) {
"$SourceCache\swift-package-manager"
} else {
"$SourceCache\swiftpm"
}

Isolate-EnvVars {
$env:SWIFTCI_USE_LOCAL_DEPS=1
Build-SPMProject `
-Test `
-Src $SrcDir `
-Bin $OutDir `
-Arch $HostArch `
-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"
}
}

function Build-Installer($Arch) {
$Properties = @{
BundleFlavor = "offline";
Expand Down Expand Up @@ -1900,6 +1921,7 @@ if ($Test -contains "dispatch") { Build-Dispatch $HostArch -Test }
if ($Test -contains "foundation") { Build-Foundation $HostArch -Test }
if ($Test -contains "xctest") { Build-XCTest $HostArch -Test }
if ($Test -contains "llbuild") { Build-LLBuild $HostArch -Test }
if ($Test -contains "swiftpm") { Test-PackageManager $HostArch }

# Custom exception printing for more detailed exception information
} catch {
Expand Down