Skip to content

Commit

Permalink
[Ubuntu] Add android NDK r23 (#4073)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikita-bykov authored Sep 20, 2021
1 parent bd5288c commit ef2db47
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 "<br>")
$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 "<br>")
}

function Build-AndroidEnvironmentTable {
Expand Down
21 changes: 12 additions & 9 deletions images/linux/scripts/installers/android.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
23 changes: 13 additions & 10 deletions images/linux/scripts/tests/Android.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down Expand Up @@ -67,10 +63,17 @@ Describe "Android" {

Context "Packages" {
$testCases = $androidPackages | ForEach-Object { @{ PackageName = $_ } }
$defaultNdkTestCase = @{ NdkDefaultFullVersion = $ndkDefaultFullVersion }

It "<PackageName>" -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
}
}
}
5 changes: 4 additions & 1 deletion images/linux/toolsets/toolset-1804.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@
"cmake;3.18.1"
],
"ndk": {
"lts": "21"
"default": "21",
"versions": [
"21", "23"
]
}
},
"powershellModules": [
Expand Down
6 changes: 4 additions & 2 deletions images/linux/toolsets/toolset-2004.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,10 @@
"cmake;3.18.1"
],
"ndk": {
"lts": "21",
"latest": "22"
"default": "21",
"versions": [
"21", "22", "23"
]
}
},
"powershellModules": [
Expand Down

0 comments on commit ef2db47

Please sign in to comment.