From 84604456d2192e212f20e931e9842c3b81d8be73 Mon Sep 17 00:00:00 2001 From: Marco A L Barbosa Date: Fri, 7 Apr 2017 18:57:30 -0300 Subject: [PATCH 1/3] Update android ndk of arm-android image to r13b Also update sscache to 2017-04-04 and reorganize Dockerfile so we can share some image layers --- src/ci/docker/arm-android/Dockerfile | 48 +++++++++++++++--------- src/ci/docker/arm-android/install-ndk.sh | 33 ---------------- 2 files changed, 30 insertions(+), 51 deletions(-) delete mode 100644 src/ci/docker/arm-android/install-ndk.sh diff --git a/src/ci/docker/arm-android/Dockerfile b/src/ci/docker/arm-android/Dockerfile index 04ca6d76c557b..ebbfdb4224bd4 100644 --- a/src/ci/docker/arm-android/Dockerfile +++ b/src/ci/docker/arm-android/Dockerfile @@ -1,7 +1,6 @@ FROM ubuntu:16.04 -RUN dpkg --add-architecture i386 && \ - apt-get update && \ +RUN apt-get update && \ apt-get install -y --no-install-recommends \ g++ \ make \ @@ -12,35 +11,48 @@ RUN dpkg --add-architecture i386 && \ git \ cmake \ unzip \ - expect \ - openjdk-9-jre-headless \ sudo \ - libstdc++6:i386 \ xz-utils \ libssl-dev \ pkg-config -WORKDIR /android/ -ENV PATH=$PATH:/android/ndk-arm-9/bin:/android/sdk/tools:/android/sdk/platform-tools - -COPY install-ndk.sh install-sdk.sh accept-licenses.sh /android/ -RUN sh /android/install-ndk.sh -RUN sh /android/install-sdk.sh - RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb && \ dpkg -i dumb-init_*.deb && \ rm dumb-init_*.deb -COPY start-emulator.sh /android/ - -ENTRYPOINT ["/usr/bin/dumb-init", "--", "/android/start-emulator.sh"] - RUN curl -o /usr/local/bin/sccache \ - https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-02-24-sccache-x86_64-unknown-linux-gnu && \ + https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-04-04-sccache-x86_64-unknown-linux-musl && \ chmod +x /usr/local/bin/sccache +RUN curl -O https://dl.google.com/android/repository/android-ndk-r13b-linux-x86_64.zip && \ + unzip -q android-ndk-r13b-linux-x86_64.zip && \ + python2.7 android-ndk-r13b/build/tools/make_standalone_toolchain.py \ + --install-dir /android-ndk \ + --arch arm \ + --api 9 && \ + rm -rf android-ndk-* + +RUN dpkg --add-architecture i386 && \ + apt-get update && \ + apt-get install -y --no-install-recommends \ + expect \ + openjdk-9-jre-headless \ + libstdc++6:i386 + +WORKDIR /android/ +ENV PATH=$PATH:/android-ndk/bin +ENV PATH=$PATH:/android/sdk/tools +ENV PATH=$PATH:/android/sdk/platform-tools + +COPY accept-licenses.sh /android/ +COPY install-sdk.sh /android/ +RUN sh /android/install-sdk.sh + +COPY start-emulator.sh /android/ +ENTRYPOINT ["/usr/bin/dumb-init", "--", "/android/start-emulator.sh"] + ENV RUST_CONFIGURE_ARGS \ --target=arm-linux-androideabi \ - --arm-linux-androideabi-ndk=/android/ndk-arm-9 + --arm-linux-androideabi-ndk=/android-ndk ENV SCRIPT python2.7 ../x.py test --target arm-linux-androideabi diff --git a/src/ci/docker/arm-android/install-ndk.sh b/src/ci/docker/arm-android/install-ndk.sh deleted file mode 100644 index 389ec062110e0..0000000000000 --- a/src/ci/docker/arm-android/install-ndk.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/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 or the MIT license -# , at your -# option. This file may not be copied, modified, or distributed -# except according to those terms. - -set -ex - -cpgdb() { - cp android-ndk-r11c/prebuilt/linux-x86_64/bin/gdb /android/$1/bin/$2-gdb - cp android-ndk-r11c/prebuilt/linux-x86_64/bin/gdb-orig /android/$1/bin/gdb-orig - cp -r android-ndk-r11c/prebuilt/linux-x86_64/share /android/$1/share -} - -# Prep the Android NDK -# -# See https://github.com/servo/servo/wiki/Building-for-Android -curl -O https://dl.google.com/android/repository/android-ndk-r11c-linux-x86_64.zip -unzip -q android-ndk-r11c-linux-x86_64.zip -bash android-ndk-r11c/build/tools/make-standalone-toolchain.sh \ - --platform=android-9 \ - --toolchain=arm-linux-androideabi-4.9 \ - --install-dir=/android/ndk-arm-9 \ - --ndk-dir=/android/android-ndk-r11c \ - --arch=arm -cpgdb ndk-arm-9 arm-linux-androideabi - -rm -rf ./android-ndk-r11c-linux-x86_64.zip ./android-ndk-r11c From 40ac5a594bceb3d9396bd2f4c12bf29f77becd9f Mon Sep 17 00:00:00 2001 From: Marco A L Barbosa Date: Wed, 19 Apr 2017 13:50:36 -0300 Subject: [PATCH 2/3] Add openssl android build support --- src/bootstrap/native.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index 726e94e49a19e..c25041d1c0f19 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -274,11 +274,15 @@ pub fn openssl(build: &Build, target: &str) { configure.arg("no-ssl3"); let os = match target { + "aarch64-linux-android" => "linux-aarch64", "aarch64-unknown-linux-gnu" => "linux-aarch64", + "arm-linux-androideabi" => "android", "arm-unknown-linux-gnueabi" => "linux-armv4", "arm-unknown-linux-gnueabihf" => "linux-armv4", + "armv7-linux-androideabi" => "android-armv7", "armv7-unknown-linux-gnueabihf" => "linux-armv4", "i686-apple-darwin" => "darwin-i386-cc", + "i686-linux-android" => "android-x86", "i686-unknown-freebsd" => "BSD-x86-elf", "i686-unknown-linux-gnu" => "linux-elf", "i686-unknown-linux-musl" => "linux-elf", @@ -302,6 +306,12 @@ pub fn openssl(build: &Build, target: &str) { for flag in build.cflags(target) { configure.arg(flag); } + // There is no specific os target for android aarch64, + // so we use linux-aarch64 and pass some extra cflags + if os == "linux-aarch64" { + configure.arg("-mandroid"); + configure.arg("-fomit-frame-pointer"); + } configure.current_dir(&obj); println!("Configuring openssl for {}", target); build.run_quiet(&mut configure); From 6500357180bc0ce243c66256db45dbfb42ee06cb Mon Sep 17 00:00:00 2001 From: Marco A L Barbosa Date: Wed, 19 Apr 2017 13:51:55 -0300 Subject: [PATCH 3/3] Add host build for aarch64-linux-android --- .travis.yml | 1 + src/ci/docker/dist-aarch64-android/Dockerfile | 49 +++++++++++++++++++ src/ci/docker/dist-android/Dockerfile | 28 ++++------- src/ci/docker/dist-android/install-ndk.sh | 37 ++++++-------- src/tools/build-manifest/src/main.rs | 1 + 5 files changed, 77 insertions(+), 39 deletions(-) create mode 100644 src/ci/docker/dist-aarch64-android/Dockerfile diff --git a/.travis.yml b/.travis.yml index 0ffba70d2ef44..16c8458a3e7ad 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,6 +15,7 @@ matrix: - env: IMAGE=arm-android - env: IMAGE=armhf-gnu - env: IMAGE=cross DEPLOY=1 + - env: IMAGE=dist-aarch64-android DEPLOY=1 - env: IMAGE=dist-aarch64-linux DEPLOY=1 - env: IMAGE=dist-android DEPLOY=1 - env: IMAGE=dist-arm-linux DEPLOY=1 diff --git a/src/ci/docker/dist-aarch64-android/Dockerfile b/src/ci/docker/dist-aarch64-android/Dockerfile new file mode 100644 index 0000000000000..00a869e1fd5bc --- /dev/null +++ b/src/ci/docker/dist-aarch64-android/Dockerfile @@ -0,0 +1,49 @@ +FROM ubuntu:16.04 + +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + g++ \ + make \ + file \ + curl \ + ca-certificates \ + python2.7 \ + git \ + cmake \ + unzip \ + sudo \ + xz-utils \ + libssl-dev \ + pkg-config + +RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb && \ + dpkg -i dumb-init_*.deb && \ + rm dumb-init_*.deb + +RUN curl -o /usr/local/bin/sccache \ + https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-04-04-sccache-x86_64-unknown-linux-musl && \ + chmod +x /usr/local/bin/sccache + +RUN curl -O https://dl.google.com/android/repository/android-ndk-r13b-linux-x86_64.zip && \ + unzip -q android-ndk-r13b-linux-x86_64.zip && \ + python2.7 android-ndk-r13b/build/tools/make_standalone_toolchain.py \ + --install-dir /android-ndk \ + --arch arm64 \ + --api 21 && \ + rm -rf android-ndk-* + +ENTRYPOINT ["/usr/bin/dumb-init", "--"] + +ENV PATH=$PATH:/android-ndk/bin + +ENV DEP_Z_ROOT=/android-ndk/sysroot/usr/ + +ENV RUST_CONFIGURE_ARGS \ + --target=aarch64-linux-android \ + --host=aarch64-linux-android \ + --aarch64-linux-android-ndk=/android-ndk \ + --disable-rpath \ + --enable-extended \ + --enable-cargo-openssl-static + +ENV SCRIPT python2.7 ../x.py dist --target aarch64-linux-android --host aarch64-linux-android diff --git a/src/ci/docker/dist-android/Dockerfile b/src/ci/docker/dist-android/Dockerfile index 99c176aa820c7..895b9a9a5e25b 100644 --- a/src/ci/docker/dist-android/Dockerfile +++ b/src/ci/docker/dist-android/Dockerfile @@ -1,7 +1,6 @@ FROM ubuntu:16.04 -RUN dpkg --add-architecture i386 && \ - apt-get update && \ +RUN apt-get update && \ apt-get install -y --no-install-recommends \ g++ \ make \ @@ -12,40 +11,33 @@ RUN dpkg --add-architecture i386 && \ git \ cmake \ unzip \ - expect \ - openjdk-9-jre \ sudo \ - libstdc++6:i386 \ xz-utils \ libssl-dev \ pkg-config -WORKDIR /android/ -ENV PATH=$PATH:/android/ndk-arm-9/bin:/android/sdk/tools:/android/sdk/platform-tools - -COPY install-ndk.sh /android/ -RUN sh /android/install-ndk.sh - RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb && \ dpkg -i dumb-init_*.deb && \ rm dumb-init_*.deb -ENTRYPOINT ["/usr/bin/dumb-init", "--"] RUN curl -o /usr/local/bin/sccache \ https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-04-04-sccache-x86_64-unknown-linux-musl && \ chmod +x /usr/local/bin/sccache +COPY install-ndk.sh /android/ +RUN sh /android/install-ndk.sh + +ENTRYPOINT ["/usr/bin/dumb-init", "--"] + ENV TARGETS=arm-linux-androideabi -ENV TARGETS=$TARGETS,i686-linux-android -ENV TARGETS=$TARGETS,aarch64-linux-android ENV TARGETS=$TARGETS,armv7-linux-androideabi +ENV TARGETS=$TARGETS,i686-linux-android ENV RUST_CONFIGURE_ARGS \ --target=$TARGETS \ --enable-extended \ - --arm-linux-androideabi-ndk=/android/ndk-arm-9 \ - --armv7-linux-androideabi-ndk=/android/ndk-arm-9 \ - --i686-linux-android-ndk=/android/ndk-x86-9 \ - --aarch64-linux-android-ndk=/android/ndk-aarch64 + --arm-linux-androideabi-ndk=/android/ndk/arm-9 \ + --armv7-linux-androideabi-ndk=/android/ndk/arm-9 \ + --i686-linux-android-ndk=/android/ndk/x86-9 ENV SCRIPT python2.7 ../x.py dist --target $TARGETS diff --git a/src/ci/docker/dist-android/install-ndk.sh b/src/ci/docker/dist-android/install-ndk.sh index 19c1b94e784c8..d26bb0cdb6ca6 100644 --- a/src/ci/docker/dist-android/install-ndk.sh +++ b/src/ci/docker/dist-android/install-ndk.sh @@ -11,28 +11,23 @@ set -ex +install_ndk() { + python2.7 android-ndk-r13b/build/tools/make_standalone_toolchain.py \ + --install-dir /android/ndk/$1-$2 \ + --arch $1 \ + --api $2 +} + +mkdir -p /android/ndk +cd android + # Prep the Android NDK # # See https://github.com/servo/servo/wiki/Building-for-Android -curl -O https://dl.google.com/android/repository/android-ndk-r11c-linux-x86_64.zip -unzip -q android-ndk-r11c-linux-x86_64.zip -bash android-ndk-r11c/build/tools/make-standalone-toolchain.sh \ - --platform=android-9 \ - --toolchain=arm-linux-androideabi-4.9 \ - --install-dir=/android/ndk-arm-9 \ - --ndk-dir=/android/android-ndk-r11c \ - --arch=arm -bash android-ndk-r11c/build/tools/make-standalone-toolchain.sh \ - --platform=android-21 \ - --toolchain=aarch64-linux-android-4.9 \ - --install-dir=/android/ndk-aarch64 \ - --ndk-dir=/android/android-ndk-r11c \ - --arch=arm64 -bash android-ndk-r11c/build/tools/make-standalone-toolchain.sh \ - --platform=android-9 \ - --toolchain=x86-4.9 \ - --install-dir=/android/ndk-x86-9 \ - --ndk-dir=/android/android-ndk-r11c \ - --arch=x86 +curl -O https://dl.google.com/android/repository/android-ndk-r13b-linux-x86_64.zip +unzip -q android-ndk-r13b-linux-x86_64.zip + +install_ndk arm 9 +install_ndk x86 9 -rm -rf ./android-ndk-r11c-linux-x86_64.zip ./android-ndk-r11c +rm -rf android-ndk-* diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index 28c8d22707325..52ab1208fe11d 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -19,6 +19,7 @@ use std::path::{PathBuf, Path}; use std::process::{Command, Stdio}; static HOSTS: &'static [&'static str] = &[ + "aarch64-linux-android", "aarch64-unknown-linux-gnu", "arm-unknown-linux-gnueabi", "arm-unknown-linux-gnueabihf",