Last active
June 3, 2019 21:30
-
-
Save neikeq/b8b62075f0032efd67355ce7e7246266 to your computer and use it in GitHub Desktop.
Bash scripts to build Godot with Mono for Android
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e; | |
set -o pipefail; | |
set -x; | |
: ${GODOT_SOURCE_ROOT:?Variable GODOT_SOURCE_ROOT not set or empty} | |
: ${MONO_SOURCE_ROOT:?Variable MONO_SOURCE_ROOT not set or empty} | |
# The SCons script expects an absolute path | |
MONO_SOURCE_ROOT="$( cd "${MONO_SOURCE_ROOT}" >/dev/null 2>&1 && pwd )" | |
cd ${GODOT_SOURCE_ROOT}; | |
ANDROID_TOOLCHAIN_DIR=${ANDROID_TOOLCHAIN_DIR:-${HOME}/Android/Toolchain} | |
ANDROID_HOME=${ANDROID_HOME:-${ANDROID_TOOLCHAIN_DIR}/sdk} | |
ANDROID_NDK_ROOT=${ANDROID_NDK_ROOT:-${ANDROID_TOOLCHAIN_DIR}/ndk} | |
ANDROID_NDK_HOME=${ANDROID_NDK_HOME:-${ANDROID_NDK_ROOT}} | |
MONO_VERSION=${MONO_VERSION:-5.20} | |
export ANDROID_HOME ANDROID_NDK_ROOT ANDROID_NDK_HOME MONO_VERSION | |
SCONS_NUM_JOBS=${SCONS_NUM_JOBS:-3} | |
SCONS_MONO_STATIC=${SCONS_MONO_STATIC:-yes} | |
SCONS_VERBOSE=${SCONS_VERBOSE:-yes} | |
scons_build() { | |
local SCONS_TARGET=${1} | |
local TARGET_ARCH=${2} | |
local SCONS_ANDROID_ARCH=${3} | |
local MONO_PREFIX=${MONO_SOURCE_ROOT}/sdks/out/android-${TARGET_ARCH}-release | |
scons platform=android target=${SCONS_TARGET} tools=no android_arch=${SCONS_ANDROID_ARCH} \ | |
module_mono_enabled=yes mono_prefix=${MONO_PREFIX} mono_static=${SCONS_MONO_STATIC} \ | |
verbose=${SCONS_VERBOSE} -j ${SCONS_NUM_JOBS} | |
} | |
# ARGS: SCONS_TARGET TARGET_ARCH SCONS_ANDROID_ARCH | |
scons_build release_debug armeabi-v7a armv7 | |
scons_build release armeabi-v7a armv7 | |
scons_build release_debug arm64-v8a arm64v8 | |
scons_build release arm64-v8a arm64v8 | |
scons_build release_debug x86 x86 | |
scons_build release x86 x86 | |
scons_build release_debug x86_64 x86_64 | |
scons_build release x86_64 x86_64 | |
cd platform/android/java; | |
./gradlew clean; | |
./gradlew build; | |
cd ../../..; | |
set +x; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e; | |
set -o pipefail; | |
set -x; | |
: ${MONO_SOURCE_ROOT:?Variable MONO_SOURCE_ROOT not set or empty} | |
cd ${MONO_SOURCE_ROOT} | |
# We're using the sdk makefiles distributed with Mono. In the future we may want to | |
# write our own configuration to get rid of the stuff we don't need and reducing size. | |
# We are not using the cross templates for now, so you can comment out the calls | |
# to the AndroidCross* functions in '${MONO_SOURCE_ROOT}/sdks/builds/android.mk'. | |
ANDROID_TOOLCHAIN_DIR=${ANDROID_TOOLCHAIN_DIR:-${HOME}/Android/Toolchain} | |
ANDROID_TOOLCHAIN_CACHE_DIR=${ANDROID_TOOLCHAIN_CACHE_DIR:-${ANDROID_TOOLCHAIN_DIR}/android-archives} | |
ANDROID_TOOLCHAIN_PREFIX=${ANDROID_TOOLCHAIN_PREFIX:-${ANDROID_TOOLCHAIN_DIR}/toolchains} | |
if [ ! -d ${ANDROID_TOOLCHAIN_DIR}/sdk ]; then | |
echo Directory not found ${ANDROID_TOOLCHAIN_DIR}/sdk | |
exit 1 | |
fi | |
if [ ! -d ${ANDROID_TOOLCHAIN_DIR}/ndk ]; then | |
echo Directory not found ${ANDROID_TOOLCHAIN_DIR}/ndk | |
exit 1 | |
fi | |
export ANDROID_TOOLCHAIN_DIR ANDROID_TOOLCHAIN_CACHE_DIR ANDROID_TOOLCHAIN_PREFIX | |
MAKE_NUM_JOBS=${MAKE_NUM_JOBS:-2} | |
echo " | |
DISABLE_IOS = 1 | |
DISABLE_MAC = 1 | |
DISABLE_WASM = 1 | |
DISABLE_WASM_CROSS = 1 | |
DISABLE_BCL = 1 | |
DISABLE_DESKTOP = 1 | |
DISABLE_LLVM = 1 | |
" > ${MONO_SOURCE_ROOT}/sdks/Make.config | |
make -C sdks/builds provision-mxe | |
make -C sdks/builds archive-android NINJA= IGNORE_PROVISION_ANDROID=1 IGNORE_PROVISION_MXE=1 -j ${MAKE_NUM_JOBS} | |
strip_libs() { | |
local TARGET_ARCH=${1} | |
local ABI_NAME=${2} | |
local OUTPUT_LIB_DIR=${MONO_SOURCE_ROOT}/sdks/out/android-${TARGET_ARCH}-release/lib | |
${ANDROID_TOOLCHAIN_PREFIX}/${TARGET_ARCH}-clang/bin/${ABI_NAME}-strip --strip-unneeded ${OUTPUT_LIB_DIR}/*.a ${OUTPUT_LIB_DIR}/*.so | |
} | |
# ARGS: TARGET_ARCH ABI_NAME | |
strip_libs armeabi-v7a arm-linux-androideabi | |
strip_libs arm64-v8a aarch64-linux-android | |
strip_libs x86 i686-linux-android | |
strip_libs x86_64 x86_64-linux-android | |
set +x; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment