Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add android build support #3885

Merged
merged 4 commits into from
Apr 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ matrix:
MAKE_TARGETS=test-unit-$TARGET

# cross compiled targets
- env: TARGET=armv7-linux-androideabi
IMAGE=android
- env: TARGET=arm-unknown-linux-gnueabi
IMAGE=cross
- env: TARGET=arm-unknown-linux-gnueabihf
Expand Down
15 changes: 15 additions & 0 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,15 @@ $(DOC_DIR)/%: $(S)src/doc/%
@mkdir -p $(@D)
cp $< $@

OPENSSL_OS_aarch64-linux-android := linux-aarch64
OPENSSL_OS_aarch64-unknown-linux-gnu := linux-aarch64
OPENSSL_OS_arm-linux-androideabi := android
OPENSSL_OS_arm-unknown-linux-gnueabi := linux-armv4
OPENSSL_OS_arm-unknown-linux-gnueabihf := linux-armv4
OPENSSL_OS_armv7-linux-androideabi := android-armv7
OPENSSL_OS_armv7-unknown-linux-gnueabihf := linux-armv4
OPENSSL_OS_i686-apple-darwin := darwin-i386-cc
OPENSSL_OS_i686-linux-android := android-x86
OPENSSL_OS_i686-unknown-freebsd := BSD-x86-elf
OPENSSL_OS_i686-unknown-linux-gnu := linux-elf
OPENSSL_OS_i686-unknown-linux-musl := linux-elf
Expand All @@ -217,11 +221,15 @@ OPENSSL_OS_x86_64-unknown-linux-gnu := linux-x86_64
OPENSSL_OS_x86_64-unknown-linux-musl := linux-x86_64
OPENSSL_OS_x86_64-unknown-netbsd := BSD-x86_64

OPENSSL_AR_aarch64-linux-android := aarch64-linux-android-ar
OPENSSL_AR_aarch64-unknown-linux-gnu := aarch64-linux-gnu-ar
OPENSSL_AR_arm-linux-androideabi := arm-linux-androideabi-ar
OPENSSL_AR_arm-unknown-linux-gnueabi := arm-linux-gnueabi-ar
OPENSSL_AR_arm-unknown-linux-gnueabihf := arm-linux-gnueabihf-ar
OPENSSL_AR_armv7-linux-androideabi := arm-linux-androideabi-ar
OPENSSL_AR_armv7-unknown-linux-gnueabihf := armv7-linux-gnueabihf-ar
OPENSSL_AR_i686-apple-darwin := ar
OPENSSL_AR_i686-linux-android := i686-linux-android-ar
OPENSSL_AR_i686-unknown-freebsd := i686-unknown-freebsd10-ar
OPENSSL_AR_i686-unknown-linux-gnu := ar
OPENSSL_AR_i686-unknown-linux-musl := ar
Expand All @@ -238,11 +246,16 @@ OPENSSL_AR_x86_64-unknown-freebsd := x86_64-unknown-freebsd10-ar
OPENSSL_AR_x86_64-unknown-linux-gnu := ar
OPENSSL_AR_x86_64-unknown-linux-musl := ar
OPENSSL_AR_x86_64-unknown-netbsd := x86_64-unknown-netbsd-ar

OPENSSL_CC_aarch64-linux-android := aarch64-linux-android-gcc
OPENSSL_CC_aarch64-unknown-linux-gnu := aarch64-linux-gnu-gcc
OPENSSL_CC_arm-linux-androideabi := arm-linux-androideabi-gcc
OPENSSL_CC_arm-unknown-linux-gnueabi := arm-linux-gnueabi-gcc
OPENSSL_CC_arm-unknown-linux-gnueabihf := arm-linux-gnueabihf-gcc
OPENSSL_CC_armv7-unknown-linux-gnueabihf := armv7-linux-gnueabihf-gcc
OPENSSL_CC_armv7-linux-androideabi := arm-linux-androideabi-gcc
OPENSSL_CC_i686-apple-darwin := clang
OPENSSL_CC_i686-linux-android := i686-linux-android-gcc
OPENSSL_CC_i686-unknown-freebsd := i686-unknown-freebsd10-gcc
OPENSSL_CC_i686-unknown-linux-gnu := gcc
OPENSSL_CC_i686-unknown-linux-musl := musl-gcc
Expand All @@ -261,6 +274,8 @@ OPENSSL_CC_x86_64-unknown-linux-musl := musl-gcc
OPENSSL_CC_x86_64-unknown-netbsd := x86_64-unknown-netbsd-gcc

SETARCH_i686-unknown-linux-gnu := setarch i386

OPENSSL_CFLAGS_aarch64-linux-android := "-mandroid -fomit-frame-pointer"
OPENSSL_CFLAGS_i686-apple-darwin := -m32
OPENSSL_CFLAGS_i686-unknown-linux-gnu := -m32
OPENSSL_CFLAGS_i686-unknown-linux-musl := -m32
Expand Down
27 changes: 27 additions & 0 deletions src/ci/docker/android/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM ubuntu:16.04

RUN apt-get update && \
apt-get install -y --no-install-recommends \
ca-certificates \
cmake \
curl \
gcc \
git \
libc6-dev \
make \
pkg-config

WORKDIR /android
RUN apt-get install -y --no-install-recommends \
unzip \
python && \
curl -O https://dl.google.com/android/repository/android-ndk-r13b-linux-x86_64.zip && \
unzip -q android-ndk-r13b-linux-x86_64.zip && \
./android-ndk-r13b/build/tools/make_standalone_toolchain.py \
--install-dir /android-ndk/arm --arch arm --api 21 && \
rm -rf ./android-ndk-r13b-linux-x86_64.zip ./android-ndk-r13b && \
apt-get purge --auto-remove -y unzip python

ENV PATH=$PATH:/android-ndk/arm/bin

ENV CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_LINKER=arm-linux-androideabi-gcc
6 changes: 6 additions & 0 deletions src/ci/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ if [ -n "$CI" ] && [ "$BRANCH" != "auto-cargo" ] && [ "$ALLOW_PR" = "" ]; then
exit 0
fi

# For some unknown reason libz is not found in the android docker image, so we
# use this workaround
if [ "$TARGET" = armv7-linux-androideabi ]; then
export DEP_Z_ROOT=/android-ndk/arm/sysroot/usr
fi

$SRC/configure \
--prefix=/tmp/obj/install \
--target=$TARGET \
Expand Down