@@ -537,18 +537,18 @@ function Get-PythonScriptsPath {
537
537
538
538
function Get-InstallDir ([Hashtable ] $Platform ) {
539
539
if ($Platform -eq $HostPlatform ) {
540
- $ProgramFilesName = " Program Files"
541
- } elseif ($Platform -eq $KnownPlatforms [" WindowsX86" ]) {
542
- $ProgramFilesName = " Program Files (x86)"
543
- } elseif (($HostPlatform -eq $KnownPlatforms [" WindowsARM64" ]) -and ($Platform -eq $KnownPlatforms [" WindowsX64" ])) {
544
- # x64 programs actually install under "Program Files" on arm64,
545
- # but this would conflict with the native installation.
546
- $ProgramFilesName = " Program Files (Amd64)"
547
- } else {
548
- # arm64 cannot be installed on x64
549
- return $null
540
+ return [IO.Path ]::Combine(" $ImageRoot \" , " Program Files" , " Swift" )
541
+ }
542
+ if ($Platform -eq $KnownPlatforms [" WindowsARM64" ]) {
543
+ return [IO.Path ]::Combine(" $ImageRoot \" , " Program Files (Arm64)" , " Swift" )
544
+ }
545
+ if ($Platform -eq $KnownPlatforms [" WindowsX64" ]) {
546
+ return [IO.Path ]::Combine(" $ImageRoot \" , " Program Files (Amd64)" , " Swift" )
550
547
}
551
- return " $ImageRoot \$ProgramFilesName \Swift"
548
+ if ($Platform -eq $KnownPlatforms [" WindowsX86" ]) {
549
+ return [IO.Path ]::Combine(" $ImageRoot \" , " Program Files (x86)" , " Swift" )
550
+ }
551
+ throw " Unknown Platform"
552
552
}
553
553
554
554
# For dev productivity, install the host toolchain directly using CMake.
@@ -1601,10 +1601,7 @@ function Build-WiXProject() {
1601
1601
Add-KeyValueIfNew $Properties ProductArchitecture $Platform.Architecture.VSName
1602
1602
Add-KeyValueIfNew $Properties ProductVersion $ProductVersionArg
1603
1603
1604
- $MSBuildArgs = @ (" $SourceCache \swift-installer-scripts\platforms\Windows\$FileName " )
1605
- $MSBuildArgs += " -noLogo"
1606
- $MSBuildArgs += " -restore"
1607
- $MSBuildArgs += " -maxCpuCount"
1604
+ $MSBuildArgs = @ ( " -noLogo" , " -maxCpuCount" , " -restore" , " $SourceCache \swift-installer-scripts\platforms\Windows\$FileName " )
1608
1605
foreach ($Property in $Properties.GetEnumerator ()) {
1609
1606
if ($Property.Value.Contains (" " )) {
1610
1607
$MSBuildArgs += " -p:$ ( $Property.Key ) =$ ( $Property.Value.Replace (' \' , ' \\' )) "
@@ -2184,8 +2181,12 @@ function Build-Runtime([Hashtable] $Platform) {
2184
2181
$PlatformDefines += @ {
2185
2182
LLVM_ENABLE_LIBCXX = " YES" ;
2186
2183
SWIFT_USE_LINKER = " lld" ;
2187
- # Clang[<18] doesn't provide the _Builtin_float module.
2188
- SWIFT_BUILD_CLANG_OVERLAYS_SKIP_BUILTIN_FLOAT = " YES" ;
2184
+ }
2185
+
2186
+ if ((Get-AndroidNDK ).ClangVersion -lt 18 ) {
2187
+ $PlatformDefines += @ {
2188
+ SWIFT_BUILD_CLANG_OVERLAYS_SKIP_BUILTIN_FLOAT = " YES" ;
2189
+ }
2189
2190
}
2190
2191
}
2191
2192
@@ -2290,31 +2291,49 @@ function Build-ExperimentalRuntime {
2290
2291
}
2291
2292
}
2292
2293
2293
- function Write-SDKSettingsPlist ([Hashtable ] $Platform ) {
2294
+ function Write-SDKSettingsPlist ([OS ] $OS ) {
2294
2295
$SDKSettings = @ {
2295
2296
DefaultProperties = @ {
2296
2297
}
2297
2298
}
2298
- if ($Platform . OS -eq [OS ]::Windows) {
2299
+ if ($OS -eq [OS ]::Windows) {
2299
2300
$SDKSettings.DefaultProperties.DEFAULT_USE_RUNTIME = " MD"
2300
2301
}
2301
- Write-PList - Settings $SDKSettings - Path " $ ( Get-SwiftSDK $Platform . OS ) \SDKSettings.plist"
2302
+ Write-PList - Settings $SDKSettings - Path " $ ( Get-SwiftSDK $OS ) \SDKSettings.plist"
2302
2303
2303
2304
$SDKSettings = @ {
2304
- CanonicalName = " $ ( $Platform .Triple ) "
2305
- DisplayName = " $ ( $Platform . OS.ToString ()) "
2305
+ CanonicalName = $OS .ToString ()
2306
+ DisplayName = $ OS.ToString ()
2306
2307
IsBaseSDK = " NO"
2307
2308
Version = " ${ProductVersion} "
2308
2309
VersionMap = @ {}
2309
2310
DefaultProperties = @ {
2310
- PLATFORM_NAME = " $ ( $Platform . OS.ToString ()) "
2311
+ PLATFORM_NAME = $ OS.ToString ()
2311
2312
DEFAULT_COMPILER = " ${ToolchainIdentifier} "
2312
2313
}
2314
+ SupportedTargets = @ {
2315
+ $OS.ToString ().ToLowerInvariant() = @ {
2316
+ PlatformFamilyDisplayName = $OS.ToString ()
2317
+ PlatformFamilyName = $OS.ToString ()
2318
+ }
2319
+ }
2313
2320
}
2314
- if ($Platform.OS -eq [OS ]::Windows) {
2315
- $SDKSettings.DefaultProperties.DEFAULT_USE_RUNTIME = " MD"
2321
+ switch ($OS ) {
2322
+ Windows {
2323
+ $SDKSettings.DefaultProperties.DEFAULT_USE_RUNTIME = " MD"
2324
+ $SDKSettings.SupportedTargets.windows.LLVMTargetVendor = " unknown"
2325
+ $SDKSettings.SupportedTargets.windows.LLVMTargetSys = " windows"
2326
+ $SDKSettings.SupportedTargets.windows.LLVMTargetTripleEnvironment = " msvc"
2327
+ $SDKSettings.SupportedTargets.windows.Archs = $WindowsSDKPlatforms | ForEach-Object { $_.Architecture.LLVMName } | Sort-Object
2328
+ }
2329
+ Android {
2330
+ $SDKSettings.SupportedTargets.android.LLVMTargetVendor = " unknown"
2331
+ $SDKSettings.SupportedTargets.android.LLVMTargetSys = " linux"
2332
+ $SDKSettings.SupportedTargets.android.LLVMTargetTripleEnvironment = " android${AndroidAPILevel} "
2333
+ $SDKSettings.SupportedTargets.android.Archs = $AndroidSDKPlatforms | ForEach-Object { $_.Architecture.LLVMName } | Sort-Object
2334
+ }
2316
2335
}
2317
- $SDKSettings | ConvertTo-JSON | Out-FIle - FilePath " $ ( Get-SwiftSDK $Platform . OS ) \SDKSettings.json"
2336
+ $SDKSettings | ConvertTo-JSON - Depth 4 | Out-FIle - FilePath " $ ( Get-SwiftSDK $OS ) \SDKSettings.json"
2318
2337
}
2319
2338
2320
2339
function Build-Dispatch ([Hashtable ] $Platform ) {
@@ -2501,18 +2520,18 @@ function Test-Testing {
2501
2520
throw " testing Testing is not supported"
2502
2521
}
2503
2522
2504
- function Write-PlatformInfoPlist ([Hashtable ] $Platform ) {
2523
+ function Write-PlatformInfoPlist ([OS ] $OS ) {
2505
2524
$Settings = @ {
2506
2525
DefaultProperties = @ {
2507
2526
SWIFT_TESTING_VERSION = " $ProductVersion "
2508
2527
XCTEST_VERSION = " $ProductVersion "
2509
2528
}
2510
2529
}
2511
- if ($Platform . OS -eq [OS ]::Windows) {
2530
+ if ($OS -eq [OS ]::Windows) {
2512
2531
$Settings.DefaultProperties.SWIFTC_FLAGS = @ ( " -use-ld=lld" )
2513
2532
}
2514
2533
2515
- Write-PList - Settings $Settings - Path " $ ( Get-PlatformRoot $Platform . OS ) \Info.plist"
2534
+ Write-PList - Settings $Settings - Path " $ ( Get-PlatformRoot $OS ) \Info.plist"
2516
2535
}
2517
2536
2518
2537
# Copies files installed by CMake from the arch-specific platform root,
@@ -2532,12 +2551,44 @@ function Install-Platform([Hashtable[]] $Platforms, [OS] $OS) {
2532
2551
$PlatformResources = " $ ( Get-SwiftSDK $Platform.OS ) \usr\lib\swift\$ ( $Platform.OS.ToString ().ToLowerInvariant()) "
2533
2552
Get-ChildItem - Recurse " $PlatformResources \$ ( $Platform.Architecture.LLVMName ) " | ForEach-Object {
2534
2553
if (" .swiftmodule" , " .swiftdoc" , " .swiftinterface" -contains $_.Extension ) {
2554
+ Write-Host - BackgroundColor DarkRed - ForegroundColor White " $ ( $_.FullName ) is not in a thick module layout"
2535
2555
Copy-File $_.FullName " $PlatformResources \$ ( $_.BaseName ) .swiftmodule\$ ( Get-ModuleTriple $Platform ) $ ( $_.Extension ) "
2536
2556
}
2537
2557
}
2538
2558
}
2539
2559
}
2540
2560
2561
+ function Build-SDK ([Hashtable ] $Platform , [switch ] $IncludeMacros = $false ) {
2562
+ if ($IncludeDS2 ) {
2563
+ Invoke-BuildStep Build-DS2 $Platform
2564
+ }
2565
+
2566
+ # Third Party Dependencies
2567
+ Invoke-BuildStep Build-ZLib $Platform
2568
+ Invoke-BuildStep Build-XML2 $Platform
2569
+ Invoke-BuildStep Build-CURL $Platform
2570
+ Invoke-BuildStep Build-LLVM $Platform
2571
+
2572
+ # Libraries
2573
+ Invoke-BuildStep Build-Runtime $Platform
2574
+ Invoke-BuildStep Build-Dispatch $Platform
2575
+ if ($IncludeMacros ) {
2576
+ Invoke-BuildStep Build-FoundationMacros $Platform
2577
+ Invoke-BuildStep Build-TestingMacros $Platform
2578
+ }
2579
+ Invoke-BuildStep Build-Foundation $Platform
2580
+ Invoke-BuildStep Build-Sanitizers $Platform
2581
+ Invoke-BuildStep Build-XCTest $Platform
2582
+ Invoke-BuildStep Build-Testing $Platform
2583
+ }
2584
+
2585
+ function Build-ExperimentalSDK ([Hashtable ] $Platform ) {
2586
+ # TODO(compnerd) we currently build the experimental SDK with just the static
2587
+ # variant. We should aim to build both dynamic and static variants.
2588
+ Invoke-BuildStep Build-ExperimentalRuntime $Platform - Static
2589
+ Invoke-BuildStep Build-Foundation $Platform - Static
2590
+ }
2591
+
2541
2592
function Build-SQLite ([Hashtable ] $Platform ) {
2542
2593
Build-CMakeProject `
2543
2594
- Src $SourceCache \swift- toolchain- sqlite `
@@ -3077,14 +3128,14 @@ function Test-PackageManager() {
3077
3128
function Build-Installer ([Hashtable ] $Platform ) {
3078
3129
# TODO(hjyamauchi) Re-enable the swift-inspect and swift-docc builds
3079
3130
# when cross-compiling https://github.com/apple/swift/issues/71655
3080
- $INCLUDE_SWIFT_DOCC = if ($IsCrossCompiling ) { " false " } else { " true " }
3131
+ $INCLUDE_SWIFT_DOCC = if ($IsCrossCompiling ) { " False " } else { " True " }
3081
3132
3082
3133
$Properties = @ {
3083
3134
BundleFlavor = " offline" ;
3084
- TOOLCHAIN_ROOT = " $ ( $Platform.ToolchainInstallRoot ) \" ;
3135
+ ImageRoot = " $ ( Get-InstallDir $Platform ) \" ;
3085
3136
# When cross-compiling, bundle the second mimalloc redirect dll as a workaround for
3086
3137
# https://github.com/microsoft/mimalloc/issues/997
3087
- WORKAROUND_MIMALLOC_ISSUE_997 = if ($IsCrossCompiling ) { " true " } else { " false " };
3138
+ WORKAROUND_MIMALLOC_ISSUE_997 = if ($IsCrossCompiling ) { " True " } else { " False " };
3088
3139
INCLUDE_SWIFT_DOCC = $INCLUDE_SWIFT_DOCC ;
3089
3140
SWIFT_DOCC_BUILD = " $ ( Get-ProjectBinaryCache $HostPlatform DocC) \release" ;
3090
3141
SWIFT_DOCC_RENDER_ARTIFACT_ROOT = " ${SourceCache} \swift-docc-render-artifact" ;
@@ -3099,10 +3150,11 @@ function Build-Installer([Hashtable] $Platform) {
3099
3150
}
3100
3151
}
3101
3152
3153
+ $Properties [" Platforms" ] = " `" windows$ ( if ($Android ) { " ;android" }) `" " ;
3154
+ $Properties [" AndroidArchitectures" ] = " `" $ ( ($AndroidSDKPlatforms | ForEach-Object { $_.Architecture.LLVMName }) -Join " ;" ) `" "
3155
+ $Properties [" WindowsArchitectures" ] = " `" $ ( ($WindowsSDKPlatforms | ForEach-Object { $_.Architecture.LLVMName }) -Join " ;" ) `" "
3102
3156
foreach ($SDKPlatform in $WindowsSDKPlatforms ) {
3103
- $Properties [" INCLUDE_WINDOWS_$ ( $SDKPlatform.Architecture.VSName.ToUpperInvariant ()) _SDK" ] = " true"
3104
- $Properties [" PLATFORM_ROOT_$ ( $SDKPlatform.Architecture.VSName.ToUpperInvariant ()) " ] = " $ ( Get-PlatformRoot Windows) \" ;
3105
- $Properties [" SDK_ROOT_$ ( $SDKPlatform.Architecture.VSName.ToUpperInvariant ()) " ] = " $ ( Get-SwiftSDK Windows) \"
3157
+ $Properties [" WindowsRuntime$ ( $SDKPlatform.Architecture.ShortName.ToUpperInvariant ()) " ] = [IO.Path ]::Combine((Get-InstallDir $SDKPlatform ), " Runtimes" , " $ProductVersion " );
3106
3158
}
3107
3159
3108
3160
Build-WiXProject bundle\installer.wixproj - Platform $Platform - Bundle - Properties $Properties
@@ -3111,11 +3163,7 @@ function Build-Installer([Hashtable] $Platform) {
3111
3163
function Copy-BuildArtifactsToStage ([Hashtable ] $Platform ) {
3112
3164
Copy-File " $BinaryCache \$ ( $Platform.Triple ) \installer\Release\$ ( $Platform.Architecture.VSName ) \*.cab" $Stage
3113
3165
Copy-File " $BinaryCache \$ ( $Platform.Triple ) \installer\Release\$ ( $Platform.Architecture.VSName ) \*.msi" $Stage
3114
- foreach ($SDKPlatform in $WindowsSDKPlatforms ) {
3115
- Copy-File " $BinaryCache \$ ( $Platform.Triple ) \installer\Release\$ ( $SDKPlatform.Architecture.VSName ) \sdk.windows.$ ( $SDKPlatform.Architecture.VSName ) .cab" $Stage
3116
- Copy-File " $BinaryCache \$ ( $Platform.Triple ) \installer\Release\$ ( $SDKPlatform.Architecture.VSName ) \sdk.windows.$ ( $SDKPlatform.Architecture.VSName ) .msi" $Stage
3117
- Copy-File " $BinaryCache \$ ( $Platform.Triple ) \installer\Release\$ ( $SDKPlatform.Architecture.VSName ) \rtl.$ ( $SDKPlatform.Architecture.VSName ) .msm" $Stage
3118
- }
3166
+ Copy-File " $BinaryCache \$ ( $Platform.Triple ) \installer\Release\$ ( $Platform.Architecture.VSName ) \*.msm" $Stage
3119
3167
Copy-File " $BinaryCache \$ ( $Platform.Triple ) \installer\Release\$ ( $Platform.Architecture.VSName ) \installer.exe" $Stage
3120
3168
# Extract installer engine to ease code-signing on swift.org CI
3121
3169
if ($ToBatch ) {
@@ -3167,69 +3215,43 @@ if (-not $SkipBuild) {
3167
3215
Invoke-BuildStep Build-XML2 $HostPlatform
3168
3216
Invoke-BuildStep Build-Compilers $HostPlatform
3169
3217
3218
+ Invoke-BuildStep Build-SDK $BuildPlatform - IncludeMacros
3219
+
3170
3220
foreach ($Platform in $WindowsSDKPlatforms ) {
3171
- Invoke-BuildStep Build-ZLib $Platform
3172
- Invoke-BuildStep Build-XML2 $Platform
3173
- Invoke-BuildStep Build-CURL $Platform
3174
- Invoke-BuildStep Build-LLVM $Platform
3221
+ Invoke-BuildStep Build-SDK $Platform
3222
+ Invoke-BuildStep Build-ExperimentalSDK $Platform
3175
3223
3176
- # Build platform: SDK, Redist and XCTest
3177
- Invoke-BuildStep Build-Runtime $Platform
3178
- Invoke-BuildStep Build-Dispatch $Platform
3179
- # FIXME(compnerd) ensure that the _build_ is the first arch and don't rebuild on each arch
3180
- if ($Platform -eq $BuildPlatform ) {
3181
- Invoke-BuildStep Build-FoundationMacros $BuildPlatform
3182
- Invoke-BuildStep Build-TestingMacros $BuildPlatform
3224
+ Get-ChildItem " $ ( Get-SwiftSDK Windows) \usr\lib\swift\windows" - Filter " *.lib" - File - ErrorAction Ignore | ForEach-Object {
3225
+ Write-Host - BackgroundColor DarkRed - ForegroundColor White " $ ( $_.FullName ) is not nested in an architecture directory"
3226
+ Move-Item $_.FullName " $ ( Get-SwiftSDK Windows) \usr\lib\swift\windows\$ ( $Platform.Architecture.LLVMName ) \" | Out-Null
3183
3227
}
3184
- Invoke-BuildStep Build-Foundation $Platform
3185
- Invoke-BuildStep Build-Sanitizers $Platform
3186
- Invoke-BuildStep Build-XCTest $Platform
3187
- Invoke-BuildStep Build-Testing $Platform
3188
- Invoke-BuildStep Write-SDKSettingsPlist $Platform
3189
3228
3190
- Invoke-BuildStep Build-ExperimentalRuntime $Platform - Static
3191
- Invoke-BuildStep Build-Foundation $Platform - Static
3192
-
3193
- Copy-File " $ ( Get-SwiftSDK Windows) \usr\lib\swift\windows\*.lib" " $ ( Get-SwiftSDK Windows) \usr\lib\swift\windows\$ ( $Platform.Architecture.LLVMName ) \"
3194
- if ($Platform -eq $HostPlatform ) {
3195
- Copy-Directory " $ ( Get-SwiftSDK Windows) \usr\bin" " $ ( [IO.Path ]::Combine((Get-InstallDir $HostPlatform ), " Runtimes" , $ProductVersion )) \usr"
3196
- }
3229
+ Copy-Directory " $ ( Get-SwiftSDK Windows) \usr\bin" " $ ( [IO.Path ]::Combine((Get-InstallDir $Platform ), " Runtimes" , $ProductVersion , " usr" )) "
3197
3230
}
3231
+
3198
3232
Install-Platform $WindowsSDKPlatforms Windows
3199
- Invoke-BuildStep Write-PlatformInfoPlist $HostPlatform
3233
+ Write-PlatformInfoPlist Windows
3234
+ Write-SDKSettingsPlist Windows
3200
3235
3201
3236
if ($Android ) {
3202
3237
foreach ($Platform in $AndroidSDKPlatforms ) {
3203
- if ($IncludeDS2 ) {
3204
- Invoke-BuildStep Build-DS2 $Platform
3205
- }
3206
- Invoke-BuildStep Build-ZLib $Platform
3207
- Invoke-BuildStep Build-XML2 $Platform
3208
- Invoke-BuildStep Build-CURL $Platform
3209
- Invoke-BuildStep Build-LLVM $Platform
3210
-
3211
- # Build platform: SDK, Redist and XCTest
3212
- Invoke-BuildStep Build-Runtime $Platform
3213
- Invoke-BuildStep Build-Dispatch $Platform
3214
- Invoke-BuildStep Build-Foundation $Platform
3215
- Invoke-BuildStep Build-Sanitizers $Platform
3216
- Invoke-BuildStep Build-XCTest $Platform
3217
- Invoke-BuildStep Build-Testing $Platform
3218
-
3219
- # Android swift-inspect only supports 64-bit platforms.
3220
- if ($Platform.Architecture.ABI -in @ (" arm64-v8a" , " x86_64" )) {
3221
- Invoke-BuildStep Build-Inspect $Platform
3238
+ Invoke-BuildStep Build-SDK $Platform
3239
+ Invoke-BuildStep Build-ExperimentalSDK $Platform
3240
+
3241
+ Get-ChildItem " $ ( Get-SwiftSDK Android) \usr\lib\swift\android" - File | Where-Object { $_.Name -match " .a$|.so$" } | ForEach-Object {
3242
+ Write-Host - BackgroundColor DarkRed - ForegroundColor White " $ ( $_.FullName ) is not nested in an architecture directory"
3243
+ Move-Item $_.FullName " $ ( Get-SwiftSDK Android) \usr\lib\swift\android\$ ( $Platform.Architecture.LLVMName ) \" | Out-Null
3222
3244
}
3223
- Invoke-BuildStep Write-SDKSettingsPlist $Platform
3245
+ }
3224
3246
3225
- Invoke-BuildStep Build-ExperimentalRuntime $Platform - Static
3226
- Invoke-BuildStep Build-Foundation $Platform - Static
3247
+ Install-Platform $AndroidSDKPlatforms Android
3248
+ Write-PlatformInfoPlist Android
3249
+ Write-SDKSettingsPlist Android
3227
3250
3228
- Move-Item " $ ( Get-SwiftSDK Android) \usr\lib\swift\android\*.a" " $ ( Get-SwiftSDK Android) \usr\lib\swift\android\$ ( $Platform.Architecture.LLVMName ) \"
3229
- Move-Item " $ ( Get-SwiftSDK Android) \usr\lib\swift\android\*.so" " $ ( Get-SwiftSDK Android) \usr\lib\swift\android\$ ( $Platform.Architecture.LLVMName ) \"
3251
+ # Android swift-inspect only supports 64-bit platforms.
3252
+ $AndroidSDKPlatforms | Where-Object { @ (" arm64-v8a" , " x86_64" ) -contains $_.Architecture.ABI } | ForEach-Object {
3253
+ Invoke-BuildStep Build-Inspect $_
3230
3254
}
3231
- Install-Platform $AndroidSDKPlatforms Android
3232
- Invoke-BuildStep Write-PlatformInfoPlist $Platform
3233
3255
}
3234
3256
3235
3257
# Build Macros for distribution
0 commit comments