Skip to content

Commit f53d006

Browse files
committed
util: build static foundation for distribution on Windows
This builds the static version of foundation in the experimental SDKs for Windows. This is required to make further progress towards building the early swift-driver with static linking to enable the early swift driver based bootstrapping on Windows.
1 parent 3787044 commit f53d006

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

utils/build.ps1

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,7 @@ enum TargetComponent {
434434
ClangRuntime
435435
SwiftInspect
436436
ExperimentalRuntime
437+
StaticFoundation
437438
}
438439

439440
function Get-TargetProjectBinaryCache($Arch, [TargetComponent]$Project) {
@@ -2149,7 +2150,18 @@ function Build-Dispatch([Platform]$Platform, $Arch, [switch]$Test = $false) {
21492150
}
21502151
}
21512152

2152-
function Build-Foundation([Platform]$Platform, $Arch, [switch]$Test = $false) {
2153+
function Build-Foundation {
2154+
[CmdletBinding(PositionalBinding = $false)]
2155+
param
2156+
(
2157+
[Parameter(Position = 0, Mandatory = $true)]
2158+
[Platform] $Platform,
2159+
[Parameter(Position = 1, Mandatory = $true)]
2160+
[hashtable] $Arch,
2161+
[switch] $Static = $false,
2162+
[switch] $Test = $false
2163+
)
2164+
21532165
if ($Test) {
21542166
# Foundation tests build via swiftpm rather than CMake
21552167
$OutDir = Join-Path -Path $HostArch.BinaryCache -ChildPath swift-foundation-tests
@@ -2182,7 +2194,11 @@ function Build-Foundation([Platform]$Platform, $Arch, [switch]$Test = $false) {
21822194
}
21832195
} else {
21842196
$DispatchBinaryCache = Get-TargetProjectBinaryCache $Arch Dispatch
2185-
$FoundationBinaryCache = Get-TargetProjectBinaryCache $Arch DynamicFoundation
2197+
$FoundationBinaryCache = if ($Static) {
2198+
Get-TargetProjectBinaryCache $Arch StaticFoundation
2199+
} else {
2200+
Get-TargetProjectBinaryCache $Arch DynamicFoundation
2201+
}
21862202
$ShortArch = $Arch.LLVMName
21872203

21882204
Isolate-EnvVars {
@@ -2195,12 +2211,13 @@ function Build-Foundation([Platform]$Platform, $Arch, [switch]$Test = $false) {
21952211
Build-CMakeProject `
21962212
-Src $SourceCache\swift-corelibs-foundation `
21972213
-Bin $FoundationBinaryCache `
2198-
-InstallTo "$($Arch.SDKInstallRoot)\usr" `
2214+
-InstallTo $(if ($Static) { "$($Arch.ExperimentalSDKInstallRoot)\usr" } else { "$($Arch.SDKInstallRoot)\usr" }) `
21992215
-Arch $Arch `
22002216
-Platform $Platform `
22012217
-UseBuiltCompilers ASM,C,CXX,Swift `
22022218
-SwiftSDK:$SDKRoot `
22032219
-Defines @{
2220+
BUILD_SHARED_LIBS = if ($Static) { "NO" } else { "YES" };
22042221
CMAKE_FIND_PACKAGE_PREFER_CONFIG = "YES";
22052222
CMAKE_NINJA_FORCE_RESPONSE_FILE = "YES";
22062223
CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib";
@@ -3119,6 +3136,7 @@ if (-not $SkipBuild) {
31193136
Invoke-BuildStep Write-PlatformInfoPlist $Arch
31203137

31213138
Invoke-BuildStep Build-ExperimentalRuntime -Static Windows $Arch
3139+
Invoke-BuildStep Build-Foundation -Static Windows $Arch
31223140
}
31233141

31243142
foreach ($Arch in $AndroidSDKArchs) {
@@ -3147,6 +3165,7 @@ if (-not $SkipBuild) {
31473165
Invoke-BuildStep Write-PlatformInfoPlist $Arch
31483166

31493167
Invoke-BuildStep Build-ExperimentalRuntime -Static Android $Arch
3168+
Invoke-BuildStep Build-Foundation -Static Android $Arch
31503169
}
31513170

31523171
# Build Macros for distribution

0 commit comments

Comments
 (0)