Skip to content
Closed
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
51 changes: 44 additions & 7 deletions utils/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2490,18 +2490,37 @@ function Build-Foundation {
Get-ProjectBinaryCache $Platform DynamicFoundation
}

$FoundationImage = if ($Static) {
"$(Get-SwiftSDK $Platform.OS -Identifier "$($Platform.OS)Experimental")\usr"
} else {
"$(Get-SwiftSDK $Platform.OS)\usr"
}

$SwiftFlags = if ($Static) {
@("-static-stdlib", "-Xfrontend", "-use-static-resource-dir")
} else {
@()
}

$SwiftSDK = if ($Static) {
Get-SwiftSDK $Platform.OS -Identifier "$($Platform.OS)Experimental"
} else {
Get-SwiftSDK $Platform.OS
}

Build-CMakeProject `
-Src $SourceCache\swift-corelibs-foundation `
-Bin $FoundationBinaryCache `
-InstallTo $(if ($Static) { "$(Get-SwiftSDK $Platform.OS -Identifier "$($Platform.OS)Experimental")\usr" } else { "$(Get-SwiftSDK $Platform.OS)\usr" }) `
-InstallTo $FoundationImage `
-Platform $Platform `
-UseBuiltCompilers ASM,C,CXX,Swift `
-SwiftSDK (Get-SwiftSDK $Platform.OS) `
-SwiftSDK $SwiftSDK `
-Defines @{
BUILD_SHARED_LIBS = if ($Static) { "NO" } else { "YES" };
CMAKE_FIND_PACKAGE_PREFER_CONFIG = "YES";
CMAKE_NINJA_FORCE_RESPONSE_FILE = "YES";
CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib";
CMAKE_Swift_FLAGS = $SwiftFlags;
ENABLE_TESTING = "NO";
FOUNDATION_BUILD_TOOLS = if ($Platform.OS -eq [OS]::Windows) { "YES" } else { "NO" };
CURL_DIR = "$BinaryCache\$($Platform.Triple)\usr\lib\cmake\CURL";
Expand Down Expand Up @@ -3337,7 +3356,6 @@ if (-not $SkipBuild) {

foreach ($Platform in $WindowsSDKPlatforms) {
Invoke-BuildStep Build-SDK $Platform
Invoke-BuildStep Build-ExperimentalSDK $Platform

Get-ChildItem "$(Get-SwiftSDK Windows)\usr\lib\swift\windows" -Filter "*.lib" -File -ErrorAction Ignore | ForEach-Object {
Write-Host -BackgroundColor DarkRed -ForegroundColor White "$($_.FullName) is not nested in an architecture directory"
Expand All @@ -3347,29 +3365,48 @@ if (-not $SkipBuild) {
Copy-Directory "$(Get-SwiftSDK Windows)\usr\bin" "$([IO.Path]::Combine((Get-InstallDir $Platform), "Runtimes", $ProductVersion, "usr"))"
}

Write-PlatformInfoPlist Windows
Install-SDK $WindowsSDKPlatforms
Write-SDKSettings Windows

foreach ($Platform in $WindowsSDKPlatforms) {
Invoke-BuildStep Build-ExperimentalSDK $Platform
Get-ChildItem "$(Get-SwiftSDK Windows -Identifier WindowsExperimental)\usr\lib\swift_static\windows" -Filter "*.lib" -File -ErrorAction Ignore | ForEach-Object {
Write-Host -BackgroundColor DarkRed -ForegroundColor White "$($_.FullName) is not nested in an architecture directory"
Move-Item $_.FullName "$(Get-SwiftSDK Windows -Identifier WindowsExperimental)\usr\lib\swift_static\windows\$($Platform.Architecture.LLVMName)\" | Out-Null
}
}

Install-SDK $WindowsSDKPlatforms -Identifier WindowsExperimental
Write-SDKSettings Windows -Identifier WindowsExperimental

Write-PlatformInfoPlist Windows

if ($Android) {
foreach ($Platform in $AndroidSDKPlatforms) {
Invoke-BuildStep Build-SDK $Platform
Invoke-BuildStep Build-ExperimentalSDK $Platform

Get-ChildItem "$(Get-SwiftSDK Android)\usr\lib\swift\android" -File | Where-Object { $_.Name -match ".a$|.so$" } | ForEach-Object {
Write-Host -BackgroundColor DarkRed -ForegroundColor White "$($_.FullName) is not nested in an architecture directory"
Move-Item $_.FullName "$(Get-SwiftSDK Android)\usr\lib\swift\android\$($Platform.Architecture.LLVMName)\" | Out-Null
}
}

Write-PlatformInfoPlist Android
Install-SDK $AndroidSDKPlatforms
Write-SDKSettings Android
Install-SDK $AndroidSDKPlatforms -Identifiers AndroidExperimental

foreach ($Platform in $AndroidSDKPlatforms) {
Invoke-BuildStep Build-ExperimentalSDK $Platform
Get-ChildItem "$(Get-SwiftSDK Android -Identifier AndroidExperimental)\usr\lib\swift_static\android" -File | Where-Object { $_.Name -match ".a$" } | ForEach-Object {
Write-Host -BackgroundColor DarkRed -ForegroundColor White "$($_.FullName) is not nested in an architecture directory"
Move-Item $_.FullName "$(Get-SwiftSDK Android -Identifier AndroidExperimental)\usr\lib\swift_static\android\$($Platform.Architecture.LLVMName)\" | Out-Null
}
}

Install-SDK $AndroidSDKPlatforms -Identifier AndroidExperimental
Write-SDKSettings Android -Identifier AndroidExperimental

Write-PlatformInfoPlist Android

# Android swift-inspect only supports 64-bit platforms.
$AndroidSDKPlatforms | Where-Object { @("arm64-v8a", "x86_64") -contains $_.Architecture.ABI } | ForEach-Object {
Invoke-BuildStep Build-Inspect $_
Expand Down