@@ -537,18 +537,18 @@ function Get-PythonScriptsPath {
537537
538538function Get-InstallDir ([Hashtable ] $Platform ) {
539539 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" )
550547 }
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"
552552}
553553
554554# For dev productivity, install the host toolchain directly using CMake.
@@ -1601,10 +1601,7 @@ function Build-WiXProject() {
16011601 Add-KeyValueIfNew $Properties ProductArchitecture $Platform.Architecture.VSName
16021602 Add-KeyValueIfNew $Properties ProductVersion $ProductVersionArg
16031603
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 " )
16081605 foreach ($Property in $Properties.GetEnumerator ()) {
16091606 if ($Property.Value.Contains (" " )) {
16101607 $MSBuildArgs += " -p:$ ( $Property.Key ) =$ ( $Property.Value.Replace (' \' , ' \\' )) "
@@ -2184,8 +2181,12 @@ function Build-Runtime([Hashtable] $Platform) {
21842181 $PlatformDefines += @ {
21852182 LLVM_ENABLE_LIBCXX = " YES" ;
21862183 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+ }
21892190 }
21902191 }
21912192
@@ -2290,31 +2291,49 @@ function Build-ExperimentalRuntime {
22902291 }
22912292}
22922293
2293- function Write-SDKSettingsPlist ([Hashtable ] $Platform ) {
2294+ function Write-SDKSettingsPlist ([OS ] $OS ) {
22942295 $SDKSettings = @ {
22952296 DefaultProperties = @ {
22962297 }
22972298 }
2298- if ($Platform . OS -eq [OS ]::Windows) {
2299+ if ($OS -eq [OS ]::Windows) {
22992300 $SDKSettings.DefaultProperties.DEFAULT_USE_RUNTIME = " MD"
23002301 }
2301- Write-PList - Settings $SDKSettings - Path " $ ( Get-SwiftSDK $Platform . OS ) \SDKSettings.plist"
2302+ Write-PList - Settings $SDKSettings - Path " $ ( Get-SwiftSDK $OS ) \SDKSettings.plist"
23022303
23032304 $SDKSettings = @ {
2304- CanonicalName = " $ ( $Platform .Triple ) "
2305- DisplayName = " $ ( $Platform . OS.ToString ()) "
2305+ CanonicalName = $OS .ToString ()
2306+ DisplayName = $ OS.ToString ()
23062307 IsBaseSDK = " NO"
23072308 Version = " ${ProductVersion} "
23082309 VersionMap = @ {}
23092310 DefaultProperties = @ {
2310- PLATFORM_NAME = " $ ( $Platform . OS.ToString ()) "
2311+ PLATFORM_NAME = $ OS.ToString ()
23112312 DEFAULT_COMPILER = " ${ToolchainIdentifier} "
23122313 }
2314+ SupportedTargets = @ {
2315+ $OS.ToString ().ToLowerInvariant() = @ {
2316+ PlatformFamilyDisplayName = $OS.ToString ()
2317+ PlatformFamilyName = $OS.ToString ()
2318+ }
2319+ }
23132320 }
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+ }
23162335 }
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"
23182337}
23192338
23202339function Build-Dispatch ([Hashtable ] $Platform ) {
@@ -2501,18 +2520,18 @@ function Test-Testing {
25012520 throw " testing Testing is not supported"
25022521}
25032522
2504- function Write-PlatformInfoPlist ([Hashtable ] $Platform ) {
2523+ function Write-PlatformInfoPlist ([OS ] $OS ) {
25052524 $Settings = @ {
25062525 DefaultProperties = @ {
25072526 SWIFT_TESTING_VERSION = " $ProductVersion "
25082527 XCTEST_VERSION = " $ProductVersion "
25092528 }
25102529 }
2511- if ($Platform . OS -eq [OS ]::Windows) {
2530+ if ($OS -eq [OS ]::Windows) {
25122531 $Settings.DefaultProperties.SWIFTC_FLAGS = @ ( " -use-ld=lld" )
25132532 }
25142533
2515- Write-PList - Settings $Settings - Path " $ ( Get-PlatformRoot $Platform . OS ) \Info.plist"
2534+ Write-PList - Settings $Settings - Path " $ ( Get-PlatformRoot $OS ) \Info.plist"
25162535}
25172536
25182537# Copies files installed by CMake from the arch-specific platform root,
@@ -2532,12 +2551,44 @@ function Install-Platform([Hashtable[]] $Platforms, [OS] $OS) {
25322551 $PlatformResources = " $ ( Get-SwiftSDK $Platform.OS ) \usr\lib\swift\$ ( $Platform.OS.ToString ().ToLowerInvariant()) "
25332552 Get-ChildItem - Recurse " $PlatformResources \$ ( $Platform.Architecture.LLVMName ) " | ForEach-Object {
25342553 if (" .swiftmodule" , " .swiftdoc" , " .swiftinterface" -contains $_.Extension ) {
2554+ Write-Host - BackgroundColor DarkRed - ForegroundColor White " $ ( $_.FullName ) is not in a thick module layout"
25352555 Copy-File $_.FullName " $PlatformResources \$ ( $_.BaseName ) .swiftmodule\$ ( Get-ModuleTriple $Platform ) $ ( $_.Extension ) "
25362556 }
25372557 }
25382558 }
25392559}
25402560
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+
25412592function Build-SQLite ([Hashtable ] $Platform ) {
25422593 Build-CMakeProject `
25432594 - Src $SourceCache \swift- toolchain- sqlite `
@@ -3077,14 +3128,14 @@ function Test-PackageManager() {
30773128function Build-Installer ([Hashtable ] $Platform ) {
30783129 # TODO(hjyamauchi) Re-enable the swift-inspect and swift-docc builds
30793130 # 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 " }
30813132
30823133 $Properties = @ {
30833134 BundleFlavor = " offline" ;
3084- TOOLCHAIN_ROOT = " $ ( $Platform.ToolchainInstallRoot ) \" ;
3135+ ImageRoot = " $ ( Get-InstallDir $Platform ) \" ;
30853136 # When cross-compiling, bundle the second mimalloc redirect dll as a workaround for
30863137 # 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 " };
30883139 INCLUDE_SWIFT_DOCC = $INCLUDE_SWIFT_DOCC ;
30893140 SWIFT_DOCC_BUILD = " $ ( Get-ProjectBinaryCache $HostPlatform DocC) \release" ;
30903141 SWIFT_DOCC_RENDER_ARTIFACT_ROOT = " ${SourceCache} \swift-docc-render-artifact" ;
@@ -3099,10 +3150,11 @@ function Build-Installer([Hashtable] $Platform) {
30993150 }
31003151 }
31013152
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 " ;" ) `" "
31023156 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 " );
31063158 }
31073159
31083160 Build-WiXProject bundle\installer.wixproj - Platform $Platform - Bundle - Properties $Properties
@@ -3111,11 +3163,7 @@ function Build-Installer([Hashtable] $Platform) {
31113163function Copy-BuildArtifactsToStage ([Hashtable ] $Platform ) {
31123164 Copy-File " $BinaryCache \$ ( $Platform.Triple ) \installer\Release\$ ( $Platform.Architecture.VSName ) \*.cab" $Stage
31133165 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
31193167 Copy-File " $BinaryCache \$ ( $Platform.Triple ) \installer\Release\$ ( $Platform.Architecture.VSName ) \installer.exe" $Stage
31203168 # Extract installer engine to ease code-signing on swift.org CI
31213169 if ($ToBatch ) {
@@ -3167,69 +3215,43 @@ if (-not $SkipBuild) {
31673215 Invoke-BuildStep Build-XML2 $HostPlatform
31683216 Invoke-BuildStep Build-Compilers $HostPlatform
31693217
3218+ Invoke-BuildStep Build-SDK $BuildPlatform - IncludeMacros
3219+
31703220 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
31753223
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
31833227 }
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
31893228
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" )) "
31973230 }
3231+
31983232 Install-Platform $WindowsSDKPlatforms Windows
3199- Invoke-BuildStep Write-PlatformInfoPlist $HostPlatform
3233+ Write-PlatformInfoPlist Windows
3234+ Write-SDKSettingsPlist Windows
32003235
32013236 if ($Android ) {
32023237 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
32223244 }
3223- Invoke-BuildStep Write-SDKSettingsPlist $Platform
3245+ }
32243246
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
32273250
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 $_
32303254 }
3231- Install-Platform $AndroidSDKPlatforms Android
3232- Invoke-BuildStep Write-PlatformInfoPlist $Platform
32333255 }
32343256
32353257 # Build Macros for distribution
0 commit comments