Skip to content

Commit 71d1663

Browse files
metin-armmarcbonnici
authored andcommitted
tools/android: Address review comments on PR#668
PR#668: #668 - Fix mixed tab-space white-spacing issues - s/CMDLINE_VERSION/ANDROID_CMDLINE_VERSION/ to be more precise - s/set_host_arch/get_android_sdk_host_arch/ because the global variable for Android host architecture is removed now Signed-off-by: Metin Kaya <metin.kaya@arm.com>
1 parent 492d42d commit 71d1663

File tree

2 files changed

+28
-26
lines changed

2 files changed

+28
-26
lines changed

tools/android/install_base.sh

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,21 @@ test_os_release() {
3737

3838
if [[ "$(read_os_release "${field_name}")" == "${value}" ]]; then
3939
return 0
40-
else
41-
return 1
4240
fi
41+
return 1
4342
}
4443

45-
function set_host_arch
46-
{
47-
# Google ABI type for Arm platforms
48-
HOST_ARCH="arm64-v8a"
44+
get_android_sdk_host_arch() {
45+
# Default to Google ABI type for Arm platforms
46+
local arch="arm64-v8a"
47+
local machine
48+
49+
machine=$(uname -m)
50+
if [[ "${machine}" == "x86"* ]]; then
51+
arch=${machine}
52+
fi
4953

50-
local machine
51-
machine=$(uname -m)
52-
if [[ "${machine}" == "x86"* ]]; then
53-
HOST_ARCH=${machine}
54-
fi
54+
echo "${arch}"
5555
}
5656

5757
ANDROID_HOME="$(dirname "${0}")/android-sdk-linux"
@@ -60,7 +60,7 @@ export ANDROID_USER_HOME="${ANDROID_HOME}/.android"
6060

6161
mkdir -p "${ANDROID_HOME}/cmdline-tools"
6262

63-
CMDLINE_VERSION=${CMDLINE_VERSION:-"11076708"}
63+
ANDROID_CMDLINE_VERSION=${ANDROID_CMDLINE_VERSION:-"11076708"}
6464

6565
cleanup_android_home() {
6666
echo "Cleaning up Android SDK: ${ANDROID_HOME}"
@@ -72,7 +72,7 @@ install_android_sdk_manager() {
7272
echo "Installing Android SDK manager ..."
7373

7474
# URL taken from "Command line tools only": https://developer.android.com/studio
75-
local url="https://dl.google.com/android/repository/commandlinetools-linux-${CMDLINE_VERSION}_latest.zip"
75+
local url="https://dl.google.com/android/repository/commandlinetools-linux-${ANDROID_CMDLINE_VERSION}_latest.zip"
7676

7777
echo "Downloading Android SDK manager from: $url"
7878
wget -qO- "${url}" | bsdtar -xf- -C "${ANDROID_HOME}/cmdline-tools"
@@ -117,29 +117,34 @@ call_android_avdmanager() {
117117

118118
# Needs install_android_sdk_manager first
119119
install_android_tools() {
120+
local android_sdk_host_arch
121+
android_sdk_host_arch=$(get_android_sdk_host_arch)
122+
120123
yes | call_android_sdkmanager --verbose --channel=0 --install "platform-tools"
121124
yes | call_android_sdkmanager --verbose --channel=0 --install "platforms;android-31"
122125
yes | call_android_sdkmanager --verbose --channel=0 --install "platforms;android-33"
123126
yes | call_android_sdkmanager --verbose --channel=0 --install "platforms;android-34"
124-
yes | call_android_sdkmanager --verbose --channel=0 --install "system-images;android-31;google_apis;${HOST_ARCH}"
125-
yes | call_android_sdkmanager --verbose --channel=0 --install "system-images;android-33;android-desktop;${HOST_ARCH}"
126-
yes | call_android_sdkmanager --verbose --channel=0 --install "system-images;android-34;google_apis;${HOST_ARCH}"
127+
yes | call_android_sdkmanager --verbose --channel=0 --install "system-images;android-31;google_apis;${android_sdk_host_arch}"
128+
yes | call_android_sdkmanager --verbose --channel=0 --install "system-images;android-33;android-desktop;${android_sdk_host_arch}"
129+
yes | call_android_sdkmanager --verbose --channel=0 --install "system-images;android-34;google_apis;${android_sdk_host_arch}"
127130
}
128131

129132
create_android_vds() {
130-
local vd_name
133+
local android_sdk_host_arch
134+
android_sdk_host_arch=$(get_android_sdk_host_arch)
131135

136+
local vd_name
132137
vd_name="devlib-p6-12"
133138
echo "Creating virtual device \"${vd_name}\" (Pixel 6 - Android 12)..."
134-
echo no | call_android_avdmanager -s create avd -n "${vd_name}" -k "system-images;android-31;google_apis;${HOST_ARCH}" --skin pixel_6 -b "${HOST_ARCH}" -f
139+
echo no | call_android_avdmanager -s create avd -n "${vd_name}" -k "system-images;android-31;google_apis;${android_sdk_host_arch}" --skin pixel_6 -b "${android_sdk_host_arch}" -f
135140

136141
vd_name="devlib-p6-14"
137142
echo "Creating virtual device \"${vd_name}\" (Pixel 6 - Android 14)..."
138-
echo no | call_android_avdmanager -s create avd -n "${vd_name}" -k "system-images;android-34;google_apis;${HOST_ARCH}" --skin pixel_6 -b "${HOST_ARCH}" -f
143+
echo no | call_android_avdmanager -s create avd -n "${vd_name}" -k "system-images;android-34;google_apis;${android_sdk_host_arch}" --skin pixel_6 -b "${android_sdk_host_arch}" -f
139144

140145
vd_name="devlib-chromeos"
141146
echo "Creating virtual device \"${vd_name}\" (ChromeOS - Android 13, Pixel tablet)..."
142-
echo no | call_android_avdmanager -s create avd -n "${vd_name}" -k "system-images;android-33;android-desktop;${HOST_ARCH}" --skin pixel_tablet -b "${HOST_ARCH}" -f
147+
echo no | call_android_avdmanager -s create avd -n "${vd_name}" -k "system-images;android-33;android-desktop;${android_sdk_host_arch}" --skin pixel_tablet -b "${android_sdk_host_arch}" -f
143148
}
144149

145150
install_apt() {
@@ -183,7 +188,6 @@ if which apt-get &>/dev/null; then
183188
install_functions+=(install_apt)
184189
package_manager='apt-get'
185190
expected_distro="Ubuntu"
186-
187191
elif which pacman &>/dev/null; then
188192
install_functions+=(install_pacman)
189193
package_manager="pacman"
@@ -223,8 +227,6 @@ else
223227
args=("$@")
224228
fi
225229

226-
set_host_arch
227-
228230
# Use conditional fall-through ;;& to all matching all branches with
229231
# --install-all
230232
for arg in "${args[@]}"; do

tools/docker/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ RUN cd /devlib && \
6363
pip install --upgrade pip setuptools wheel && \
6464
pip install .[full]
6565

66-
# Set CMDLINE_VERSION environment variable if you want to use a specific
67-
# version of Android command line tools rather than default which is
68-
# ``11076708`` as of writing this comment.
66+
# Set ANDROID_CMDLINE_VERSION environment variable if you want to use a
67+
# specific version of Android command line tools rather than default
68+
# which is ``11076708`` as of writing this comment.
6969
RUN cd /devlib/tools/android && ./install_base.sh
7070

7171
# Set BUILDROOT_VERSION environment variable if you want to use a specific

0 commit comments

Comments
 (0)