Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade Android SDK & NDK #1342

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 23 additions & 20 deletions ci/android-install-ndk.sh
Original file line number Diff line number Diff line change
@@ -1,38 +1,41 @@
#!/usr/bin/env sh
# Copyright 2016 The Rust Project Developers. See the COPYRIGHT
# file at the top-level directory of this distribution and at
# http://rust-lang.org/COPYRIGHT.
#
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
# option. This file may not be copied, modified, or distributed
# except according to those terms.

set -ex

curl --retry 5 -O \
https://dl.google.com/android/repository/android-ndk-r15b-linux-x86_64.zip
unzip -q android-ndk-r15b-linux-x86_64.zip
NDK=android-ndk-r21d
wget --tries=20 -q https://dl.google.com/android/repository/${NDK}-linux-x86_64.zip
unzip -q ${NDK}-linux-x86_64.zip

case "${1}" in
case "$1" in
arm)
arch=arm
api=28
;;
armv7)
arch=arm
api=28
;;
aarch64)
arch=arm64
api=28
;;

i686)
arch=x86
api=28
;;
x86_64)
arch=x86_64
api=28
;;

*)
arch="${1}"
echo "invalid arch: $1"
exit 1
;;
esac;

android-ndk-r15b/build/tools/make_standalone_toolchain.py \
--unified-headers \
python3 ${NDK}/build/tools/make_standalone_toolchain.py \
--install-dir "/android/ndk-${1}" \
--arch "${arch}" \
--api 24
--api ${api}

rm -rf ./android-ndk-r15b-linux-x86_64.zip ./android-ndk-r15b
rm -rf ./${NDK}-linux-x86_64.zip ./${NDK}
60 changes: 32 additions & 28 deletions ci/android-install-sdk.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
#!/usr/bin/env sh
# Copyright 2016 The Rust Project Developers. See the COPYRIGHT
# file at the top-level directory of this distribution and at
# http://rust-lang.org/COPYRIGHT.
#
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
# option. This file may not be copied, modified, or distributed
# except according to those terms.

set -ex

Expand All @@ -18,43 +9,56 @@ set -ex
# located in https://github.com/appunite/docker by just wrapping it in a script
# which apparently magically accepts the licenses.

mkdir sdk
curl --retry 5 https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip -O
unzip -d sdk sdk-tools-linux-4333796.zip
SDK=6609375
mkdir -p sdk/cmdline-tools
wget -q --tries=20 https://dl.google.com/android/repository/commandlinetools-linux-${SDK}_latest.zip
unzip -q -d sdk/cmdline-tools commandlinetools-linux-${SDK}_latest.zip

case "$1" in
arm | armv7)
abi=armeabi-v7a
api=24
image="system-images;android-${api};default;armeabi-v7a"
;;

aarch64)
abi=arm64-v8a
api=24
image="system-images;android-${api};google_apis;arm64-v8a"
;;

i686)
abi=x86
api=28
image="system-images;android-${api};default;x86"
;;

x86_64)
abi=x86_64
api=28
image="system-images;android-${api};default;x86_64"
;;

*)
echo "invalid arch: $1"
exit 1
;;
esac;

# Try to fix warning about missing file.
# See https://askubuntu.com/a/1078784
mkdir -p /root/.android/
echo '### User Sources for Android SDK Manager' >> /root/.android/repositories.cfg
echo '#Fri Nov 03 10:11:27 CET 2017 count=0' >> /root/.android/repositories.cfg

# Print all available packages
# yes | ./sdk/tools/bin/sdkmanager --list --verbose

# --no_https avoids
# javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: No trusted certificate found
yes | ./sdk/tools/bin/sdkmanager --licenses --no_https
yes | ./sdk/tools/bin/sdkmanager --no_https \
"emulator" \
"platform-tools" \
"platforms;android-24" \
"system-images;android-24;default;$abi"
#
# | grep -v = || true removes the progress bar output from the sdkmanager
# which produces an insane amount of output.
yes | ./sdk/cmdline-tools/tools/bin/sdkmanager --licenses --no_https | grep -v = || true
yes | ./sdk/cmdline-tools/tools/bin/sdkmanager --no_https \
"emulator" \
"platform-tools" \
"platforms;android-${api}" \
"${image}" | grep -v = || true

echo "no" |
./sdk/tools/bin/avdmanager create avd \
./sdk/cmdline-tools/tools/bin/avdmanager create avd \
--name "${1}" \
--package "system-images;android-24;default;$abi"
--package "${image}" | grep -v = || true
18 changes: 4 additions & 14 deletions ci/android-sysimage.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
#!/usr/bin/env bash

# Copyright 2017 The Rust Project Developers. See the COPYRIGHT
# file at the top-level directory of this distribution and at
# http://rust-lang.org/COPYRIGHT.
#
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
# option. This file may not be copied, modified, or distributed
# except according to those terms.

