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

Improve Travis CI Android Builds #548

Closed
wants to merge 7 commits into from
Closed
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
163 changes: 76 additions & 87 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ cache:
directories:
- $HOME/kcov-i686-unknown-linux-gnu
- $HOME/kcov-x86_64-unknown-linux-gnu
- $HOME/android/android-sdk-linux
- $HOME/android/android-18-arm-linux-androideabi-4.8
- $HOME/android/android-ndk
- $HOME/android/android-sdk-linux/platform-tools
- $HOME/android/android-sdk-linux/tools
matrix:
fast_finish: true
allow_failures:
Expand Down Expand Up @@ -37,57 +38,53 @@ matrix:
os: osx
osx_image: xcode8.2

- env: TARGET_X=aarch64-linux-android CC_X=aarch64-linux-android-gcc CXX_X=aarch64-linux-android-g++ FEATURES_X=--features=rsa_signing MODE_X=DEBUG KCOV=0
rust: stable
os: linux
dist: trusty
sudo: required

- env: TARGET_X=aarch64-linux-android CC_X=aarch64-linux-android-gcc CXX_X=aarch64-linux-android-g++ FEATURES_X= MODE_X=DEBUG KCOV=0
rust: stable
os: linux
dist: trusty
sudo: required

- env: TARGET_X=aarch64-linux-android CC_X=aarch64-linux-android-gcc CXX_X=aarch64-linux-android-g++ FEATURES_X=--features=rsa_signing MODE_X=RELWITHDEBINFO KCOV=0
rust: stable
os: linux
dist: trusty
sudo: required

- env: TARGET_X=aarch64-linux-android CC_X=aarch64-linux-android-gcc CXX_X=aarch64-linux-android-g++ FEATURES_X= MODE_X=RELWITHDEBINFO KCOV=0
rust: stable
os: linux
dist: trusty
sudo: required

- env: TARGET_X=armv7-linux-androideabi CC_X=arm-linux-androideabi-gcc CXX_X=arm-linux-androideabi-g++ FEATURES_X=--features=rsa_signing MODE_X=DEBUG KCOV=0
rust: stable
os: linux
dist: trusty
sudo: required
addons:
apt:
packages:
- expect
- openjdk-6-jre-headless
sources:
- ubuntu-toolchain-r-test

- env: TARGET_X=armv7-linux-androideabi CC_X=arm-linux-androideabi-gcc CXX_X=arm-linux-androideabi-g++ FEATURES_X= MODE_X=DEBUG KCOV=0
rust: stable
os: linux
dist: trusty
sudo: required
addons:
apt:
packages:
- expect
- openjdk-6-jre-headless
sources:
- ubuntu-toolchain-r-test

- env: TARGET_X=armv7-linux-androideabi CC_X=arm-linux-androideabi-gcc CXX_X=arm-linux-androideabi-g++ FEATURES_X=--features=rsa_signing MODE_X=RELWITHDEBINFO KCOV=0
rust: stable
os: linux
dist: trusty
sudo: required
addons:
apt:
packages:
- expect
- openjdk-6-jre-headless
sources:
- ubuntu-toolchain-r-test

- env: TARGET_X=armv7-linux-androideabi CC_X=arm-linux-androideabi-gcc CXX_X=arm-linux-androideabi-g++ FEATURES_X= MODE_X=RELWITHDEBINFO KCOV=0
rust: stable
os: linux
dist: trusty
sudo: required
addons:
apt:
packages:
- expect
- openjdk-6-jre-headless
sources:
- ubuntu-toolchain-r-test

- env: TARGET_X=x86_64-unknown-linux-gnu FEATURES_X=--features=rsa_signing MODE_X=DEBUG KCOV=0
rust: stable
Expand Down Expand Up @@ -585,57 +582,53 @@ matrix:
os: osx
osx_image: xcode8.2

- env: TARGET_X=aarch64-linux-android CC_X=aarch64-linux-android-gcc CXX_X=aarch64-linux-android-g++ FEATURES_X=--features=rsa_signing MODE_X=DEBUG KCOV=0
rust: nightly
os: linux
dist: trusty
sudo: required

