@@ -38,10 +38,16 @@ The API Level to target when building the Android SDKs
38
38
. PARAMETER Android
39
39
When set, build android SDKs.
40
40
41
- . PARAMETER AndroidSDKs
41
+ . PARAMETER AndroidSDKVersions
42
+ An array of SDKs to build for the Android OS.
43
+
44
+ . PARAMETER AndroidSDKArchitectures
42
45
An array of architectures for which the Android Swift SDK should be built.
43
46
44
- . PARAMETER WindowsSDKs
47
+ . PARAMETER WindowsSDKVersions
48
+ An array of SDKs to build for the Windows OS.
49
+
50
+ . PARAMETER WindowsSDKArchitectures
45
51
An array of architectures for which the Windows Swift SDK should be built.
46
52
47
53
. PARAMETER ProductVersion
@@ -106,7 +112,7 @@ Whether to run swift-foundation and swift-corelibs-foundation tests in a debug o
106
112
PS> .\Build.ps1
107
113
108
114
. 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
110
116
#>
111
117
[CmdletBinding (PositionalBinding = $false )]
112
118
param
@@ -120,8 +126,10 @@ param
120
126
[string ] $SwiftDebugFormat = " dwarf" ,
121
127
[ValidateRange (1 , 36 )]
122
128
[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" ),
125
133
[string ] $ProductVersion = " 0.0.0" ,
126
134
[string ] $ToolchainIdentifier = $ (if ($env: TOOLCHAIN_VERSION ) { $env: TOOLCHAIN_VERSION } else { " $env: USERNAME .development" }),
127
135
[string ] $PinnedBuild = " " ,
@@ -182,20 +190,14 @@ if (($PinnedBuild -or $PinnedSHA256 -or $PinnedVersion) -and -not ($PinnedBuild
182
190
throw " If any of PinnedBuild, PinnedSHA256, or PinnedVersion is set, all three must be set."
183
191
}
184
192
185
- if ($Android -and ($AndroidSDKs.Length -eq 0 )) {
186
- # Enable all android SDKs by default.
187
- $AndroidSDKs = @ (" aarch64" , " armv7" , " i686" , " x86_64" )
188
- }
189
-
190
193
# 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(" ," ) }
194
196
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( " , " ) }
199
201
200
202
if ($Test -contains " *" ) {
201
203
# 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"])) {
492
494
}
493
495
494
496
# Resolve the architectures received as argument
495
- $AndroidSDKPlatforms = @ ($AndroidSDKs | ForEach-Object {
497
+ $AndroidSDKBuilds = @ ($AndroidSDKArchitectures | ForEach-Object {
496
498
switch ($_ ) {
497
499
" aarch64" { $KnownPlatforms [" AndroidARM64" ] }
498
500
" armv7" { $KnownPlatforms [" AndroidARMv7" ] }
@@ -502,7 +504,7 @@ $AndroidSDKPlatforms = @($AndroidSDKs | ForEach-Object {
502
504
}
503
505
})
504
506
505
- $WindowsSDKPlatforms = @ ($WindowsSDKs | ForEach-Object {
507
+ $WindowsSDKBuilds = @ ($WindowsSDKArchitectures | ForEach-Object {
506
508
switch ($_ ) {
507
509
" X64" { $KnownPlatforms [" WindowsX64" ] }
508
510
" X86" { $KnownPlatforms [" WindowsX86" ] }
@@ -1189,14 +1191,14 @@ function Get-Dependencies {
1189
1191
$script :CustomWinSDKRoot = " $NugetRoot \$Package .$WinSDKVersion \c"
1190
1192
1191
1193
# 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
1195
1197
}
1196
1198
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 "
1200
1202
}
1201
1203
}
1202
1204
}
@@ -2710,13 +2712,13 @@ function Write-SDKSettings([OS] $OS, [string] $Identifier = $OS.ToString()) {
2710
2712
$SDKSettings.SupportedTargets.windows.LLVMTargetVendor = " unknown"
2711
2713
$SDKSettings.SupportedTargets.windows.LLVMTargetSys = " windows"
2712
2714
$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
2714
2716
}
2715
2717
Android {
2716
2718
$SDKSettings.SupportedTargets.android.LLVMTargetVendor = " unknown"
2717
2719
$SDKSettings.SupportedTargets.android.LLVMTargetSys = " linux"
2718
2720
$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
2720
2722
}
2721
2723
}
2722
2724
$SDKSettings | ConvertTo-JSON - Depth 4 | Out-FIle - FilePath " $ ( Get-SwiftSDK $OS - Identifier $Identifier ) \SDKSettings.json"
@@ -3613,11 +3615,11 @@ function Build-Installer([Hashtable] $Platform) {
3613
3615
}
3614
3616
3615
3617
$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 " ;" ) `" "
3618
3620
$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 " );
3621
3623
}
3622
3624
3623
3625
Build-WiXProject bundle\installer.wixproj - Platform $Platform - Bundle - Properties $Properties
@@ -3626,8 +3628,8 @@ function Build-Installer([Hashtable] $Platform) {
3626
3628
function Copy-BuildArtifactsToStage ([Hashtable ] $Platform ) {
3627
3629
Copy-File " $BinaryCache \$ ( $Platform.Triple ) \installer\Release\$ ( $Platform.Architecture.VSName ) \*.cab" $Stage
3628
3630
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
3631
3633
}
3632
3634
Copy-File " $BinaryCache \$ ( $Platform.Triple ) \installer\Release\$ ( $Platform.Architecture.VSName ) \installer.exe" $Stage
3633
3635
# Extract installer engine to ease code-signing on swift.org CI
@@ -3678,11 +3680,11 @@ Get-Dependencies
3678
3680
if ($Clean ) {
3679
3681
Remove-Item - Force - Recurse - Path " $BinaryCache \$ ( $BuildPlatform.Triple ) \" - ErrorAction Ignore
3680
3682
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
3683
3685
}
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
3686
3688
}
3687
3689
Remove-Item - Force - Recurse - Path " $BinaryCache \1" - ErrorAction Ignore
3688
3690
Remove-Item - Force - Recurse - Path " $BinaryCache \5" - ErrorAction Ignore
@@ -3712,55 +3714,80 @@ if (-not $SkipBuild) {
3712
3714
3713
3715
Invoke-BuildStep Build-SDK $BuildPlatform - IncludeMacros
3714
3716
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
3717
3722
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
+ }
3722
3727
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
+ }
3724
3735
3725
- Invoke-BuildStep Build-ExperimentalSDK $Platform
3736
+ WindowsExperimental {
3737
+ foreach ($Build in $WindowsSDKBuilds ) {
3738
+ Invoke-BuildStep Build-ExperimentalSDK $Build
3726
3739
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
+ }
3730
3749
}
3731
3750
}
3732
3751
3733
3752
Write-PlatformInfoPlist Windows
3734
- Install-SDK $WindowsSDKPlatforms
3735
- Write-SDKSettings Windows
3736
- Install-SDK $WindowsSDKPlatforms - Identifier WindowsExperimental
3737
- Write-SDKSettings Windows - Identifier WindowsExperimental
3738
3753
3739
3754
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
+ }
3742
3766
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
3747
3774
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
+ }
3749
3780
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
+ }
3753
3784
}
3754
3785
}
3755
3786
3756
3787
Write-PlatformInfoPlist Android
3757
- Install-SDK $AndroidSDKPlatforms
3758
- Write-SDKSettings Android
3759
- Install-SDK $AndroidSDKPlatforms - Identifiers AndroidExperimental
3760
- Write-SDKSettings Android - Identifier AndroidExperimental
3761
3788
3762
3789
# 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 {
3764
3791
Invoke-BuildStep Build-Inspect $_
3765
3792
}
3766
3793
}
@@ -3837,10 +3864,11 @@ if (-not $IsCrossCompiling) {
3837
3864
if ($Test -contains " sourcekit-lsp" ) { Invoke-BuildStep Test-SourceKitLSP $BuildPlatform }
3838
3865
3839
3866
if ($Test -contains " swift" ) {
3840
- foreach ($Platform in $AndroidSDKPlatforms ) {
3867
+ foreach ($Build in $AndroidSDKBuilds ) {
3841
3868
try {
3842
- Invoke-BuildStep Test-Runtime $Platform
3843
- } catch {}
3869
+ Invoke-BuildStep Test-Runtime $Build
3870
+ } catch {
3871
+ }
3844
3872
}
3845
3873
}
3846
3874
}
0 commit comments