Skip to content

Commit ffa4006

Browse files
committed
build: introduce new Build-SPMProject function
Begin laying out the infrastructure to build SPM based projects. Certain higher level tools (e.g. swift-inspect, swift-format) do not have CMake based build systems. This will allow us to build and package them as part of the toolchain distribution by building them with SPM with the partially staged toolchain.
1 parent d9ecd11 commit ffa4006

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

build.ps1

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,58 @@ function Build-CMakeProject {
475475
}
476476
}
477477

478+
function Build-SPMProject {
479+
[CmdletBinding(PositionalBinding = $false)]
480+
param(
481+
[string] $Src,
482+
[string] $Bin,
483+
[hashtable] $Arch,
484+
[Parameter(ValueFromRemainingArguments)]
485+
[string[]] $AdditionalArguments
486+
)
487+
488+
if ($ToBatch) {
489+
Write-Output ""
490+
Write-Output "echo Building '$Src' to '$Bin' for arch '$($Arch.ShortName)'..."
491+
} else {
492+
Write-Host -ForegroundColor Cyan "[$([DateTime]::Now.ToString("yyyy-MM-dd HH:mm:ss"))] Building '$Src' to '$Bin' for arch '$($Arch.ShortName)'..."
493+
}
494+
495+
$Stopwatch = [Diagnostics.Stopwatch]::StartNew()
496+
497+
Isolate-EnvVars {
498+
$env:Path = "${RuntimeInstallRoot}\usr\bin;${ToolchainInstallRoot}\usr\bin;${env:Path}"
499+
$env:SDKROOT = $Arch.SDKInstallRoot
500+
501+
$Arguments = @(
502+
"--scratch-path", $Bin,
503+
"--package-path", $Src,
504+
"-c", "release",
505+
"-Xbuild-tools-swiftc", "-I$($HostArch.SDKInstallRoot)\usr\lib\swift",
506+
"-Xbuild-tools-swiftc", "-L$($HostArch.SDKInstallRoot)\usr\lib\swift\windows",
507+
"-Xcc", "-I$($HostArch.SDKInstallRoot)\usr\lib\swift",
508+
"-Xlinker", "-L$($HostArch.SDKInstallRoot)\usr\lib\swift\windows"
509+
)
510+
if ($BuildType -eq "Release") {
511+
$Arguments += @("-Xswiftc", "-gnone")
512+
} else {
513+
if ($SwiftDebugFormat -eq "dwarf") {
514+
$Arguments += @("-Xlinker", "-debug:dwarf")
515+
} else {
516+
$Arguments += @("-g", "-debug-info-format=codeview")
517+
$Arguments += @("-Xlinker", "-debug")
518+
}
519+
}
520+
521+
Invoke-Program "$($Arch.ToolchainInstallRoot)\usr\bin\swift.exe" "build" @Arguments @AdditionalArguments
522+
}
523+
524+
if (-not $ToBatch) {
525+
Write-Host -ForegroundColor Cyan "[$([DateTime]::Now.ToString("yyyy-MM-dd HH:mm:ss"))] Finished building '$Src' to '$Bin' for arch '$($Arch.ShortName)' in $($Stopwatch.Elapsed)"
526+
Write-Host ""
527+
}
528+
}
529+
478530
function Build-WiXProject() {
479531
[CmdletBinding(PositionalBinding = $false)]
480532
param(

0 commit comments

Comments
 (0)