diff options
Diffstat (limited to 'libc/ci')
-rw-r--r-- | libc/ci/android-install-sdk.sh | 4 | ||||
-rw-r--r-- | libc/ci/android-sysimage.sh | 52 | ||||
-rw-r--r-- | libc/ci/docker/x86_64-linux-android/Dockerfile | 26 | ||||
-rw-r--r-- | libc/ci/run-docker.sh | 6 | ||||
-rwxr-xr-x | libc/ci/run.sh | 9 |
5 files changed, 94 insertions, 3 deletions
diff --git a/libc/ci/android-install-sdk.sh b/libc/ci/android-install-sdk.sh index 0762dcb..d03b762 100644 --- a/libc/ci/android-install-sdk.sh +++ b/libc/ci/android-install-sdk.sh @@ -37,6 +37,10 @@ case "$1" in abi=x86 ;; + x86_64) + abi=x86_64 + ;; + *) echo "invalid arch: $1" exit 1 diff --git a/libc/ci/android-sysimage.sh b/libc/ci/android-sysimage.sh new file mode 100644 index 0000000..9611dfe --- /dev/null +++ b/libc/ci/android-sysimage.sh @@ -0,0 +1,52 @@ +# 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 + +main() { + local arch=$1 + local name=$2 + local dest=/system + local td=$(mktemp -d) + + apt-get install --no-install-recommends e2tools + + pushd $td + curl -O $URL/$name + unzip -q $name + + local 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) + if [ $arch = "x86_64" -o $arch = "arm64" ]; then + e2cp -p $system:/bin/linker64 $dest/bin/ + e2cp -p $system:/lib64/libdl.so $dest/lib64/ + e2cp -p $system:/lib64/libc.so $dest/lib64/ + e2cp -p $system:/lib64/libm.so $dest/lib64/ + else + e2cp -p $system:/bin/linker $dest/bin/ + e2cp -p $system:/lib/libdl.so $dest/lib/ + e2cp -p $system:/lib/libc.so $dest/lib/ + e2cp -p $system:/lib/libm.so $dest/lib/ + fi + + # clean up + apt-get purge --auto-remove -y e2tools + + popd + + rm -rf $td +} + +main "${@}" diff --git a/libc/ci/docker/x86_64-linux-android/Dockerfile b/libc/ci/docker/x86_64-linux-android/Dockerfile new file mode 100644 index 0000000..dfc0c83 --- /dev/null +++ b/libc/ci/docker/x86_64-linux-android/Dockerfile @@ -0,0 +1,26 @@ +FROM ubuntu:16.04 + +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + ca-certificates \ + curl \ + gcc \ + libc-dev \ + python \ + unzip + +WORKDIR /android/ +ENV ANDROID_ARCH=x86_64 +COPY android-install-ndk.sh /android/ +RUN sh /android/android-install-ndk.sh $ANDROID_ARCH + +# We do not run x86_64-linux-android tests on an android emulator. +# See ci/android-sysimage.sh for informations about how tests are run. +COPY android-sysimage.sh /android/ +RUN bash /android/android-sysimage.sh x86_64 x86_64-21_r04.zip + +ENV PATH=$PATH:/rust/bin:/android/ndk-$ANDROID_ARCH/bin \ + CARGO_TARGET_X86_64_LINUX_ANDROID_LINKER=x86_64-linux-android-gcc \ + CC_x86_64_linux_android=x86_64-linux-android-gcc \ + CXX_x86_64_linux_android=x86_64-linux-android-g++ \ + HOME=/tmp diff --git a/libc/ci/run-docker.sh b/libc/ci/run-docker.sh index 1ac419a..e963078 100644 --- a/libc/ci/run-docker.sh +++ b/libc/ci/run-docker.sh @@ -8,10 +8,14 @@ run() { # use -f so we can use ci/ as build context docker build -t libc -f ci/docker/$1/Dockerfile ci/ mkdir -p target + if [ -w /dev/kvm ]; then + kvm="--volume /dev/kvm:/dev/kvm" + fi docker run \ --user `id -u`:`id -g` \ --rm \ --volume $HOME/.cargo:/cargo \ + $kvm \ --env CARGO_HOME=/cargo \ --volume `rustc --print sysroot`:/rust:ro \ --volume `pwd`:/checkout:ro \ @@ -19,8 +23,6 @@ run() { --env CARGO_TARGET_DIR=/checkout/target \ --workdir /checkout \ --privileged \ - --interactive \ - --tty \ libc \ ci/run.sh $1 } diff --git a/libc/ci/run.sh b/libc/ci/run.sh index 1b6e0fb..3ddc7b3 100755 --- a/libc/ci/run.sh +++ b/libc/ci/run.sh @@ -105,13 +105,20 @@ case "$TARGET" in esac case "$TARGET" in + # Android emulator for x86_64 does not work on travis (missing hardware + # acceleration). Tests are run on case *). See ci/android-sysimage.sh for + # informations about how tests are run. arm-linux-androideabi | aarch64-linux-android | i686-linux-android) # set SHELL so android can detect a 64bits system, see # http://stackoverflow.com/a/41789144 # https://issues.jenkins-ci.org/browse/JENKINS-26930?focusedCommentId=230791&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-230791 export SHELL=/bin/dash arch=$(echo $TARGET | cut -d- -f1) - emulator @$arch -no-window -no-accel & + accel="-no-accel" + if emulator -accel-check; then + accel="" + fi + emulator @$arch -no-window $accel & adb wait-for-device adb push $CARGO_TARGET_DIR/$TARGET/debug/libc-test /data/local/tmp/libc-test adb shell /data/local/tmp/libc-test 2>&1 | tee /tmp/out |