TRAVIS: Build APK for both architectures at once

This commit is contained in:
Dries Harnie 2019-11-11 12:29:29 +01:00 committed by Paweł Kołodziejski
parent 6fa2c2eb6b
commit eac71426c2
6 changed files with 41 additions and 42 deletions

View File

@ -81,55 +81,36 @@ matrix:
- make osxsnap
- mkdir artifacts && cp -r ResidualVM-snapshot.dmg artifacts
- os: linux
name: "Android ARM64"
name: "Android (ARM64 & ARMv7)"
language: android
android: &android
android:
components:
- tools
- platform-tools
- build-tools
- android-26
env:
- ANDROID_TARGET=android-arm64-v8a
- ANDROID_ABI=arm64-v8a
- CROSS_HOST=aarch64-linux-android
- ANDROID_LEVEL=26
- ANDROID_SDK=${ANDROID_HOME}
- ANDROID_NDK=${ANDROID_HOME}/ndk-bundle
before_install: &android-before-install
before_install:
- mkdir -p $ANDROID_HOME/licenses
- echo -e "\n24333f8a63b6825ea9c5514f83c2829b004d1fee" > $ANDROID_HOME/licenses/android-sdk-license
install: &android-install
install:
- echo y | $ANDROID_HOME/tools/bin/sdkmanager ndk-bundle >/dev/null 2>&1
- ./.travis/android-build-deps
before_cache: &android-before-cache
- CROSS_HOST=aarch64-linux-android ./.travis/android-build-deps
- CROSS_HOST=armv7a-linux-androideabi ./.travis/android-build-deps
before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
cache: &android-cache
cache:
directories:
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/
- $TRAVIS_BUILD_DIR/dependencies
script: &android-script .travis/android-build
before_deploy: &android-before-deploy
script: .travis/android-build
before_deploy:
- mkdir artifacts && cp build-*/android/build/outputs/apk/release/ResidualVM-release-unsigned.apk artifacts
- os: linux
name: "Android ARM"
language: android
android: *android
env:
- ANDROID_TARGET=android-arm-v7a
- ANDROID_ABI=armeabi-v7a
- CROSS_HOST=armv7a-linux-androideabi
- ANDROID_LEVEL=26
- ANDROID_SDK=${ANDROID_HOME}
- ANDROID_NDK=${ANDROID_HOME}/ndk-bundle
before_install: *android-before-install
install: *android-install
before_cache: *android-before-cache
cache: *android-cache
script: *android-script
before_deploy: *android-before-deploy
deploy:
provider: script

View File

@ -1,11 +1,20 @@
#!/bin/sh
set -e
here=$(dirname "$0")
. "$here"/android-set-environment
DEPENDENCIES=$(pwd)/dependencies/$CROSS_HOST
mkdir -p build-${ANDROID_ABI}
cd build-${ANDROID_ABI}
../configure --enable-all-engines --enable-static --enable-opengl-shaders --with-jpeg-prefix=$DEPENDENCIES --with-freetype2-prefix=$DEPENDENCIES --host=${ANDROID_TARGET}
export ANDROID_TARGET_VERSION=${ANDROID_LEVEL}
make -j4 libresidualvm.so
TERM=dumb make androidrelease ABI=${ANDROID_ABI}
# Build both ABIs first
for CROSS_HOST in aarch64-linux-android armv7a-linux-androideabi; do (
echo ">>> Building libresidualvm.so for $CROSS_HOST"
. "$here"/android-set-environment
DEPENDENCIES=$(pwd)/dependencies/$CROSS_HOST
mkdir -p build-${ANDROID_ABI}
cd build-${ANDROID_ABI}
../configure --enable-all-engines --enable-static --enable-opengl-shaders --with-jpeg-prefix=$DEPENDENCIES --with-freetype2-prefix=$DEPENDENCIES --host=${ANDROID_TARGET}
make libresidualvm.so
) || exit 1 ; done
echo ">>> Creating final APK"
# Now copy the ARMv7 one into the ARM64 tree and build the final package from there
ln -s build-arm64-v8a build
install -C -D -m 644 build-armeabi-v7a/libresidualvm.so build/android/jni/armeabi-v7a/libresidualvm.so
TERM=dumb make -C build androidrelease ABI=arm64-v8a