- env: TARGET_X=aarch64-linux-android CC_X=aarch64-linux-android-gcc CXX_X=aarch64-linux-android-g++ FEATURES_X= MODE_X=DEBUG KCOV=0
rust: nightly
os: linux
dist: trusty
sudo: required

- env: TARGET_X=aarch64-linux-android CC_X=aarch64-linux-android-gcc CXX_X=aarch64-linux-android-g++ FEATURES_X=--features=rsa_signing MODE_X=RELWITHDEBINFO KCOV=0
rust: nightly
os: linux
dist: trusty
sudo: required

- env: TARGET_X=aarch64-linux-android CC_X=aarch64-linux-android-gcc CXX_X=aarch64-linux-android-g++ FEATURES_X= MODE_X=RELWITHDEBINFO KCOV=0
rust: nightly
os: linux
dist: trusty
sudo: required

- env: TARGET_X=armv7-linux-androideabi CC_X=arm-linux-androideabi-gcc CXX_X=arm-linux-androideabi-g++ FEATURES_X=--features=rsa_signing MODE_X=DEBUG KCOV=0
rust: nightly
os: linux
dist: trusty
sudo: required
addons:
apt:
packages:
- expect
- openjdk-6-jre-headless
sources:
- ubuntu-toolchain-r-test

- env: TARGET_X=armv7-linux-androideabi CC_X=arm-linux-androideabi-gcc CXX_X=arm-linux-androideabi-g++ FEATURES_X= MODE_X=DEBUG KCOV=0
rust: nightly
os: linux
dist: trusty
sudo: required
addons:
apt:
packages:
- expect
- openjdk-6-jre-headless
sources:
- ubuntu-toolchain-r-test

- env: TARGET_X=armv7-linux-androideabi CC_X=arm-linux-androideabi-gcc CXX_X=arm-linux-androideabi-g++ FEATURES_X=--features=rsa_signing MODE_X=RELWITHDEBINFO KCOV=0
rust: nightly
os: linux
dist: trusty
sudo: required
addons:
apt:
packages:
- expect
- openjdk-6-jre-headless
sources:
- ubuntu-toolchain-r-test

- env: TARGET_X=armv7-linux-androideabi CC_X=arm-linux-androideabi-gcc CXX_X=arm-linux-androideabi-g++ FEATURES_X= MODE_X=RELWITHDEBINFO KCOV=0
rust: nightly
os: linux
dist: trusty
sudo: required
addons:
apt:
packages:
- expect
- openjdk-6-jre-headless
sources:
- ubuntu-toolchain-r-test

- env: TARGET_X=x86_64-unknown-linux-gnu FEATURES_X=--features=rsa_signing MODE_X=DEBUG KCOV=0
rust: nightly
Expand Down Expand Up @@ -1153,57 +1146,53 @@ matrix:
os: osx
osx_image: xcode8.2

- env: TARGET_X=aarch64-linux-android CC_X=aarch64-linux-android-gcc CXX_X=aarch64-linux-android-g++ FEATURES_X=--features=rsa_signing MODE_X=DEBUG KCOV=0
rust: beta
os: linux
dist: trusty
sudo: required

- env: TARGET_X=aarch64-linux-android CC_X=aarch64-linux-android-gcc CXX_X=aarch64-linux-android-g++ FEATURES_X= MODE_X=DEBUG KCOV=0
rust: beta
os: linux
dist: trusty
sudo: required

- env: TARGET_X=aarch64-linux-android CC_X=aarch64-linux-android-gcc CXX_X=aarch64-linux-android-g++ FEATURES_X=--features=rsa_signing MODE_X=RELWITHDEBINFO KCOV=0
rust: beta
os: linux
dist: trusty
sudo: required

- env: TARGET_X=aarch64-linux-android CC_X=aarch64-linux-android-gcc CXX_X=aarch64-linux-android-g++ FEATURES_X= MODE_X=RELWITHDEBINFO KCOV=0
rust: beta
os: linux
dist: trusty
sudo: required

