Skip to content

Commit 4cfd5f1

Browse files
committed
[android] only build android SDKs when -Android is passed, or -AndroidSDKs are specified when running build.ps1
1 parent c032c9b commit 4cfd5f1

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

utils/build.ps1

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ The debug information format for Swift code: dwarf or codeview.
3535
.PARAMETER AndroidAPILevel
3636
The API Level to target when building the Android SDKs
3737
38+
.PARAMETER Android
39+
When set, build android SDKs.
40+
3841
.PARAMETER AndroidSDKs
3942
An array of architectures for which the Android Swift SDK should be built.
4043
@@ -106,14 +109,15 @@ param(
106109
[string] $CDebugFormat = "dwarf",
107110
[string] $SwiftDebugFormat = "dwarf",
108111
[string] $AndroidAPILevel = 28,
109-
[string[]] $AndroidSDKs = @("aarch64","armv7","i686","x86_64"),
112+
[string[]] $AndroidSDKs = @(),
110113
[string[]] $WindowsSDKs = @("X64","X86","Arm64"),
111114
[string] $ProductVersion = "0.0.0",
112115
[string] $PinnedBuild = "",
113116
[string] $PinnedSHA256 = "",
114117
[string] $PythonVersion = "3.9.10",
115118
[string] $AndroidNDKVersion = "r26b",
116119
[string] $WinSDKVersion = "",
120+
[switch] $Android = $false,
117121
[switch] $SkipBuild = $false,
118122
[switch] $SkipRedistInstall = $false,
119123
[switch] $SkipPackaging = $false,
@@ -177,11 +181,20 @@ if (-not (Test-Path $python)) {
177181
}
178182
}
179183

184+
if ($Android -and ($AndroidSDKs.Length -eq 0)) {
185+
# Enable all android SDKs by default.
186+
$AndroidSDKs = @("aarch64","armv7","i686","x86_64")
187+
}
180188
# Work around limitations of cmd passing in array arguments via powershell.exe -File
181189
if ($AndroidSDKs.Length -eq 1) { $AndroidSDKs = $AndroidSDKs[0].Split(",") }
182190
if ($WindowsSDKs.Length -eq 1) { $WindowsSDKs = $WindowsSDKs[0].Split(",") }
183191
if ($Test.Length -eq 1) { $Test = $Test[0].Split(",") }
184192

193+
if ($AndroidSDKs.Length -gt 0) {
194+
# Always enable android when one of the SDKs is specified.
195+
$Android = $true
196+
}
197+
185198
if ($Test -contains "*") {
186199
# Explicitly don't include llbuild yet since tests are known to fail on Windows
187200
$Test = @("swift", "dispatch", "foundation", "xctest")
@@ -344,7 +357,7 @@ $AndroidSDKArchs = @($AndroidSDKs | ForEach-Object {
344357
default { throw "Unknown architecture $_" }
345358
}
346359
})
347-
if ($AndroidSDKArchs.count -gt 0) {
360+
if ($Android) {
348361
if ($HostArch -ne $ArchX64) {
349362
throw "Unsupported host architecture for building android SDKs"
350363
}
@@ -666,7 +679,7 @@ function Fetch-Dependencies {
666679
Download-Python $BuildArchName
667680
}
668681

669-
if ($AndroidSDKArchs.count -gt 0) {
682+
if ($Android) {
670683
# Only a specific NDK version is supported right now.
671684
if ($AndroidNDKVersion -ne "r26b") {
672685
throw "Unsupported Android NDK version"

0 commit comments

Comments
 (0)