View File

@ -19,7 +19,7 @@ echo ">>> Building libjpeg-turbo for $CROSS_HOST"
pushd libjpeg-turbo
git clean -fdx
autoreconf -fiv
./configure --host=$CROSS_HOST --prefix=$prefix --without-turbojpeg --disable-shared && make -j4 install || false
./configure --host=$CROSS_HOST --prefix=$prefix --without-turbojpeg --disable-shared && make install || false
popd
echo ">>> Building freetype for $CROSS_HOST"
@ -27,7 +27,7 @@ echo ">>> Building freetype for $CROSS_HOST"
pushd freetype
git clean -fdx
sh autogen.sh
./configure --host=$CROSS_HOST --with-harfbuzz=no --with-bzip2=no --with-png=no --prefix=$prefix --disable-shared && make -j4 install || false
./configure --host=$CROSS_HOST --with-harfbuzz=no --with-bzip2=no --with-png=no --prefix=$prefix --disable-shared && make install || false
popd
cp -p .travis/android-freetype-config $prefix/bin/freetype-config

View File

@ -1,12 +1,17 @@
#!/bin/sh
export TOOLCHAIN=$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64
export ANDROID_LEVEL=${ANDROID_LEVEL:-26}
export ANDROID_TARGET_VERSION=${ANDROID_LEVEL}
if [ "$CROSS_HOST" = "armv7a-linux-androideabi" ]; then
export AR=$TOOLCHAIN/bin/arm-linux-androideabi-ar
export RANLIB=$TOOLCHAIN/bin/arm-linux-androideabi-ranlib
export ANDROID_TARGET=android-arm-v7a
export ANDROID_ABI=armeabi-v7a
else
export AR=$TOOLCHAIN/bin/${CROSS_HOST}-ar
export RANLIB=$TOOLCHAIN/bin/${CROSS_HOST}-ranlib
export ANDROID_TARGET=android-arm64-v8a
export ANDROID_ABI=arm64-v8a
fi
export AS=$TOOLCHAIN/bin/${CROSS_HOST}-as
export CC=$TOOLCHAIN/bin/${CROSS_HOST}${ANDROID_LEVEL}-clang
@ -15,3 +20,6 @@ export LD=$TOOLCHAIN/bin/${CROSS_HOST}-ld
export STRIP=$TOOLCHAIN/bin/${CROSS_HOST}-strip
export PATH=$TOOLCHAIN/bin:$ANDROID_NDK:$PATH
export CXXFLAGS=-Wno-inconsistent-missing-override
NPROC=$(nproc 2>/dev/null)
export MAKEFLAGS="-j${NPROC:-4}"

View File

@ -35,11 +35,12 @@ $(PATH_BUILD_JNI): libresidualvm.so
$(INSTALL) -C -D -m 644 libresidualvm.so $(PATH_BUILD_JNI)
$(PATH_BUILD_GRADLE): $(PATH_BUILD_ASSETS) $(PATH_DIST)/build.gradle
@echo "gradle.ext.versionCode = $(ANDROID_VERSIONCODE)" >> $@
$(eval ABIS = $(notdir $(wildcard $(PATH_BUILD)/jni/*)))
@echo "gradle.ext.versionCode = $(ANDROID_VERSIONCODE)" > $@
@echo "gradle.ext.versionName = '$(ANDROID_VERSIONNAME)'" >> $@
@echo "gradle.ext.sourceDir = '$(abspath $(srcdir))'" >> $@
@echo "gradle.ext.buildDir = '$(CURDIR)'" >> $@
@echo "gradle.ext.androidAbi = '$(ABI)'" >> $@
@echo "gradle.ext.androidAbi = '$(ABIS)'" >> $@
@echo "include ':ResidualVM'" >> $@
@echo "project(':ResidualVM').projectDir = new File('$(abspath $(PATH_DIST))')" >> $@
@echo "ndk.dir=$(ANDROID_NDK)" > $(PATH_BUILD)/local.properties

View File

@ -28,7 +28,7 @@ android {
versionCode gradle.versionCode
versionName gradle.versionName
ndk {
abiFilters gradle.androidAbi
abiFilters gradle.androidAbi.split(" ")
}
aaptOptions {
noCompress "zip", "lab"