@@ -38,10 +38,16 @@ The API Level to target when building the Android SDKs
3838. PARAMETER Android
3939When set, build android SDKs.
4040
41- . PARAMETER AndroidSDKs
41+ . PARAMETER AndroidSDKVersions
42+ An array of SDKs to build for the Android OS.
43+
44+ . PARAMETER AndroidSDKArchitectures
4245An array of architectures for which the Android Swift SDK should be built.
4346
44- . PARAMETER WindowsSDKs
47+ . PARAMETER WindowsSDKVersions
48+ An array of SDKs to build for the Windows OS.
49+
50+ . PARAMETER WindowsSDKArchitectures
4551An array of architectures for which the Windows Swift SDK should be built.
4652
4753. PARAMETER ProductVersion
@@ -106,7 +112,7 @@ Whether to run swift-foundation and swift-corelibs-foundation tests in a debug o
106112PS> .\Build.ps1
107113
108114. EXAMPLE
109- PS> .\Build.ps1 -WindowsSDKs x64 -ProductVersion 1.2.3 -Test foundation,xctest
115+ PS> .\Build.ps1 -WindowsSDKArchitectures x64 -ProductVersion 1.2.3 -Test foundation,xctest
110116#>
111117[CmdletBinding (PositionalBinding = $false )]
112118param
@@ -120,8 +126,10 @@ param
120126 [string ] $SwiftDebugFormat = " dwarf" ,
121127 [ValidateRange (1 , 36 )]
122128 [int ] $AndroidAPILevel = 28 ,
123- [string []] $AndroidSDKs = @ (),
124- [string []] $WindowsSDKs = @ (" X64" , " X86" , " Arm64" ),
129+ [string []] $AndroidSDKVersions = @ (" Android" , " AndroidExperimental" ),
130+ [string []] $AndroidSDKArchitectures = @ (" aarch64" , " armv7" , " i686" , " x86_64" ),
131+ [string []] $WindowsSDKVersions = @ (" Windows" , " WindowsExperimental" ),
132+ [string []] $WindowsSDKArchitectures = @ (" X64" , " X86" , " Arm64" ),
125133 [string ] $ProductVersion = " 0.0.0" ,
126134 [string ] $ToolchainIdentifier = $ (if ($env: TOOLCHAIN_VERSION ) { $env: TOOLCHAIN_VERSION } else { " $env: USERNAME .development" }),
127135 [string ] $PinnedBuild = " " ,
@@ -182,20 +190,14 @@ if (($PinnedBuild -or $PinnedSHA256 -or $PinnedVersion) -and -not ($PinnedBuild
182190 throw " If any of PinnedBuild, PinnedSHA256, or PinnedVersion is set, all three must be set."
183191}
184192
185- if ($Android -and ($AndroidSDKs.Length -eq 0 )) {
186- # Enable all android SDKs by default.
187- $AndroidSDKs = @ (" aarch64" , " armv7" , " i686" , " x86_64" )
188- }
189-
190193# Work around limitations of cmd passing in array arguments via powershell.exe -File
191- if ($AndroidSDKs.Length -eq 1 ) { $AndroidSDKs = $AndroidSDKs [0 ].Split(" ," ) }
192- if ($WindowsSDKs.Length -eq 1 ) { $WindowsSDKs = $WindowsSDKs [0 ].Split(" ," ) }
193- if ($Test.Length -eq 1 ) { $Test = $Test [0 ].Split(" ," ) }
194+ if ($AndroidSDKVersions.Length -eq 1 ) { $AndroidSDKVersions = $AndroidSDKVersions [0 ].Split(" ," ) }
195+ if ($AndroidSDKArchitectures.Length -eq 1 ) { $AndroidSDKArchitectures = $AndroidSDKArchitectures [0 ].Split(" ," ) }
194196
195- if ($AndroidSDKs .Length -gt 0 ) {
196- # Always enable android when one of the SDKs is specified.
197- $Android = $true
198- }
197+ if ($WindowsSDKVersions .Length -eq 1 ) { $WindowsSDKVersions = $WindowsSDKVersions [ 0 ].Split( " , " ) }
198+ if ( $WindowsSDKArchitectures .Length -eq 1 ) { $WindowsSDKArchitectures = $WindowsSDKArchitectures [ 0 ].Split( " , " ) }
199+
200+ if ( $Test .Length -eq 1 ) { $Test = $Test [ 0 ].Split( " , " ) }
199201
200202if ($Test -contains " *" ) {
201203 # Explicitly don't include llbuild yet since tests are known to fail on Windows
@@ -492,7 +494,7 @@ if ($Android -and ($HostPlatform -ne $KnownPlatforms["WindowsX64"])) {
492494}
493495
494496# Resolve the architectures received as argument
495- $AndroidSDKPlatforms = @ ($AndroidSDKs | ForEach-Object {
497+ $AndroidSDKBuilds = @ ($AndroidSDKArchitectures | ForEach-Object {
496498 switch ($_ ) {
497499 " aarch64" { $KnownPlatforms [" AndroidARM64" ] }
498500 " armv7" { $KnownPlatforms [" AndroidARMv7" ] }
@@ -502,7 +504,7 @@ $AndroidSDKPlatforms = @($AndroidSDKs | ForEach-Object {
502504 }
503505})
504506
505- $WindowsSDKPlatforms = @ ($WindowsSDKs | ForEach-Object {
507+ $WindowsSDKBuilds = @ ($WindowsSDKArchitectures | ForEach-Object {
506508 switch ($_ ) {
507509 " X64" { $KnownPlatforms [" WindowsX64" ] }
508510 " X86" { $KnownPlatforms [" WindowsX86" ] }
@@ -1189,14 +1191,14 @@ function Get-Dependencies {
11891191 $script :CustomWinSDKRoot = " $NugetRoot \$Package .$WinSDKVersion \c"
11901192
11911193 # Install each required architecture package and move files under the base /lib directory.
1192- $WinSDKPlatforms = $WindowsSDKPlatforms .Clone ()
1193- if (-not ($HostPlatform -in $WinSDKPlatforms )) {
1194- $WinSDKPlatforms += $HostPlatform
1194+ $Builds = $WindowsSDKBuilds .Clone ()
1195+ if (-not ($HostPlatform -in $Builds )) {
1196+ $Builds += $HostPlatform
11951197 }
11961198
1197- foreach ($Platform in $WinSDKPlatforms ) {
1198- Invoke-Program nuget install $Package .$ ($Platform .Architecture.ShortName ) - Version $WinSDKVersion - OutputDirectory $NugetRoot
1199- Copy-Directory " $NugetRoot \$Package .$ ( $Platform .Architecture.ShortName ) .$WinSDKVersion \c\*" " $CustomWinSDKRoot \lib\$WinSDKVersion "
1199+ foreach ($Build in $Builds ) {
1200+ Invoke-Program nuget install $Package .$ ($Build .Architecture.ShortName ) - Version $WinSDKVersion - OutputDirectory $NugetRoot
1201+ Copy-Directory " $NugetRoot \$Package .$ ( $Build .Architecture.ShortName ) .$WinSDKVersion \c\*" " $CustomWinSDKRoot \lib\$WinSDKVersion "
12001202 }
12011203 }
12021204 }
@@ -2710,13 +2712,13 @@ function Write-SDKSettings([OS] $OS, [string] $Identifier = $OS.ToString()) {
27102712 $SDKSettings.SupportedTargets.windows.LLVMTargetVendor = " unknown"
27112713 $SDKSettings.SupportedTargets.windows.LLVMTargetSys = " windows"
27122714 $SDKSettings.SupportedTargets.windows.LLVMTargetTripleEnvironment = " msvc"
2713- $SDKSettings.SupportedTargets.windows.Archs = $WindowsSDKPlatforms | ForEach-Object { $_.Architecture.LLVMName } | Sort-Object
2715+ $SDKSettings.SupportedTargets.windows.Archs = $WindowsSDKBuilds | ForEach-Object { $_.Architecture.LLVMName } | Sort-Object
27142716 }
27152717 Android {
27162718 $SDKSettings.SupportedTargets.android.LLVMTargetVendor = " unknown"
27172719 $SDKSettings.SupportedTargets.android.LLVMTargetSys = " linux"
27182720 $SDKSettings.SupportedTargets.android.LLVMTargetTripleEnvironment = " android${AndroidAPILevel} "
2719- $SDKSettings.SupportedTargets.android.Archs = $AndroidSDKPlatforms | ForEach-Object { $_.Architecture.LLVMName } | Sort-Object
2721+ $SDKSettings.SupportedTargets.android.Archs = $AndroidSDKBuilds | ForEach-Object { $_.Architecture.LLVMName } | Sort-Object
27202722 }
27212723 }
27222724 $SDKSettings | ConvertTo-JSON - Depth 4 | Out-FIle - FilePath " $ ( Get-SwiftSDK $OS - Identifier $Identifier ) \SDKSettings.json"
@@ -3613,11 +3615,11 @@ function Build-Installer([Hashtable] $Platform) {
36133615 }
36143616
36153617 $Properties [" Platforms" ] = " `" windows$ ( if ($Android ) { " ;android" }) `" " ;
3616- $Properties [" AndroidArchitectures" ] = " `" $ ( ($AndroidSDKPlatforms | ForEach-Object { $_.Architecture.LLVMName }) -Join " ;" ) `" "
3617- $Properties [" WindowsArchitectures" ] = " `" $ ( ($WindowsSDKPlatforms | ForEach-Object { $_.Architecture.LLVMName }) -Join " ;" ) `" "
3618+ $Properties [" AndroidArchitectures" ] = " `" $ ( ($AndroidSDKBuilds | ForEach-Object { $_.Architecture.LLVMName }) -Join " ;" ) `" "
3619+ $Properties [" WindowsArchitectures" ] = " `" $ ( ($WindowsSDKBuilds | ForEach-Object { $_.Architecture.LLVMName }) -Join " ;" ) `" "
36183620 $Properties [" ToolchainVariants" ] = " `" asserts$ ( if ($IncludeNoAsserts ) { " ;noasserts" }) `" " ;
3619- foreach ($SDKPlatform in $WindowsSDKPlatforms ) {
3620- $Properties [" WindowsRuntime$ ( $SDKPlatform .Architecture.ShortName.ToUpperInvariant ()) " ] = [IO.Path ]::Combine((Get-InstallDir $SDKPlatform ), " Runtimes" , " $ProductVersion " );
3621+ foreach ($Build in $WindowsSDKBuilds ) {
3622+ $Properties [" WindowsRuntime$ ( $Build .Architecture.ShortName.ToUpperInvariant ()) " ] = [IO.Path ]::Combine((Get-InstallDir $Build ), " Runtimes" , " $ProductVersion " );
36213623 }
36223624
36233625 Build-WiXProject bundle\installer.wixproj - Platform $Platform - Bundle - Properties $Properties
@@ -3626,8 +3628,8 @@ function Build-Installer([Hashtable] $Platform) {
36263628function Copy-BuildArtifactsToStage ([Hashtable ] $Platform ) {
36273629 Copy-File " $BinaryCache \$ ( $Platform.Triple ) \installer\Release\$ ( $Platform.Architecture.VSName ) \*.cab" $Stage
36283630 Copy-File " $BinaryCache \$ ( $Platform.Triple ) \installer\Release\$ ( $Platform.Architecture.VSName ) \*.msi" $Stage
3629- foreach ($SDKPlatform in $WindowsSDKPlatforms ) {
3630- Copy-File " $BinaryCache \$ ( $Platform.Triple ) \installer\Release\$ ( $SDKPlatform .Architecture.VSName ) \*.msm" $Stage
3631+ foreach ($Build in $WindowsSDKBuilds ) {
3632+ Copy-File " $BinaryCache \$ ( $Platform.Triple ) \installer\Release\$ ( $Build .Architecture.VSName ) \*.msm" $Stage
36313633 }
36323634 Copy-File " $BinaryCache \$ ( $Platform.Triple ) \installer\Release\$ ( $Platform.Architecture.VSName ) \installer.exe" $Stage
36333635 # Extract installer engine to ease code-signing on swift.org CI
@@ -3678,11 +3680,11 @@ Get-Dependencies
36783680if ($Clean ) {
36793681 Remove-Item - Force - Recurse - Path " $BinaryCache \$ ( $BuildPlatform.Triple ) \" - ErrorAction Ignore
36803682 Remove-Item - Force - Recurse - Path " $BinaryCache \$ ( $HostPlatform.Triple ) \" - ErrorAction Ignore
3681- foreach ($Platform in $WindowsSDKPlatforms ) {
3682- Remove-Item - Force - Recurse - Path " $BinaryCache \$ ( $Platform .Triple ) \" - ErrorAction Ignore
3683+ foreach ($Build in $WindowsSDKBuilds ) {
3684+ Remove-Item - Force - Recurse - Path " $BinaryCache \$ ( $Build .Triple ) \" - ErrorAction Ignore
36833685 }
3684- foreach ($Platform in $AndroidSDKPlatforms ) {
3685- Remove-Item - Force - Recurse - Path " $BinaryCache \$ ( $Platform .Triple ) \" - ErrorAction Ignore
3686+ foreach ($Build in $AndroidSDKBuilds ) {
3687+ Remove-Item - Force - Recurse - Path " $BinaryCache \$ ( $Build .Triple ) \" - ErrorAction Ignore
36863688 }
36873689 Remove-Item - Force - Recurse - Path " $BinaryCache \1" - ErrorAction Ignore
36883690 Remove-Item - Force - Recurse - Path " $BinaryCache \5" - ErrorAction Ignore
@@ -3712,55 +3714,80 @@ if (-not $SkipBuild) {
37123714
37133715 Invoke-BuildStep Build-SDK $BuildPlatform - IncludeMacros
37143716
3715- foreach ($Platform in $WindowsSDKPlatforms ) {
3716- Invoke-BuildStep Build-SDK $Platform
3717+ foreach ($SDK in $WindowsSDKVersions ) {
3718+ switch ($SDK ) {
3719+ Windows {
3720+ foreach ($Build in $WindowsSDKBuilds ) {
3721+ Invoke-BuildStep Build-SDK $Build
37173722
3718- Get-ChildItem " $ ( Get-SwiftSDK Windows) \usr\lib\swift\windows" - Filter " *.lib" - File - ErrorAction Ignore | ForEach-Object {
3719- Write-Host - BackgroundColor DarkRed - ForegroundColor White " $ ( $_.FullName ) is not nested in an architecture directory"
3720- Move-Item $_.FullName " $ ( Get-SwiftSDK Windows) \usr\lib\swift\windows\$ ( $Platform .Architecture.LLVMName ) \" | Out-Null
3721- }
3723+ Get-ChildItem " $ ( Get-SwiftSDK Windows) \usr\lib\swift\windows" - Filter " *.lib" - File - ErrorAction Ignore | ForEach-Object {
3724+ Write-Host - BackgroundColor DarkRed - ForegroundColor White " $ ( $_.FullName ) is not nested in an architecture directory"
3725+ Move-Item $_.FullName " $ ( Get-SwiftSDK Windows) \usr\lib\swift\windows\$ ( $Build .Architecture.LLVMName ) \" | Out-Null
3726+ }
37223727
3723- Copy-Directory " $ ( Get-SwiftSDK Windows) \usr\bin" " $ ( [IO.Path ]::Combine((Get-InstallDir $Platform ), " Runtimes" , $ProductVersion , " usr" )) "
3728+ # FIXME(compnerd) how do we select which SDK is meant to be re-distributed?
3729+ Copy-Directory " $ ( Get-SwiftSDK Windows) \usr\bin" " $ ( [IO.Path ]::Combine((Get-InstallDir $Build ), " Runtimes" , $ProductVersion , " usr" )) "
3730+ }
3731+
3732+ Install-SDK $WindowsSDKBuilds
3733+ Write-SDKSettings Windows
3734+ }
37243735
3725- Invoke-BuildStep Build-ExperimentalSDK $Platform
3736+ WindowsExperimental {
3737+ foreach ($Build in $WindowsSDKBuilds ) {
3738+ Invoke-BuildStep Build-ExperimentalSDK $Build
37263739
3727- Get-ChildItem " $ ( Get-SwiftSDK Windows - Identifier WindowsExperimental) \usr\lib\swift_static\windows" - Filter " *.lib" - File - ErrorAction Ignore | ForEach-Object {
3728- Write-Host - BackgroundColor DarkRed - ForegroundColor White " $ ( $_.FullName ) is not nested in an architecture directory"
3729- Move-Item $_.FullName " $ ( Get-SwiftSDK Windows - Identifier WindowsExperimental) \usr\lib\swift_static\windows\$ ( $Platform.Architecture.LLVMName ) \" | Out-Null
3740+ Get-ChildItem " $ ( Get-SwiftSDK Windows - Identifier WindowsExperimental) \usr\lib\swift_static\windows" - Filter " *.lib" - File - ErrorAction Ignore | ForEach-Object {
3741+ Write-Host - BackgroundColor DarkRed - ForegroundColor White " $ ( $_.FullName ) is not nested in an architecture directory"
3742+ Move-Item $_.FullName " $ ( Get-SwiftSDK Windows - Identifier WindowsExperimental) \usr\lib\swift_static\windows\$ ( $Build.Architecture.LLVMName ) \" | Out-Null
3743+ }
3744+ }
3745+
3746+ Install-SDK $WindowsSDKBuilds - Identifier WindowsExperimental
3747+ Write-SDKSettings Windows - Identifier WindowsExperimental
3748+ }
37303749 }
37313750 }
37323751
37333752 Write-PlatformInfoPlist Windows
3734- Install-SDK $WindowsSDKPlatforms
3735- Write-SDKSettings Windows
3736- Install-SDK $WindowsSDKPlatforms - Identifier WindowsExperimental
3737- Write-SDKSettings Windows - Identifier WindowsExperimental
37383753
37393754 if ($Android ) {
3740- foreach ($Platform in $AndroidSDKPlatforms ) {
3741- Invoke-BuildStep Build-SDK $Platform
3755+ foreach ($SDK in $AndroidSDKVersions ) {
3756+ switch ($SDK ) {
3757+ Android {
3758+ foreach ($Build in $AndroidSDKBuilds ) {
3759+ Invoke-BuildStep Build-SDK $Build
3760+
3761+ Get-ChildItem " $ ( Get-SwiftSDK Android) \usr\lib\swift\android" - File | Where-Object { $_.Name -match " .a$|.so$" } | ForEach-Object {
3762+ Write-Host - BackgroundColor DarkRed - ForegroundColor White " $ ( $_.FullName ) is not nested in an architecture directory"
3763+ Move-Item $_.FullName " $ ( Get-SwiftSDK Android) \usr\lib\swift\android\$ ( $Build.Architecture.LLVMName ) \" | Out-Null
3764+ }
3765+ }
37423766
3743- Get-ChildItem " $ ( Get-SwiftSDK Android) \usr\lib\swift\android" - File | Where-Object { $_.Name -match " .a$|.so$" } | ForEach-Object {
3744- Write-Host - BackgroundColor DarkRed - ForegroundColor White " $ ( $_.FullName ) is not nested in an architecture directory"
3745- Move-Item $_.FullName " $ ( Get-SwiftSDK Android) \usr\lib\swift\android\$ ( $Platform.Architecture.LLVMName ) \" | Out-Null
3746- }
3767+ Install-SDK $AndroidSDKBuilds
3768+ Write-SDKSettings Android
3769+ }
3770+
3771+ AndroidExperimental {
3772+ foreach ($Build in $AndroidSDKBuilds ) {
3773+ Invoke-BuildStep Build-ExperimentalSDK $Build
37473774
3748- Invoke-BuildStep Build-ExperimentalSDK $Platform
3775+ Get-ChildItem " $ ( Get-SwiftSDK Android - Identifier AndroidExperimental) \usr\lib\swift_static\android" - File | Where-Object { $_.Name -match " .a$|.so$" } | ForEach-Object {
3776+ Write-Host - BackgroundColor DarkRed - ForegroundColor White " $ ( $_.FullName ) is not nested in an architecture directory"
3777+ Move-Item $_.FullName " $ ( Get-SwiftSDK Android - Identifier AndroidExperimental) \usr\lib\swift_static\android\$ ( $Build.Architecture.LLVMName ) \" | Out-Null
3778+ }
3779+ }
37493780
3750- Get-ChildItem " $ ( Get-SwiftSDK Android - Identifier AndroidExperimental ) \usr\lib\swift_static\android " - File | Where-Object { $_ .Name -match " .a$|.so$ " } | ForEach-Object {
3751- Write-Host - BackgroundColor DarkRed - ForegroundColor White " $ ( $_ .FullName ) is not nested in an architecture directory "
3752- Move-Item $_ .FullName " $ ( Get-SwiftSDK Android - Identifier AndroidExperimental ) \usr\lib\swift_static\android\ $ ( $Platform .Architecture.LLVMName ) \ " | Out-Null
3781+ Install-SDK $AndroidSDKBuilds - Identifiers AndroidExperimental
3782+ Write-SDKSettings Android - Identifier AndroidExperimental
3783+ }
37533784 }
37543785 }
37553786
37563787 Write-PlatformInfoPlist Android
3757- Install-SDK $AndroidSDKPlatforms
3758- Write-SDKSettings Android
3759- Install-SDK $AndroidSDKPlatforms - Identifiers AndroidExperimental
3760- Write-SDKSettings Android - Identifier AndroidExperimental
37613788
37623789 # Android swift-inspect only supports 64-bit platforms.
3763- $AndroidSDKPlatforms | Where-Object { @ (" arm64-v8a" , " x86_64" ) -contains $_.Architecture.ABI } | ForEach-Object {
3790+ $AndroidSDKBuilds | Where-Object { @ (" arm64-v8a" , " x86_64" ) -contains $_.Architecture.ABI } | ForEach-Object {
37643791 Invoke-BuildStep Build-Inspect $_
37653792 }
37663793 }
@@ -3837,10 +3864,11 @@ if (-not $IsCrossCompiling) {
38373864 if ($Test -contains " sourcekit-lsp" ) { Invoke-BuildStep Test-SourceKitLSP $BuildPlatform }
38383865
38393866 if ($Test -contains " swift" ) {
3840- foreach ($Platform in $AndroidSDKPlatforms ) {
3867+ foreach ($Build in $AndroidSDKBuilds ) {
38413868 try {
3842- Invoke-BuildStep Test-Runtime $Platform
3843- } catch {}
3869+ Invoke-BuildStep Test-Runtime $Build
3870+ } catch {
3871+ }
38443872 }
38453873 }
38463874}
0 commit comments