Skip to content

Commit 612a586

Browse files
committed
Auto merge of #538 - malbarbo:ci-android, r=alexcrichton
Add and fix tests for {i686, aarch64}-linux-android targets I think that these changes do not breaks compatibility. There are some types and constants changes to i686 and aarch64, but I see these changes as bug fixes instead of breaking changes. Also the type time64_t was remove from aarch64 because it is not defined in this arch. Fixes #536
2 parents 331b179 + b2791db commit 612a586

File tree

21 files changed

+463
-200
lines changed

21 files changed

+463
-200
lines changed

.travis.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ matrix:
5151
- os: linux
5252
env: TARGET=arm-linux-androideabi
5353
rust: stable
54+
- os: linux
55+
env: TARGET=aarch64-linux-android
56+
rust: stable
57+
- os: linux
58+
env: TARGET=i686-linux-android
59+
rust: stable
5460
- os: linux
5561
env: TARGET=x86_64-unknown-linux-musl
5662
rust: stable

ci/docker/arm-linux-androideabi/install-ndk.sh renamed to ci/android-install-ndk.sh

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,24 @@ set -ex
1313

1414
curl -O https://dl.google.com/android/repository/android-ndk-r13b-linux-x86_64.zip
1515
unzip -q android-ndk-r13b-linux-x86_64.zip
16+
17+
case "$1" in
18+
aarch64)
19+
arch=arm64
20+
;;
21+
22+
i686)
23+
arch=x86
24+
;;
25+
26+
*)
27+
arch=$1
28+
;;
29+
esac;
30+
1631
android-ndk-r13b/build/tools/make_standalone_toolchain.py \
17-
--install-dir /android/ndk-arm \
18-
--arch arm \
32+
--install-dir /android/ndk-$1 \
33+
--arch $arch \
1934
--api 24
2035

2136
rm -rf ./android-ndk-r13b-linux-x86_64.zip ./android-ndk-r13b

ci/docker/arm-linux-androideabi/install-sdk.sh renamed to ci/android-install-sdk.sh

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,35 @@ set -ex
1919
# which apparently magically accepts the licenses.
2020

2121
mkdir sdk
22-
curl https://dl.google.com/android/android-sdk_r24.4.1-linux.tgz | \
23-
tar xzf - -C sdk --strip-components=1
22+
curl https://dl.google.com/android/repository/tools_r25.2.5-linux.zip -O
23+
unzip -d sdk tools_r25.2.5-linux.zip
2424

25-
filter="platform-tools,android-21"
26-
filter="$filter,sys-img-armeabi-v7a-android-21"
25+
filter="platform-tools,android-24"
2726

28-
./accept-licenses.sh "android - update sdk -a --no-ui --filter $filter"
27+
case "$1" in
28+
arm | armv7)
29+
abi=armeabi-v7a
30+
;;
31+
32+
aarch64)
33+
abi=arm64-v8a
34+
;;
35+
36+
i686)
37+
abi=x86
38+
;;
39+
40+
*)
41+
echo "invalid arch: $1"
42+
exit 1
43+
;;
44+
esac;
45+
46+
filter="$filter,sys-img-$abi-android-24"
47+
48+
./android-accept-licenses.sh "android - update sdk -a --no-ui --filter $filter"
2949

