Skip to content

Commit f04671a

Browse files
authored
[xaprepare] Support arm64 emulator components (#7743)
Updates xaprepare to install arm64 versions of Android emulator components on Apple devices that support them. The `emulator` tool version has also been bumped from `31.3.1` to `32.1.9`.
1 parent 586e7e5 commit f04671a

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

Configuration.props

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
<HostOS Condition="$([MSBuild]::IsOSPlatform('windows'))">Windows</HostOS>
5555
<HostOS Condition="$([MSBuild]::IsOSPlatform('linux'))">Linux</HostOS>
5656
<HostOS Condition="$([MSBuild]::IsOSPlatform('osx'))">Darwin</HostOS>
57+
<HostOSArchitecture>$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture.ToString())</HostOSArchitecture>
5758
</PropertyGroup>
5859
<PropertyGroup>
5960
<MicrosoftAndroidSdkPackName Condition="$([MSBuild]::IsOSPlatform('windows'))">Microsoft.Android.Sdk.Windows</MicrosoftAndroidSdkPackName>
@@ -194,9 +195,9 @@
194195
<CommandLineToolsFolder Condition=" '$(CommandLineToolsFolder)' == '' ">7.0</CommandLineToolsFolder>
195196
<CommandLineToolsVersion Condition=" '$(CommandLineToolsVersion)' == '' ">8512546_latest</CommandLineToolsVersion>
196197
<CommandLineToolsBinPath Condition=" '$(CommandLineToolsBinPath)' == '' ">$(AndroidSdkFullPath)\cmdline-tools\$(CommandLineToolsFolder)\bin</CommandLineToolsBinPath>
197-
<!-- Version numbers and PkgVersion are found in https://dl-ssl.google.com/android/repository/repository2-1.xml -->
198-
<EmulatorVersion Condition=" '$(EmulatorVersion)' == '' ">8129060</EmulatorVersion>
199-
<EmulatorPkgRevision Condition=" '$(EmulatorPkgRevision)' == '' ">31.3.1</EmulatorPkgRevision>
198+
<!-- Version numbers and PkgVersion are found in https://dl-ssl.google.com/android/repository/repository2-3.xml -->
199+
<EmulatorVersion Condition=" '$(EmulatorVersion)' == '' ">9364964</EmulatorVersion>
200+
<EmulatorPkgRevision Condition=" '$(EmulatorPkgRevision)' == '' ">32.1.9</EmulatorPkgRevision>
200201
<EmulatorToolPath Condition=" '$(EmulatorToolPath)' == '' ">$(AndroidSdkFullPath)\emulator</EmulatorToolPath>
201202
<EmulatorToolExe Condition=" '$(EmulatorToolExe)' == '' ">emulator</EmulatorToolExe>
202203
<NdkBuildPath Condition=" '$(NdkBuildPath)' == '' And '$(HostOS)' != 'Windows' ">$(AndroidNdkDirectory)\ndk-build</NdkBuildPath>

build-tools/scripts/TestApks.targets

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
<PropertyGroup>
2020
<TestAvdApiLevel Condition=" '$(TestAvdApiLevel)' == '' ">29</TestAvdApiLevel>
21+
<TestAvdAbi Condition=" '$(TestAvdAbi)' == '' and '$(HostOS)' == 'Darwin' and '$(HostOSArchitecture)' == 'Arm64' ">arm64-v8a</TestAvdAbi>
2122
<TestAvdAbi Condition=" '$(TestAvdAbi)' == '' ">x86_64</TestAvdAbi>
2223
<TestAvdType Condition=" '$(TestAvdType)' == '' ">default</TestAvdType>
2324
<TestDeviceName Condition=" '$(TestDeviceName)' == '' ">pixel_4</TestDeviceName>

build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/AndroidToolchain.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.IO;
4+
using System.Runtime.InteropServices;
45

56
namespace Xamarin.Android.Prepare
67
{
@@ -30,10 +31,14 @@ public AndroidToolchain ()
3031
string XABuildTools30PackagePrefix = Context.Instance.Properties [KnownProperties.XABuildTools30PackagePrefix] ?? String.Empty;
3132
string XAPlatformToolsVersion = GetRequiredProperty (KnownProperties.XAPlatformToolsVersion);
3233
string XAPlatformToolsPackagePrefix = Context.Instance.Properties [KnownProperties.XAPlatformToolsPackagePrefix] ?? String.Empty;
34+
bool isArm64Apple = Context.Instance.OS.Flavor == "macOS" && RuntimeInformation.OSArchitecture == Architecture.Arm64;
35+
string emulatorArch = isArm64Apple ? "aarch64" : "x64";
36+
string systemImageArch = isArm64Apple ? "arm64-v8a" : "x86_64";
3337

3438
// Upstream manifests with version information:
3539
//
3640
// https://dl-ssl.google.com/android/repository/repository2-1.xml
41+
// https://dl-ssl.google.com/android/repository/repository2-3.xml
3742
// * platform APIs
3843
// * build-tools
3944
// * command-line tools
@@ -87,10 +92,10 @@ public AndroidToolchain ()
8792
dependencyType: AndroidToolchainComponentType.BuildDependency,
8893
buildToolVersion: "47.0.0"
8994
),
90-
new AndroidToolchainComponent ($"x86_64-29_r07-{osTag}",
91-
destDir: Path.Combine ("system-images", "android-29", "default", "x86_64"),
95+
new AndroidToolchainComponent (isArm64Apple ? $"{systemImageArch}-29_r08" : $"{systemImageArch}-29_r08-{osTag}",
96+
destDir: Path.Combine ("system-images", "android-29", "default", systemImageArch),
9297
relativeUrl: new Uri ("sys-img/android/", UriKind.Relative),
93-
pkgRevision: "7",
98+
pkgRevision: "8",
9499
dependencyType: AndroidToolchainComponentType.EmulatorDependency
95100
),
96101
new AndroidToolchainComponent ($"android-ndk-r{AndroidNdkVersion}-{osTag}",
@@ -123,7 +128,7 @@ public AndroidToolchain ()
123128
buildToolName: "android-sdk-platform-tools",
124129
buildToolVersion: XAPlatformToolsVersion
125130
),
126-
new AndroidToolchainComponent ($"emulator-{osTag}_x64-{EmulatorVersion}",
131+
new AndroidToolchainComponent ($"emulator-{osTag}_{emulatorArch}-{EmulatorVersion}",
127132
destDir: "emulator",
128133
pkgRevision: EmulatorPkgRevision,
129134
dependencyType: AndroidToolchainComponentType.EmulatorDependency

0 commit comments

Comments
 (0)