From 125db52c2acbc55471e6382e6c516def748dbb8f Mon Sep 17 00:00:00 2001 From: Marco A L Barbosa Date: Mon, 24 Apr 2017 17:15:49 -0300 Subject: [PATCH] Add x86_64-linux-android target --- .travis.yml | 1 + README.md | 1 + ci/script.sh | 1 - docker/x86_64-linux-android/Dockerfile | 33 ++++++++++++++++++++++++++ src/main.rs | 6 ++++- 5 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 docker/x86_64-linux-android/Dockerfile diff --git a/.travis.yml b/.travis.yml index d4ebd3238..f077bb23c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,6 +30,7 @@ matrix: - env: TARGET=arm-linux-androideabi CPP=1 STD=1 OPENSSL=0.5.5 - env: TARGET=armv7-linux-androideabi CPP=1 STD=1 OPENSSL=0.5.5 - env: TARGET=i686-linux-android CPP=1 STD=1 OPENSSL=0.5.5 + - env: TARGET=x86_64-linux-android CPP=1 STD=1 OPENSSL=0.5.5 # OSX - env: TARGET=i686-apple-darwin DYLIB=1 STD=1 RUN=1 diff --git a/README.md b/README.md index 879b534c8..3cc2556e3 100644 --- a/README.md +++ b/README.md @@ -181,6 +181,7 @@ worst, "hang" (never terminate). | `thumbv7em-none-eabi` [3] | 2.2.0 | 5.3.1 | N/A | | N/A | | | `thumbv7em-none-eabihf` [3] | 2.2.0 | 5.3.1 | N/A | | N/A | | | `thumbv7m-none-eabi` [3] | 2.2.0 | 5.3.1 | N/A | | N/A | | +| `x86_64-linux-android` | N/A | 4.9 | 1.0.2k | ✓ | N/A | | | `x86_64-pc-windows-gnu`[1] | N/A | 5.3.1 | | ✓ | N/A | | | `x86_64-unknown-dragonfly` [1] [2] | 4.6.0 | 5.3.0 | 1.0.2k | | N/A | ✓ | | `x86_64-unknown-freebsd` [1] | 10.2 | 5.3.0 | 1.0.2k | | N/A | | diff --git a/ci/script.sh b/ci/script.sh index f4de189a6..a981291cd 100644 --- a/ci/script.sh +++ b/ci/script.sh @@ -62,7 +62,6 @@ EOF git clone --depth 1 https://github.com/rust-lang/cargo $td pushd $td - cargo update -p libc cross build --target $TARGET popd diff --git a/docker/x86_64-linux-android/Dockerfile b/docker/x86_64-linux-android/Dockerfile new file mode 100644 index 000000000..738eeefc9 --- /dev/null +++ b/docker/x86_64-linux-android/Dockerfile @@ -0,0 +1,33 @@ +FROM ubuntu:16.04 + +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + ca-certificates \ + cmake \ + gcc \ + libc6-dev \ + make \ + pkg-config + +COPY xargo.sh / +RUN bash /xargo.sh + +COPY android-ndk.sh / +RUN bash /android-ndk.sh x86_64 21 +ENV PATH=$PATH:/android-ndk/bin + +COPY openssl.sh / +RUN bash /openssl.sh linux-x86_64 x86_64-linux-android- -mandroid -fomit-frame-pointer + +# Libz is distributed in the android ndk, but for some unknown reason it is not +# found in the build process of some crates, so we explicit set the DEP_Z_ROOT +ENV 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++ \ + DEP_Z_ROOT=/android-ndk/sysroot/usr/ \ + OPENSSL_STATIC=1 \ + OPENSSL_DIR=/openssl \ + OPENSSL_INCLUDE_DIR=/openssl/include \ + OPENSSL_LIB_DIR=/openssl/lib \ + RUST_TEST_THREADS=1 \ + HOME=/tmp/ diff --git a/src/main.rs b/src/main.rs index f8a70251f..b4dbde89f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -87,6 +87,7 @@ pub enum Target { Armv7LinuxAndroideabi, Aarch64LinuxAndroid, I686LinuxAndroid, + X86_64LinuxAndroid, // Linux Aarch64UnknownLinuxGnu, @@ -157,7 +158,8 @@ impl Target { Target::ArmLinuxAndroideabi | Target::Armv7LinuxAndroideabi | Target::Aarch64LinuxAndroid | - Target::I686LinuxAndroid => true, + Target::I686LinuxAndroid | + Target::X86_64LinuxAndroid => true, _ => false, } } @@ -250,6 +252,7 @@ impl Target { Thumbv7mNoneEabi => "thumbv7m-none-eabi", X86_64AppleDarwin => "x86_64-apple-darwin", X86_64PcWindowsGnu => "x86_64-pc-windows-gnu", + X86_64LinuxAndroid => "x86_64-linux-android", X86_64UnknownDragonfly => "x86_64-unknown-dragonfly", X86_64UnknownFreebsd => "x86_64-unknown-freebsd", X86_64UnknownLinuxGnu => "x86_64-unknown-linux-gnu", @@ -295,6 +298,7 @@ impl Target { "thumbv7em-none-eabihf" => Thumbv7emNoneEabihf, "thumbv7m-none-eabi" => Thumbv7mNoneEabi, "x86_64-apple-darwin" => X86_64AppleDarwin, + "x86_64-linux-android" => X86_64LinuxAndroid, "x86_64-pc-windows-gnu" => X86_64PcWindowsGnu, "x86_64-unknown-dragonfly" => X86_64UnknownDragonfly, "x86_64-unknown-freebsd" => X86_64UnknownFreebsd,