3050
echo "no" | android create avd \
31-
--name arm-21 \
32-
--target android-21 \
33-
--abi armeabi-v7a
51+
--name $1 \
52+
--target android-24 \
53+
--abi $abi
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
FROM ubuntu:16.04
2+
3+
RUN dpkg --add-architecture i386 && \
4+
apt-get update && \
5+
apt-get install -y --no-install-recommends \
6+
file \
7+
curl \
8+
ca-certificates \
9+
python \
10+
unzip \
11+
expect \
12+
openjdk-9-jre \
13+
libstdc++6:i386 \
14+
libpulse0 \
15+
gcc \
16+
libc6-dev
17+
18+
WORKDIR /android/
19+
COPY android* /android/
20+
21+
ENV ANDROID_ARCH=aarch64
22+
ENV PATH=$PATH:/android/ndk-$ANDROID_ARCH/bin:/android/sdk/tools:/android/sdk/platform-tools
23+
24+
RUN sh /android/android-install-ndk.sh $ANDROID_ARCH
25+
RUN sh /android/android-install-sdk.sh $ANDROID_ARCH
26+
RUN mv /root/.android /tmp
27+
RUN chmod 777 -R /tmp/.android
28+
RUN chmod 755 /android/sdk/tools/* /android/sdk/tools/qemu/linux-x86_64/*
29+
30+
ENV PATH=$PATH:/rust/bin \
31+
CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER=aarch64-linux-android-gcc \
32+
HOME=/tmp

ci/docker/arm-linux-androideabi/Dockerfile

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,22 @@ RUN dpkg --add-architecture i386 && \
1111
expect \
1212
openjdk-9-jre \
1313
libstdc++6:i386 \
14+
libpulse0 \
1415
gcc \
1516
libc6-dev
1617

1718
WORKDIR /android/
19+
COPY android* /android/
1820

19-
COPY install-ndk.sh /android/
20-
RUN sh /android/install-ndk.sh
21+
ENV ANDROID_ARCH=arm
22+
ENV PATH=$PATH:/android/ndk-$ANDROID_ARCH/bin:/android/sdk/tools:/android/sdk/platform-tools
2123

22-
ENV PATH=$PATH:/android/ndk-arm/bin:/android/sdk/tools:/android/sdk/platform-tools
23-
24-
COPY install-sdk.sh accept-licenses.sh /android/
25-
RUN sh /android/install-sdk.sh
24+
RUN sh /android/android-install-ndk.sh $ANDROID_ARCH
25+
RUN sh /android/android-install-sdk.sh $ANDROID_ARCH
26+
RUN mv /root/.android /tmp
27+
RUN chmod 777 -R /tmp/.android
28+
RUN chmod 755 /android/sdk/tools/* /android/sdk/tools/qemu/linux-x86_64/*
2629

2730
ENV PATH=$PATH:/rust/bin \
2831
CARGO_TARGET_ARM_LINUX_ANDROIDEABI_LINKER=arm-linux-androideabi-gcc \
29-
ANDROID_EMULATOR_FORCE_32BIT=1 \
3032
HOME=/tmp
31-
RUN chmod 755 /android/sdk/tools/*
32-
33-
RUN cp -r /root/.android /tmp
34-
RUN chmod 777 -R /tmp/.android
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
FROM ubuntu:16.04
2+
3+
RUN dpkg --add-architecture i386 && \
4+
apt-get update && \
5+
apt-get install -y --no-install-recommends \
6+
file \
7+
curl \
8+
ca-certificates \
9+
python \
10+
unzip \
11+
expect \
12+
openjdk-9-jre \
13+
libstdc++6:i386 \
14+
libpulse0 \
15+
gcc \
16+
libc6-dev
17+
18+
WORKDIR /android/
19+
COPY android* /android/
20+
21+
ENV ANDROID_ARCH=i686
22+
ENV PATH=$PATH:/android/ndk-$ANDROID_ARCH/bin:/android/sdk/tools:/android/sdk/platform-tools
23+
24+
RUN sh /android/android-install-ndk.sh $ANDROID_ARCH
25+
RUN sh /android/android-install-sdk.sh $ANDROID_ARCH
26+
RUN mv /root/.android /tmp
27+
RUN chmod 777 -R /tmp/.android
28+
RUN chmod 755 /android/sdk/tools/* /android/sdk/tools/qemu/linux-x86_64/*
29+
30+
ENV PATH=$PATH:/rust/bin \
31+
CARGO_TARGET_I686_LINUX_ANDROID_LINKER=i686-linux-android-gcc \
32+
HOME=/tmp

ci/run-docker.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ set -ex
55

66
run() {
77
echo $1
8-
docker build -t libc ci/docker/$1
8+
# use -f so we can use ci/ as build context
9+
docker build -t libc -f ci/docker/$1/Dockerfile ci/
910
mkdir -p target
1011
docker run \
1112
--user `id -u`:`id -g` \

ci/run.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,16 @@ case "$TARGET" in
105105
esac
106106

107107
case "$TARGET" in
108-
arm-linux-androideabi)
109-
emulator @arm-21 -no-window &
108+
arm-linux-androideabi | aarch64-linux-android | i686-linux-android)
109+
# set SHELL so android can detect a 64bits system, see
110+
# http://stackoverflow.com/a/41789144
111+
# https://issues.jenkins-ci.org/browse/JENKINS-26930?focusedCommentId=230791&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-230791
112+
export SHELL=/bin/dash
113+
arch=$(echo $TARGET | cut -d- -f1)
114+
emulator @$arch -no-window -no-accel &
110115
adb wait-for-device
111-
adb push $CARGO_TARGET_DIR/$TARGET/debug/libc-test /data/libc-test
112-
adb shell /data/libc-test 2>&1 | tee /tmp/out
116+
adb push $CARGO_TARGET_DIR/$TARGET/debug/libc-test /data/local/tmp/libc-test
117+
adb shell /data/local/tmp/libc-test 2>&1 | tee /tmp/out
113118
grep "^PASSED .* tests" /tmp/out
114119
;;
115120

libc-test/build.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use std::env;
66

77
fn main() {
88
let target = env::var("TARGET").unwrap();
9+
let aarch64 = target.contains("aarch64");
910
let x86_64 = target.contains("x86_64");
1011
let windows = target.contains("windows");
1112
let mingw = target.contains("windows-gnu");
@@ -105,8 +106,12 @@ fn main() {
105106
}
106107

107108
if android {
109+
if !aarch64 {
110+
// time64_t is not define for aarch64
111+
// If included it will generate the error 'Your time_t is already 64-bit'
112+
cfg.header("time64.h");
113+
}
108114
cfg.header("arpa/inet.h");
109-
cfg.header("time64.h");
110115
cfg.header("xlocale.h");
111116
cfg.header("utmp.h");
112117
} else if !windows {

0 commit comments

Comments
 (0)