- env: TARGET_X=armv7-linux-androideabi CC_X=arm-linux-androideabi-gcc CXX_X=arm-linux-androideabi-g++ FEATURES_X=--features=rsa_signing MODE_X=DEBUG KCOV=0
rust: beta
os: linux
dist: trusty
sudo: required
addons:
apt:
packages:
- expect
- openjdk-6-jre-headless
sources:
- ubuntu-toolchain-r-test

- env: TARGET_X=armv7-linux-androideabi CC_X=arm-linux-androideabi-gcc CXX_X=arm-linux-androideabi-g++ FEATURES_X= MODE_X=DEBUG KCOV=0
rust: beta
os: linux
dist: trusty
sudo: required
addons:
apt:
packages:
- expect
- openjdk-6-jre-headless
sources:
- ubuntu-toolchain-r-test

- env: TARGET_X=armv7-linux-androideabi CC_X=arm-linux-androideabi-gcc CXX_X=arm-linux-androideabi-g++ FEATURES_X=--features=rsa_signing MODE_X=RELWITHDEBINFO KCOV=0
rust: beta
os: linux
dist: trusty
sudo: required
addons:
apt:
packages:
- expect
- openjdk-6-jre-headless
sources:
- ubuntu-toolchain-r-test

- env: TARGET_X=armv7-linux-androideabi CC_X=arm-linux-androideabi-gcc CXX_X=arm-linux-androideabi-g++ FEATURES_X= MODE_X=RELWITHDEBINFO KCOV=0
rust: beta
os: linux
dist: trusty
sudo: required
addons:
apt:
packages:
- expect
- openjdk-6-jre-headless
sources:
- ubuntu-toolchain-r-test

- env: TARGET_X=x86_64-unknown-linux-gnu FEATURES_X=--features=rsa_signing MODE_X=DEBUG KCOV=0
rust: beta
Expand Down Expand Up @@ -1683,4 +1672,4 @@ matrix:

# END GENERATED

script: if [[ "$TARGET_X" =~ ^a*.*linux-.*eabi && "$MODE_X" == "RELWITHDEBINFO" ]]; then travis_wait 60 mk/travis.sh; else mk/travis.sh; fi
script: if [[ "$TARGET_X" =~ ^a*.*linux-.*(droid|eabi) && "$MODE_X" == "RELWITHDEBINFO" ]]; then travis_wait 60 mk/travis.sh; else mk/travis.sh; fi
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ the table below. The C compilers listed are used for compiling the C portions.
<code>qemu-user-arm</code>.</td>
</tr>
<tr><td>Android</td>
<td>32&#8209;bit&nbsp;ARM</td>
<td>32&#8209;bit&nbsp;ARM, AAarch64</td>
<td>Built using the Android SDK 24.4.1 and Android NDK 14, tested using the
Android emulator.</td>
</tr>
Expand Down
7 changes: 6 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,12 @@ fn cc(file: &Path, ext: &str, target: &Target, warnings_are_errors: bool,
// Define __ANDROID_API__ to the Android API level we want.
// Needed for Android NDK Unified Headers, see:
// https://android.googlesource.com/platform/ndk/+/master/docs/UnifiedHeaders.md#Supporting-Unified-Headers-in-Your-Build-System
let _ = c.define("__ANDROID_API__", Some("18"));
if target.arch() == "aarch64" {
// Minimum API level where AArch64 is available is 21.
let _ = c.define("__ANDROID_API__", Some("21"));
} else {
let _ = c.define("__ANDROID_API__", Some("18"));
}
}

let mut c = c.get_compiler().to_command();
Expand Down
75 changes: 58 additions & 17 deletions mk/travis-install-android.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,34 +21,75 @@
# SOFTWARE.
set -ex

ARGS=$(getopt -o a:l:b:s:r: --long arch:,api-level:,abi-name:,sys-img-api-level:,rust-target: -n 'travis-install-android.sh' -- "$@" )
eval set -- "${ARGS}"

