Skip to content

Instantly share code, notes, and snippets.

@neikeq
Last active November 12, 2019 22:10
Show Gist options
  • Save neikeq/136a8da388f022ff135565f53c471c68 to your computer and use it in GitHub Desktop.
Save neikeq/136a8da388f022ff135565f53c471c68 to your computer and use it in GitHub Desktop.
Build Godot with Mono for Android. Use together with: https://gist.github.com/neikeq/8f0f4872ab4a07873c35ba4465215344
#!/bin/bash
set -e;
set -o pipefail;
set -x;
: ${GODOT_SOURCE_ROOT:?Variable GODOT_SOURCE_ROOT not set or empty}
: ${MONO_INSTALLS_DIR:=${HOME}/mono-installs}
if [ ! -d "${GODOT_SOURCE_ROOT}" ]; then
echo "ERROR: Directory not found: ${GODOT_SOURCE_ROOT}" 1>&2
exit 1
fi
if [ ! -d "${MONO_INSTALLS_DIR}" ]; then
echo "ERROR: Directory not found: ${MONO_INSTALLS_DIR}" 1>&2
exit 1
fi
# The SCons script expects an absolute path
MONO_INSTALLS_DIR="$( cd "${MONO_INSTALLS_DIR}" >/dev/null 2>&1 && pwd )"
MONO_CONFIGURATION=${MONO_CONFIGURATION:-release}
cd ${GODOT_SOURCE_ROOT};
ANDROID_HOME=${ANDROID_HOME:-${HOME}/Android/Sdk}
ANDROID_NDK_HOME=${ANDROID_NDK_HOME:-${ANDROID_HOME}/ndk-bundle}
ANDROID_NDK_ROOT=${ANDROID_NDK_HOME}
ANDROID_API_VERSION=${ANDROID_API_VERSION:-18}
export ANDROID_HOME ANDROID_NDK_ROOT ANDROID_NDK_HOME
SCONS_NUM_JOBS=${SCONS_NUM_JOBS:-2}
SCONS_VERBOSE=${SCONS_VERBOSE:-yes}
scons_build() {
local SCONS_TARGET=${1}
local TARGET_ARCH=${2}
local SCONS_ANDROID_ARCH=${3}
local MONO_PREFIX=${MONO_INSTALLS_DIR}/android-${TARGET_ARCH}-${MONO_CONFIGURATION}
scons platform=android target=${SCONS_TARGET} tools=no \
android_arch=${SCONS_ANDROID_ARCH} ndk_platform=android-${ANDROID_API_VERSION} \
module_mono_enabled=yes mono_prefix=${MONO_PREFIX} \
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 generateGodotTemplates;
cd ../../..;
set +x;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment