|  | 
|  | 1 | +FROM ubuntu:16.04 | 
|  | 2 | + | 
|  | 3 | +RUN apt-get update && \ | 
|  | 4 | +    apt-get install -y --no-install-recommends \ | 
|  | 5 | +  g++ \ | 
|  | 6 | +  make \ | 
|  | 7 | +  file \ | 
|  | 8 | +  curl \ | 
|  | 9 | +  ca-certificates \ | 
|  | 10 | +  python2.7 \ | 
|  | 11 | +  git \ | 
|  | 12 | +  cmake \ | 
|  | 13 | +  unzip \ | 
|  | 14 | +  sudo \ | 
|  | 15 | +  xz-utils \ | 
|  | 16 | +  libssl-dev \ | 
|  | 17 | +  pkg-config | 
|  | 18 | + | 
|  | 19 | +RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb && \ | 
|  | 20 | +    dpkg -i dumb-init_*.deb && \ | 
|  | 21 | +    rm dumb-init_*.deb | 
|  | 22 | + | 
|  | 23 | +RUN curl -o /usr/local/bin/sccache \ | 
|  | 24 | +      https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-04-29-sccache-x86_64-unknown-linux-musl && \ | 
|  | 25 | +      chmod +x /usr/local/bin/sccache | 
|  | 26 | + | 
|  | 27 | +ENTRYPOINT ["/usr/bin/dumb-init", "--"] | 
|  | 28 | + | 
|  | 29 | +COPY android-ndk.sh / | 
|  | 30 | +RUN . /android-ndk.sh && \ | 
|  | 31 | +    download_ndk android-ndk-r13b-linux-x86_64.zip && \ | 
|  | 32 | +    make_standalone_toolchain arm 9 && \ | 
|  | 33 | +    make_standalone_toolchain arm 21 && \ | 
|  | 34 | +    remove_ndk | 
|  | 35 | + | 
|  | 36 | +ENV PATH=$PATH:/android/ndk/arm-9/bin | 
|  | 37 | + | 
|  | 38 | +ENV DEP_Z_ROOT=/android/ndk/arm-9/sysroot/usr/ | 
|  | 39 | + | 
|  | 40 | +ENV HOSTS=armv7-linux-androideabi | 
|  | 41 | + | 
|  | 42 | +ENV RUST_CONFIGURE_ARGS \ | 
|  | 43 | +      --host=$HOSTS \ | 
|  | 44 | +      --target=$HOSTS \ | 
|  | 45 | +      --armv7-linux-androideabi-ndk=/android/ndk/arm \ | 
|  | 46 | +      --disable-rpath \ | 
|  | 47 | +      --enable-extended \ | 
|  | 48 | +      --enable-cargo-openssl-static | 
|  | 49 | + | 
|  | 50 | +# We support api level 9, but api level 21 is required to build llvm. To | 
|  | 51 | +# overcome this problem we use a ndk with api level 21 to build llvm and then | 
|  | 52 | +# switch to a ndk with api level 9 to complete the build. When the linker is | 
|  | 53 | +# invoked there are missing symbols (like sigsetempty, not available with api | 
|  | 54 | +# level 9), the default linker behavior is to generate an error, to allow the | 
|  | 55 | +# build to finish we use --warn-unresolved-symbols. Note that the missing | 
|  | 56 | +# symbols does not affect std, only the compiler (llvm) and cargo (openssl). | 
|  | 57 | +RUN chmod 777 /android/ndk && \ | 
|  | 58 | +    ln -s /android/ndk/arm-21 /android/ndk/arm | 
|  | 59 | + | 
|  | 60 | +ENV SCRIPT \ | 
|  | 61 | +  python2.7 ../x.py build src/llvm --host $HOSTS --target $HOSTS && \ | 
|  | 62 | +  (export RUSTFLAGS="\"-C link-arg=-Wl,--warn-unresolved-symbols\""; \ | 
|  | 63 | +    rm /android/ndk/arm && \ | 
|  | 64 | +    ln -s /android/ndk/arm-9 /android/ndk/arm && \ | 
|  | 65 | +    python2.7 ../x.py dist --host $HOSTS --target $HOSTS) | 
0 commit comments