From ef2db470d9b9a7225ef79e73eda23d6671f55a72 Mon Sep 17 00:00:00 2001
From: Nikita Bykov <49442273+nikita-bykov@users.noreply.github.com>
Date: Mon, 20 Sep 2021 13:35:44 +0300
Subject: [PATCH] [Ubuntu] Add android NDK r23 (#4073)
---
.../SoftwareReport.Android.psm1 | 8 ++++++-
images/linux/scripts/installers/android.sh | 21 +++++++++--------
images/linux/scripts/tests/Android.Tests.ps1 | 23 +++++++++++--------
images/linux/toolsets/toolset-1804.json | 5 +++-
images/linux/toolsets/toolset-2004.json | 6 +++--
5 files changed, 40 insertions(+), 23 deletions(-)
diff --git a/images/linux/scripts/SoftwareReport/SoftwareReport.Android.psm1 b/images/linux/scripts/SoftwareReport/SoftwareReport.Android.psm1
index 3a0e6b2f2f48..5ba50848f40c 100644
--- a/images/linux/scripts/SoftwareReport/SoftwareReport.Android.psm1
+++ b/images/linux/scripts/SoftwareReport/SoftwareReport.Android.psm1
@@ -156,7 +156,13 @@ function Get-AndroidGoogleAPIsVersions {
function Get-AndroidNDKVersions {
$ndkFolderPath = Join-Path (Get-AndroidSDKRoot) "ndk"
$versions = Get-ChildItem -Path $ndkFolderPath -Name
- return ($versions -Join "
")
+ $ndkDefaultVersion = Get-ToolsetValue "android.ndk.default"
+ $ndkDefaultFullVersion = Get-ChildItem "$env:ANDROID_HOME/ndk/$ndkDefaultVersion.*" -Name | Select-Object -Last 1
+
+ return ($versions | ForEach-Object {
+ $defaultPostfix = ( $_ -eq $ndkDefaultFullVersion ) ? " (default)" : ""
+ $_ + $defaultPostfix
+ } | Join-String -Separator "
")
}
function Build-AndroidEnvironmentTable {
diff --git a/images/linux/scripts/installers/android.sh b/images/linux/scripts/installers/android.sh
index 7e0c547c04c4..957f1430df92 100644
--- a/images/linux/scripts/installers/android.sh
+++ b/images/linux/scripts/installers/android.sh
@@ -72,22 +72,25 @@ minimumPlatformVersion=$(get_toolset_value '.android.platform_min_version')
extras=$(get_toolset_value '.android.extra_list[]|"extras;" + .')
addons=$(get_toolset_value '.android.addon_list[]|"add-ons;" + .')
additional=$(get_toolset_value '.android.additional_tools[]')
-ANDROID_NDK_MAJOR_LTS=($(get_toolset_value '.android.ndk.lts'))
-ndkLTSFullVersion=$(get_full_ndk_version $ANDROID_NDK_MAJOR_LTS)
+ANDROID_NDK_MAJOR_VERSIONS=($(get_toolset_value '.android.ndk.versions[]'))
+ANDROID_NDK_MAJOR_DEFAULT=$(get_toolset_value '.android.ndk.default')
+ndkDefaultFullVersion=$(get_full_ndk_version $ANDROID_NDK_MAJOR_DEFAULT)
-components=("${extras[@]}" "${addons[@]}" "${additional[@]}" "ndk;$ndkLTSFullVersion")
-if isUbuntu20; then
- ANDROID_NDK_MAJOR_LATEST=($(get_toolset_value '.android.ndk.latest'))
- ndkLatestFullVersion=$(get_full_ndk_version $ANDROID_NDK_MAJOR_LATEST)
- components+=("ndk;$ndkLatestFullVersion")
-fi
+components=("${extras[@]}" "${addons[@]}" "${additional[@]}")
+for ndk_version in "${ANDROID_NDK_MAJOR_VERSIONS[@]}"
+do
+ ndk_full_version=$(get_full_ndk_version $ndk_version)
+ components+=("ndk;$ndk_full_version")
+done
# This changes were added due to incompatibility with android ndk-bundle (ndk;22.0.7026061).
# Link issue virtual-environments: https://github.com/actions/virtual-environments/issues/2481
# Link issue xamarin-android: https://github.com/xamarin/xamarin-android/issues/5526
-ln -s $ANDROID_SDK_ROOT/ndk/$ndkLTSFullVersion $ANDROID_NDK_ROOT
+ln -s $ANDROID_SDK_ROOT/ndk/$ndkDefaultFullVersion $ANDROID_NDK_ROOT
if isUbuntu20; then
+ ANDROID_NDK_MAJOR_LATEST=(${ANDROID_NDK_MAJOR_VERSIONS[-1]})
+ ndkLatestFullVersion=$(get_full_ndk_version $ANDROID_NDK_MAJOR_LATEST)
echo "ANDROID_NDK_LATEST_HOME=$ANDROID_SDK_ROOT/ndk/$ndkLatestFullVersion" | tee -a /etc/environment
fi
diff --git a/images/linux/scripts/tests/Android.Tests.ps1 b/images/linux/scripts/tests/Android.Tests.ps1
index 11b18d1221c7..cd103b931403 100644
--- a/images/linux/scripts/tests/Android.Tests.ps1
+++ b/images/linux/scripts/tests/Android.Tests.ps1
@@ -2,8 +2,10 @@ Describe "Android" {
$androidSdkManagerPackages = Get-AndroidPackages
[int]$platformMinVersion = Get-ToolsetValue "android.platform_min_version"
[version]$buildToolsMinVersion = Get-ToolsetValue "android.build_tools_min_version"
- [string]$ndkLTSVersion = Get-ToolsetValue "android.ndk.lts"
- $ndkLTSFullVersion = (Get-ChildItem "/usr/local/lib/android/sdk/ndk/$ndkLTSVersion.*" | Select-Object -Last 1).Name
+ [string]$ndkDefaultVersion = Get-ToolsetValue "android.ndk.default"
+ [array]$ndkVersions = Get-ToolsetValue "android.ndk.versions"
+ $ndkDefaultFullVersion = Get-ChildItem "$env:ANDROID_HOME/ndk/$ndkDefaultVersion.*" -Name | Select-Object -Last 1
+ $ndkFullVersions = $ndkVersions | ForEach-Object { (Get-ChildItem "/usr/local/lib/android/sdk/ndk/${_}.*" | Select-Object -Last 1).Name } | ForEach-Object { "ndk/${_}" }
$platformVersionsList = ($androidSdkManagerPackages | Where-Object { "$_".StartsWith("platforms;") }) -replace 'platforms;android-', ''
$platformNumericList = $platformVersionsList | Where-Object { $_ -match "\d+" } | Where-Object { [int]$_ -ge $platformMinVersion } | Sort-Object -Unique
@@ -17,18 +19,12 @@ Describe "Android" {
$androidPackages = @(
$platforms,
$buildTools,
+ $ndkFullVersions,
(Get-ToolsetValue "android.extra_list" | ForEach-Object { "extras/${_}" }),
(Get-ToolsetValue "android.addon_list" | ForEach-Object { "add-ons/${_}" }),
- (Get-ToolsetValue "android.additional_tools" | ForEach-Object { "${_}" }),
- "ndk/$ndkLTSFullVersion"
+ (Get-ToolsetValue "android.additional_tools" | ForEach-Object { "${_}" })
)
- [string]$ndkLatestVersion = Get-ToolsetValue "android.ndk.latest"
- if ($ndkLatestVersion) {
- $ndkLatestFullVersion = (Get-ChildItem "/usr/local/lib/android/sdk/ndk/$ndkLatestVersion.*" | Select-Object -Last 1).Name
- $androidPackages += @("ndk/$ndkLatestFullVersion")
- }
-
$androidPackages = $androidPackages | ForEach-Object { $_ }
BeforeAll {
@@ -67,10 +63,17 @@ Describe "Android" {
Context "Packages" {
$testCases = $androidPackages | ForEach-Object { @{ PackageName = $_ } }
+ $defaultNdkTestCase = @{ NdkDefaultFullVersion = $ndkDefaultFullVersion }
It "" -TestCases $testCases {
param ([string] $PackageName)
Validate-AndroidPackage $PackageName
}
+
+ It "ndk-bundle points to the default NDK version" -TestCases $defaultNdkTestCase {
+ $ndkLinkTarget = (Get-Item $env:ANDROID_NDK_HOME).Target
+ $ndkVersion = Split-Path -Path $ndkLinkTarget -Leaf
+ $ndkVersion | Should -BeExactly $NdkDefaultFullVersion
+ }
}
}
\ No newline at end of file
diff --git a/images/linux/toolsets/toolset-1804.json b/images/linux/toolsets/toolset-1804.json
index 8eea24062d76..85669e8290de 100644
--- a/images/linux/toolsets/toolset-1804.json
+++ b/images/linux/toolsets/toolset-1804.json
@@ -95,7 +95,10 @@
"cmake;3.18.1"
],
"ndk": {
- "lts": "21"
+ "default": "21",
+ "versions": [
+ "21", "23"
+ ]
}
},
"powershellModules": [
diff --git a/images/linux/toolsets/toolset-2004.json b/images/linux/toolsets/toolset-2004.json
index 0f6327b193d7..c3b1d519baa8 100644
--- a/images/linux/toolsets/toolset-2004.json
+++ b/images/linux/toolsets/toolset-2004.json
@@ -90,8 +90,10 @@
"cmake;3.18.1"
],
"ndk": {
- "lts": "21",
- "latest": "22"
+ "default": "21",
+ "versions": [
+ "21", "22", "23"
+ ]
}
},
"powershellModules": [