Add docker file to build android image

This commit is contained in:
Alex Crichton 2015-09-12 11:22:42 -07:00
parent d2e41c10a4
commit 79199aff36
4 changed files with 95 additions and 0 deletions

64
Dockerfile Normal file
View file

@ -0,0 +1,64 @@
FROM ubuntu:latest
RUN mkdir /build
WORKDIR /build
# Setup PATH to allow running android tools.
ENV PATH=$PATH:/build/android-ndk/bin
ENV PATH=$PATH:/build/android-sdk-linux/tools
ENV PATH=$PATH:/build/android-sdk-linux/platform-tools
# So it looks like the default sdk gives us a 32-bit executable, but then it
# whines about it. Not sure how to download a 64-bit executable in the sdk so
# just let the 32-bit thing run for now.
ENV ANDROID_EMULATOR_FORCE_32BIT=true
# Install necessary packages:
RUN dpkg --add-architecture i386
RUN apt-get -y update
RUN apt-get -y install expect curl libncurses5:i386 libstdc++6:i386 zlib1g:i386 \
openjdk-6-jre gcc-multilib
# Prep the Android NDK
#
# See https://github.com/servo/servo/wiki/Building-for-Android
RUN curl -O http://dl.google.com/android/ndk/android-ndk-r9c-linux-x86_64.tar.bz2
RUN tar xf android-ndk-r9c-linux-x86_64.tar.bz2
RUN bash android-ndk-r9c/build/tools/make-standalone-toolchain.sh \
--platform=android-18 \
--toolchain=arm-linux-androideabi-4.8 \
--install-dir=/build/android-ndk \
--ndk-dir=/build/android-ndk-r9c \
--arch=arm
RUN rm -rf android-ndk-r9c-linux-x86_64.tar.bz2
RUN rm -rf android-ndk-r9c
# Prep the SDK and emulator
#
# Note that the update process requires that we accept a bunch of licenses, and
# we can't just pipe `yes` into it for some reason, so we take the same strategy
# located in https://github.com/appunite/docker by just wrapping it in a script
# which apparently magically accepts the licenses.
RUN curl -O http://dl.google.com/android/android-sdk_r24.3.4-linux.tgz
RUN tar xf android-sdk_r24.3.4-linux.tgz
COPY ci/android-accept-licenses.sh /build/android-accept-licenses.sh
RUN ["./android-accept-licenses.sh", \
"android - update sdk -a --no-ui --filter platform-tools,android-18,sys-img-armeabi-v7a-android-18"]
RUN echo "no" | android create avd \
--name test \
--target android-18 \
--abi armeabi-v7a
RUN rm -rf android-sdk_r24.3.4-linux.tgz
RUN rm android-accept-licenses.sh
# Install rustc + extra targets
RUN curl https://static.rust-lang.org/rustup.sh | \
sh -s -- --spec=nightly-2015-09-08 -y
RUN curl https://people.mozilla.org/~acrichton/libc-test/2015-09-08/arm-linux-androideabi.tar.gz | \
tar xzf - -C /usr/local/lib/rustlib
RUN mkdir /root/.cargo
COPY ci/cargo-config /root/.cargo/config
ENV CARGO_TARGET_DIR=/root/target
RUN mkdir /clone
WORKDIR /clone

14
ci/android-accept-licenses.sh Executable file
View file

@ -0,0 +1,14 @@
#!/usr/bin/expect -f
set timeout 1800
set cmd [lindex $argv 0]
set licenses [lindex $argv 1]
spawn {*}$cmd
expect {
"Do you accept the license '*'*" {
exp_send "y\r"
exp_continue
}
eof
}

2
ci/cargo-config Normal file
View file

@ -0,0 +1,2 @@
[target.arm-linux-androideabi]
linker = "arm-linux-androideabi-gcc"

15
ci/run.sh Normal file
View file

@ -0,0 +1,15 @@
#!/bin/sh
set -ex
TARGET=$1
cargo test --manifest-path libc-test/Cargo.toml --no-run --target $TARGET
if [ "$TARGET" = "arm-linux-androideabi" ]; then
emulator @test -no-window &
adb wait-for-device
adb push /root/target/$TARGET/debug/all-* /data/test
adb shell /data/test
else
cargo test --manifest-path libc-test/Cargo.toml --target $TARGET
fi