while true; do
case $1 in
-a|--arch)
ARCH="${2}"
shift 2
;;
-l|--api-level)
API="${2}"
shift 2
;;
-l|--abi-name)
ABI="${2}"
shift 2
;;
-s|--sys-img-api-level)
SYS_IMG_API="${2}"
shift 2
;;
-r|--rust-target)
RUST_TARGET="${2}"
shift 2
;;
--)
shift
break
;;
*)
echo "Error!"
exit 1
;;
esac
done

ANDROID_SDK_VERSION=${ANDROID_SDK_VERSION:-24.4.1}
ANDROID_SDK_URL=https://dl.google.com/android/android-sdk_r${ANDROID_SDK_VERSION}-linux.tgz

ANDROID_NDK_VERSION=${ANDROID_NDK_VERSION:-14}
ANDROID_NDK_URL=https://dl.google.com/android/repository/android-ndk-r${ANDROID_NDK_VERSION}-linux-x86_64.zip

ANDROID_INSTALL_PREFIX="${HOME}/android"
ANDROID_SDK_INSTALL_DIR="${HOME}/android/android-sdk-linux"
ANDROID_NDK_INSTALL_DIR="${ANDROID_INSTALL_PREFIX}/android-18-arm-linux-androideabi-4.8"
ANDROID_SDK_INSTALL_DIR="${ANDROID_INSTALL_PREFIX}/android-sdk-linux"
ANDROID_NDK_INSTALL_DIR="${ANDROID_INSTALL_PREFIX}/android-ndk"

if [[ ! -f $ANDROID_SDK_INSTALL_DIR/tools/emulator ]];then
mkdir -p "${ANDROID_INSTALL_PREFIX}"
pushd "${ANDROID_INSTALL_PREFIX}"
# We're using API 21 for AArch24 and 18 for everything else.
# Unfortunately the only available AArch64 images have API level 24.
# Install the extra API package and have a different option for the system image.
ANDROID_PKGS="android-${API},android-${SYS_IMG_API},sys-img-${ABI}-android-${SYS_IMG_API}"

mkdir -p "${ANDROID_INSTALL_PREFIX}"
pushd "${ANDROID_INSTALL_PREFIX}"

if [[ ! -f $ANDROID_SDK_INSTALL_DIR/tools/emulator ]];then
curl ${ANDROID_SDK_URL} | tar -zxf -

expect -c '
set timeout 600;
spawn ./android-sdk-linux/tools/android update sdk -a --no-ui --filter tools,platform-tools,android-18,sys-img-armeabi-v7a-android-18;
expect {
"Do you accept the license" { exp_send "y\r" ; exp_continue }
eof
}
'
popd
ANDROID_PKGS="tools,platform-tools,${ANDROID_PKGS}"
fi

if [[ ! -d $ANDROID_NDK_INSTALL_DIR/sysroot/usr/include/arm-linux-androideabi ]];then
echo y | ./android-sdk-linux/tools/android update sdk -a --no-ui --filter ${ANDROID_PKGS}

popd

# Test all these directories because of the mismatch between Android arch name and rustc targets.
if [[ ! ( -d $ANDROID_NDK_INSTALL_DIR/sysroot/usr/include/${ARCH}-linux-androideabi ||
-d $ANDROID_NDK_INSTALL_DIR/sysroot/usr/include/${ARCH}-linux-android ||
-d $ANDROID_NDK_INSTALL_DIR/sysroot/usr/include/${RUST_TARGET} )]];then

mkdir -p "${ANDROID_INSTALL_PREFIX}/downloads"
pushd "${ANDROID_INSTALL_PREFIX}/downloads"

Expand All @@ -57,8 +98,8 @@ if [[ ! -d $ANDROID_NDK_INSTALL_DIR/sysroot/usr/include/arm-linux-androideabi ]]

./android-ndk-r${ANDROID_NDK_VERSION}/build/tools/make_standalone_toolchain.py \
--force \
--arch arm \
--api 18 \
--arch ${ARCH} \
--api ${API} \
--unified-headers \
--install-dir ${ANDROID_NDK_INSTALL_DIR}

Expand Down
Loading