set -ex

URL=https://dl.google.com/android/repository/sys-img/android
Expand All @@ -23,13 +13,13 @@ main() {

apt-get install --no-install-recommends e2tools

pushd "$td"
curl --retry 5 -O "${URL}/${name}"
pushd "${td}"
wget -q --tries=5 "${URL}/${name}"
unzip -q "${name}"

local system
system=$(find . -name system.img)
mkdir -p $dest/{bin,lib,lib64}
system="$(find . -name system.img)"
mkdir -p ${dest}/{bin,lib,lib64}

# Extract android linker and libraries to /system
# This allows android executables to be run directly (or with qemu)
Expand Down
24 changes: 12 additions & 12 deletions ci/docker/aarch64-linux-android/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
FROM ubuntu:22.04

RUN apt-get update && \
apt-get install -y --no-install-recommends \
RUN dpkg --add-architecture i386
RUN apt-get update
RUN apt-get install -y --no-install-recommends libc6-dev gcc
RUN apt-get install -y --no-install-recommends \
file \
make \
curl \
wget \
ca-certificates \
python-is-python3 \
python3 \
python3-distutils \
unzip \
expect \
openjdk-8-jre \
libstdc++6-i386-cross \
libpulse0 \
gcc \
libc6-dev
libstdc++6:i386 \
libpulse0

WORKDIR /android/
COPY android* /android/

ENV ANDROID_ARCH=aarch64
ENV PATH=$PATH:/android/ndk-$ANDROID_ARCH/bin:/android/sdk/tools:/android/sdk/platform-tools
ENV PATH=$PATH:/android/ndk-$ANDROID_ARCH/bin:/android/sdk/cmdline-tools/tools:/android/sdk/platform-tools

RUN sh /android/android-install-ndk.sh $ANDROID_ARCH
RUN sh /android/android-install-sdk.sh $ANDROID_ARCH
RUN mv /root/.android /tmp
RUN chmod 777 -R /tmp/.android
RUN chmod 755 /android/sdk/tools/* /android/sdk/emulator/qemu/linux-x86_64/*
RUN chmod 755 /android/sdk/cmdline-tools/tools/* /android/sdk/emulator/qemu/linux-x86_64/*

ENV PATH=$PATH:/rust/bin \
CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER=aarch64-linux-android-gcc \
CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER=aarch64-linux-android28-clang \
CARGO_TARGET_AARCH64_LINUX_ANDROID_RUNNER=/tmp/runtest \
OBJDUMP=aarch64-linux-android-objdump \
HOME=/tmp
Expand Down
22 changes: 11 additions & 11 deletions ci/docker/arm-linux-androideabi/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
FROM ubuntu:22.04

RUN apt-get update && \
apt-get install -y --no-install-recommends \
RUN dpkg --add-architecture i386
RUN apt-get update
RUN apt-get install -y --no-install-recommends libc6-dev gcc
RUN apt-get install -y --no-install-recommends \
file \
make \
curl \
wget \
ca-certificates \
python-is-python3 \
python3 \
python3-distutils \
unzip \
expect \
openjdk-8-jre \
libstdc++6-i386-cross \
libpulse0 \
gcc \
libc6-dev
libstdc++6:i386 \
libpulse0

WORKDIR /android/
COPY android* /android/

ENV ANDROID_ARCH=arm
ENV PATH=$PATH:/android/ndk-$ANDROID_ARCH/bin:/android/sdk/tools:/android/sdk/platform-tools
ENV PATH=$PATH:/android/ndk-$ANDROID_ARCH/bin:/android/sdk/cmdline-tools/tools:/android/sdk/platform-tools

RUN sh /android/android-install-ndk.sh $ANDROID_ARCH
RUN sh /android/android-install-sdk.sh $ANDROID_ARCH
RUN mv /root/.android /tmp
RUN chmod 777 -R /tmp/.android
RUN chmod 755 /android/sdk/tools/* /android/sdk/emulator/qemu/linux-x86_64/*
RUN chmod 755 /android/sdk/cmdline-tools/tools/* /android/sdk/emulator/qemu/linux-x86_64/*

ENV PATH=$PATH:/rust/bin \
CARGO_TARGET_ARM_LINUX_ANDROIDEABI_LINKER=arm-linux-androideabi-gcc \
Expand Down
9 changes: 4 additions & 5 deletions ci/docker/x86_64-linux-android/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ FROM ubuntu:22.04
RUN apt-get update && \
apt-get install -y --no-install-recommends \
ca-certificates \
curl \
wget \
gcc \
libc-dev \
python-is-python3 \
unzip \
file \
make
python3 \
python3-distutils \
unzip

WORKDIR /android/
ENV ANDROID_ARCH=x86_64
Expand Down