Add android build step

This commit is contained in:
Emily Toop 2018-07-23 10:54:59 +01:00
parent 92f7a527f0
commit b4a50767c6
3 changed files with 85 additions and 0 deletions

View file

@ -51,3 +51,32 @@ matrix:
script: script:
- ./scripts/cargo_test.sh - ./scripts/cargo_test.sh
cache: cargo cache: cargo
- language: rust
dist: trusty
rust: stable
jdk:
- oraclejdk8
env:
# Get revision number from https://dl.google.com/android/repository/repository2-1.xml
# Look for the string 'sdk-tools-linux-'.
- ANDROID_SDK_VERSION=4333796
before_install:
- >
PKG_OS="$TRAVIS_OS_NAME";
export ANDROID_HOME="${HOME}/android-sdk";
export PATH=$PATH:"${ANDROID_HOME}/tools/bin";
mkdir $ANDROID_HOME
install:
# SDK Tools.
- >
curl -o sdk.zip "https://dl.google.com/android/repository/sdk-tools-${PKG_OS}-${ANDROID_SDK_VERSION}.zip" &&
unzip -q sdk.zip -d $ANDROID_HOME; > /dev/null
# Android SDK and NDK
# Unfortunately we need to get rid of all output, otherwise it can easily fill up the 4 MB log limit
- yes | sdkmanager --licenses > /dev/null
- sdkmanager 'platform-tools' 'build-tools;27.0.0' 'platforms;android-27' 'ndk-bundle' > /dev/null
script:
- cd sdks/android/Mentat
- ./gradlew --no-daemon clean :library:assemble :library:test :library:lint
- cd ../../..

11
cargo-config.toml.template Executable file
View file

@ -0,0 +1,11 @@
[target.aarch64-linux-android]
ar = "$PWD/NDK/arm64/bin/aarch64-linux-android-ar"
linker = "$PWD/NDK/arm64/bin/aarch64-linux-android-clang"
[target.armv7-linux-androideabi]
ar = "$PWD/NDK/arm/bin/arm-linux-androideabi-ar"
linker = "$PWD/NDK/arm/bin/arm-linux-androideabi-clang"
[target.i686-linux-android]
ar = "$PWD/NDK/x86/bin/i686-linux-android-ar"
linker = "$PWD/NDK/x86/bin/i686-linux-android-clang"

View file

@ -0,0 +1,45 @@
#!/bin/sh
set -eu
if [ -d NDK ]; then
printf '\033[33;1mStandalone NDK already exists... Delete the NDK folder to make a new one.\033[0m\n\n'
printf ' $ rm -rf NDK\n'
exit 0
fi
if [ ! -d "${ANDROID_SDK_ROOT-}" ]; then
ANDROID_SDK_ROOT=/usr/local/share/android-sdk
fi
if [ ! -d "${ANDROID_HOME-}" ]; then
ANDROID_HOME="$ANDROID_SDK_ROOT"
fi
if [ ! -d "${ANDROID_NDK_HOME-}" ]; then
ANDROID_NDK_HOME="$ANDROID_HOME/ndk-bundle"
fi
MAKER="${ANDROID_NDK_HOME}/build/tools/make_standalone_toolchain.py"
if [ -x "$MAKER" ]; then
echo 'Creating standalone NDK...'
else
printf '\033[91;1mPlease install Android NDK!\033[0m\n\n'
printf ' $ sdkmanager ndk-bundle\n\n'
printf "\033[33;1mnote\033[0m: file \033[34;4m$MAKER\033[0m not found.\n"
printf 'If you have installed the NDK in non-standard location, please define the \033[1m$ANDROID_NDK_HOME\033[0m variable.\n'
exit 1
fi
mkdir NDK
create_ndk() {
echo "($1)..."
"$MAKER" --api "$2" --arch "$1" --install-dir "NDK/$1"
}
create_ndk arm64 24
create_ndk arm 24
create_ndk x86 24
echo 'Updating cargo-config.toml...'
sed 's|$PWD|'"${PWD}"'|g' cargo-config.toml.template > cargo-config.toml