diff options
author | Cl1608Ho <cl1608ho@gmail.com> | 2016-11-19 20:36:42 +0100 |
---|---|---|
committer | Alexander Harkness <me@bearbin.net> | 2016-12-12 15:32:32 +0100 |
commit | 83ff2e93483b34942fafdc43cde2f0e2000ce6ed (patch) | |
tree | 0c6442ea1b925d21c19cb0fbdb299c692904c92b /android | |
parent | Documented steps for compilation (diff) | |
download | cuberite-83ff2e93483b34942fafdc43cde2f0e2000ce6ed.tar cuberite-83ff2e93483b34942fafdc43cde2f0e2000ce6ed.tar.gz cuberite-83ff2e93483b34942fafdc43cde2f0e2000ce6ed.tar.bz2 cuberite-83ff2e93483b34942fafdc43cde2f0e2000ce6ed.tar.lz cuberite-83ff2e93483b34942fafdc43cde2f0e2000ce6ed.tar.xz cuberite-83ff2e93483b34942fafdc43cde2f0e2000ce6ed.tar.zst cuberite-83ff2e93483b34942fafdc43cde2f0e2000ce6ed.zip |
Diffstat (limited to '')
-rwxr-xr-x | android/compile.sh | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/android/compile.sh b/android/compile.sh new file mode 100755 index 000000000..c10731a7f --- /dev/null +++ b/android/compile.sh @@ -0,0 +1,100 @@ +#!/bin/bash + +# This script cross-compiles cuberite for the android platform. It uses +# the following enviroment variables +# CMAKE: Should be the path to a cmake executable of version 3.7+ +# NDK: Should be the path to the android ndk root +# (optional) TYPE: either Release or Debug, sets the build type +# (optional) THREADS: The number of threads to use, default 4 + +function usage() { + echo "Usage: NDK=<path-to-ndk> CMAKE=<cmake-binary> $0 (clean|<ABI>)"; + exit 1 +} + +BASEDIR="$(realpath $(dirname $0))" +SELF="./$(basename $0)" + +# Clean doesn't need CMAKE and NDK, so it's handled here +if [ "$1" == "clean" ]; then + cd $BASEDIR + rm -rf ../android-build/ + exit 0 +fi + +if [ -z "$CMAKE" -o -z "$NDK" ];then + usage; +fi + +# CMake wants absolute path +CMAKE="$(realpath $CMAKE)" +NDK="$(realpath $NDK)" + +if [ -z "$TYPE" ]; then + TYPE="Release" +fi + +if [ -z "$THREADS" ]; then + THREADS="4" +fi + +cd $BASEDIR + +case "$1" in + armeabi) + APILEVEL=16 + ;; + + armeabi-v7a) + APILEVEL=16 + ;; + + arm64-v8a) + APILEVEL=21 + ;; + + mips) + APILEVEL=16 + ;; + + mips64) + APILEVEL=21 + ;; + + x86) + APILEVEL=16 + ;; + + x86_64) + APILEVEL=21 + ;; + + all) + echo "Packing server.zip" + mkdir -p Server + cd ../Server + zip -r ../android/Server/server.zip * + + for arch in armeabi armeabi-v7a arm64-v8a mips mips64 x86 x86_64; do + echo "Doing ... $arch ..." && \ + cd $BASEDIR && \ + "$SELF" clean && \ + "$SELF" "$arch" && \ + cd Server && \ + zip "$arch".zip Cuberite && \ + rm Cuberite + done + + echo "Done! The built zip files await you in the Server/ directory" + exit; + ;; + + *) + usage; + ;; +esac + +mkdir -p ../android-build +cd ../android-build +"$CMAKE" ../android -DCMAKE_SYSTEM_NAME=Android -DCMAKE_SYSTEM_VERSION="$APILEVEL" -DCMAKE_BUILD_TYPE="$TYPE" -DCMAKE_ANDROID_ARCH_ABI="$1" -DCMAKE_ANDROID_NDK="$NDK" +make -j "$THREADS" |