Skip to content

Instantly share code, notes, and snippets.

@neikeq
Created March 11, 2020 18:27
Show Gist options
  • Save neikeq/ca9b0205cdf49aafb59387cb56c4a94d to your computer and use it in GitHub Desktop.
Save neikeq/ca9b0205cdf49aafb59387cb56c4a94d to your computer and use it in GitHub Desktop.
#!/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:-debug}
cd ${GODOT_SOURCE_ROOT};
SCONS_NUM_JOBS=${SCONS_NUM_JOBS:-2}
SCONS_VERBOSE=${SCONS_VERBOSE:-yes}
scons_build() {
local SCONS_TARGET=${1}
local ARCH=${2}
local IOS_TRIPLE=${3}
local MONO_PREFIX=${MONO_INSTALLS_DIR}/ios-${ARCH}-${MONO_CONFIGURATION}
local IPHONESDK=${OSXCROSS_IOS}/${ARCH}/SDK/iPhoneOS${IOS_SDK}.sdk
local IPHONEPATH=${OSXCROSS_IOS}/${ARCH}/
scons platform=iphone target=${SCONS_TARGET} arch=${ARCH} tools=no \
IPHONESDK=${IPHONESDK} IPHONEPATH=${IPHONEPATH} ios_triple=${IOS_TRIPLE} \
module_mono_enabled=yes mono_prefix=${MONO_PREFIX} mono_static=yes \
verbose=${SCONS_VERBOSE} -j ${SCONS_NUM_JOBS}
}
# ARGS: SCONS_TARGET ARCH IOS_TRIPLE
scons_build release_debug arm64 arm-apple-darwin11-
scons_build release arm64 arm-apple-darwin11-
scons_build release_debug x86_64 x86_64-apple-darwin11-
scons_build release x86_64 x86_64-apple-darwin11-
mkdir -p bin/ios
# libgodot
${OSXCROSS_IOS}/arm64/bin/arm-apple-darwin11-lipo -create bin/libgodot.iphone.opt.arm64.a bin/libgodot.iphone.opt.x86_64.a -output bin/ios/libgodot.iphone.opt.fat
${OSXCROSS_IOS}/arm64/bin/arm-apple-darwin11-lipo -create bin/libgodot.iphone.opt.debug.arm64.a bin/libgodot.iphone.opt.debug.x86_64.a -output bin/ios/libgodot.iphone.opt.debug.fat
# libgodot_arkit_module
${OSXCROSS_IOS}/arm64/bin/arm-apple-darwin11-lipo -create bin/libgodot_arkit_module.iphone.opt.arm64.a bin/libgodot_arkit_module.iphone.opt.x86_64.a -output bin/ios/libgodot_arkit_module.iphone.opt.fat
${OSXCROSS_IOS}/arm64/bin/arm-apple-darwin11-lipo -create bin/libgodot_arkit_module.iphone.opt.debug.arm64.a bin/libgodot_arkit_module.iphone.opt.debug.x86_64.a -output bin/ios/libgodot_arkit_module.iphone.opt.debug.fat
# libgodot_camera_module
${OSXCROSS_IOS}/arm64/bin/arm-apple-darwin11-lipo -create bin/libgodot_camera_module.iphone.opt.arm64.a bin/libgodot_camera_module.iphone.opt.x86_64.a -output bin/ios/libgodot_camera_module.iphone.opt.fat
${OSXCROSS_IOS}/arm64/bin/arm-apple-darwin11-lipo -create bin/libgodot_camera_module.iphone.opt.debug.arm64.a bin/libgodot_camera_module.iphone.opt.debug.x86_64.a -output bin/ios/libgodot_camera_module.iphone.opt.debug.fat
# Mono libraries
mkdir -p bin/ios/iphone-mono-libs
${OSXCROSS_IOS}/arm64/bin/arm-apple-darwin11-lipo -create bin/libmonosgen-2.0.iphone.arm64.a bin/libmonosgen-2.0.iphone.x86_64.a -output bin/ios/iphone-mono-libs/libmonosgen-2.0.iphone.fat.a
${OSXCROSS_IOS}/arm64/bin/arm-apple-darwin11-lipo -create bin/libmono-native.iphone.arm64.a bin/libmono-native.iphone.x86_64.a -output bin/ios/iphone-mono-libs/libmono-native.iphone.fat.a
${OSXCROSS_IOS}/arm64/bin/arm-apple-darwin11-lipo -create bin/libmono-profiler-log.iphone.arm64.a bin/libmono-profiler-log.iphone.x86_64.a -output bin/ios/iphone-mono-libs/libmono-profiler-log.iphone.fat.a
# The interpreter Mono libraries are not available for simulator builds
${OSXCROSS_IOS}/arm64/bin/arm-apple-darwin11-lipo -create bin/libmono-ee-interp.iphone.arm64.a -output bin/ios/iphone-mono-libs/libmono-ee-interp.iphone.fat.a
${OSXCROSS_IOS}/arm64/bin/arm-apple-darwin11-lipo -create bin/libmono-icall-table.iphone.arm64.a -output bin/ios/iphone-mono-libs/libmono-icall-table.iphone.fat.a
${OSXCROSS_IOS}/arm64/bin/arm-apple-darwin11-lipo -create bin/libmono-ilgen.iphone.arm64.a -output bin/ios/iphone-mono-libs/libmono-ilgen.iphone.fat.a
# Package iOS export templates
TOP="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
cd $TOP
rm -rf $TOP/bin/ios/ios_xcode
cp -r $TOP/misc/dist/ios_xcode $TOP/bin/ios/ios_xcode
for suffix in "" "_arkit_module" "_camera_module"; do
cp $TOP/bin/ios/libgodot${suffix}.iphone.opt.fat $TOP/bin/ios/ios_xcode/libgodot${suffix}.iphone.release.fat.a
cp $TOP/bin/ios/libgodot${suffix}.iphone.opt.debug.fat $TOP/bin/ios/ios_xcode/libgodot${suffix}.iphone.debug.fat.a
done
chmod +x $TOP/bin/ios/ios_xcode/libgodot*.iphone.*
cd $TOP/bin/ios/ios_xcode
zip -q -9 -r "$TOP/bin/ios/iphone.zip" *
cd ..
rm -rf $TOP/bin/ios/ios_xcode
echo "Done!"
set +x;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment