mirror of
https://github.com/godotengine/godot-build-scripts.git
synced 2026-01-05 06:11:49 +03:00
Backport of #89 and #90, in sync with https://github.com/godotengine/build-containers/pull/135. In the 3.x branch, the situation with `arch` and `bits` is very brittle, so we only add the explicit `arch` argument for the arm32/arm64 builds. x86_32 still relies on `bits=32`. This would all be worth refactoring upstream like we did for 4.0, but it's a major undertaking and breaking change, which I'd prefer to avoid in 3.6. For Linux builds, we move the `strip` calls to the link stage, as this needs to be done with the arch-appropriate `strip` binary, so it's easier done there. In `master`, we now let the compiler strip automatically during the build if no debug symbols are requested, but this change wasn't backported to 3.x.
100 lines
4.5 KiB
Bash
Executable File
100 lines
4.5 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
# Config
|
|
|
|
export SCONS="scons -j${NUM_CORES} verbose=yes warnings=no progress=no"
|
|
export OPTIONS="osxcross_sdk=darwin23 production=yes"
|
|
export OPTIONS_MONO="module_mono_enabled=yes mono_static=yes"
|
|
export MONO_PREFIX_X86_64="/root/mono-installs/desktop-osx-x86_64-release"
|
|
export MONO_PREFIX_ARM64="/root/mono-installs/desktop-osx-arm64-release"
|
|
export STRIP="x86_64-apple-darwin23-strip -u -r"
|
|
export TERM=xterm
|
|
|
|
rm -rf godot
|
|
mkdir godot
|
|
cd godot
|
|
tar xf /root/godot.tar.gz --strip-components=1
|
|
|
|
# Classical
|
|
|
|
if [ "${CLASSICAL}" == "1" ]; then
|
|
echo "Starting classical build for macOS..."
|
|
|
|
$SCONS platform=osx $OPTIONS arch=x86_64 tools=yes target=release_debug
|
|
$SCONS platform=osx $OPTIONS arch=arm64 tools=yes target=release_debug
|
|
lipo -create bin/godot.osx.opt.tools.x86_64 bin/godot.osx.opt.tools.arm64 -output bin/godot.osx.opt.tools.universal
|
|
$STRIP bin/godot.osx.opt.tools.universal
|
|
|
|
mkdir -p /root/out/tools
|
|
cp -rvp bin/* /root/out/tools
|
|
rm -rf bin
|
|
|
|
$SCONS platform=osx $OPTIONS arch=x86_64 tools=no target=release_debug
|
|
$SCONS platform=osx $OPTIONS arch=arm64 tools=no target=release_debug
|
|
lipo -create bin/godot.osx.opt.debug.x86_64 bin/godot.osx.opt.debug.arm64 -output bin/godot.osx.opt.debug.universal
|
|
$STRIP bin/godot.osx.opt.debug.universal
|
|
$SCONS platform=osx $OPTIONS arch=x86_64 tools=no target=release
|
|
$SCONS platform=osx $OPTIONS arch=arm64 tools=no target=release
|
|
lipo -create bin/godot.osx.opt.x86_64 bin/godot.osx.opt.arm64 -output bin/godot.osx.opt.universal
|
|
$STRIP bin/godot.osx.opt.universal
|
|
|
|
mkdir -p /root/out/templates
|
|
cp -rvp bin/* /root/out/templates
|
|
rm -rf bin
|
|
fi
|
|
|
|
# Mono
|
|
|
|
if [ "${MONO}" == "1" ]; then
|
|
echo "Starting Mono build for macOS..."
|
|
|
|
cp /root/mono-glue/*.cpp modules/mono/glue/
|
|
cp -r /root/mono-glue/GodotSharp/GodotSharp/Generated modules/mono/glue/GodotSharp/GodotSharp/
|
|
cp -r /root/mono-glue/GodotSharp/GodotSharpEditor/Generated modules/mono/glue/GodotSharp/GodotSharpEditor/
|
|
|
|
# Note: A bit of dylib wrangling involved as x86_64 and arm64 builds both generate GodotSharp
|
|
# so the second build overrides the first, but we need to lipo the libs to make them universal.
|
|
# We also need to ensure that /etc/mono/config has the proper filenames (keep arm64 as the last
|
|
# build so that we rely on its config, which has libmono-native.dylib instead of
|
|
# libmono-native-compat.dylib).
|
|
mkdir -p tmp-lib/{x86_64,arm64}
|
|
|
|
$SCONS platform=osx $OPTIONS $OPTIONS_MONO mono_prefix=$MONO_PREFIX_X86_64 arch=x86_64 tools=yes target=release_debug copy_mono_root=yes
|
|
cp bin/GodotSharp/Mono/lib/*.dylib tmp-lib/x86_64/
|
|
$SCONS platform=osx $OPTIONS $OPTIONS_MONO mono_prefix=$MONO_PREFIX_ARM64 arch=arm64 tools=yes target=release_debug copy_mono_root=yes
|
|
cp bin/GodotSharp/Mono/lib/*.dylib tmp-lib/arm64/
|
|
lipo -create bin/godot.osx.opt.tools.x86_64.mono bin/godot.osx.opt.tools.arm64.mono -output bin/godot.osx.opt.tools.universal.mono
|
|
$STRIP bin/godot.osx.opt.tools.universal.mono
|
|
|
|
# Make universal versions of the dylibs we use.
|
|
lipo -create tmp-lib/x86_64/libmono-native.dylib tmp-lib/arm64/libmono-native.dylib -output tmp-lib/libmono-native.dylib
|
|
lipo -create tmp-lib/x86_64/libMonoPosixHelper.dylib tmp-lib/arm64/libMonoPosixHelper.dylib -output tmp-lib/libMonoPosixHelper.dylib
|
|
lipo -create tmp-lib/x86_64/libmono-btls-shared.dylib tmp-lib/arm64/libmono-btls-shared.dylib -output tmp-lib/libmono-btls-shared.dylib
|
|
|
|
cp -f tmp-lib/*.dylib bin/GodotSharp/Mono/lib/
|
|
|
|
mkdir -p /root/out/tools-mono
|
|
cp -rvp bin/* /root/out/tools-mono
|
|
rm -rf bin
|
|
|
|
$SCONS platform=osx $OPTIONS $OPTIONS_MONO mono_prefix=$MONO_PREFIX_X86_64 arch=x86_64 tools=no target=release_debug
|
|
$SCONS platform=osx $OPTIONS $OPTIONS_MONO mono_prefix=$MONO_PREFIX_ARM64 arch=arm64 tools=no target=release_debug
|
|
lipo -create bin/godot.osx.opt.debug.x86_64.mono bin/godot.osx.opt.debug.arm64.mono -output bin/godot.osx.opt.debug.universal.mono
|
|
$STRIP bin/godot.osx.opt.debug.universal.mono
|
|
$SCONS platform=osx $OPTIONS $OPTIONS_MONO mono_prefix=$MONO_PREFIX_X86_64 arch=x86_64 tools=no target=release
|
|
$SCONS platform=osx $OPTIONS $OPTIONS_MONO mono_prefix=$MONO_PREFIX_ARM64 arch=arm64 tools=no target=release
|
|
lipo -create bin/godot.osx.opt.x86_64.mono bin/godot.osx.opt.arm64.mono -output bin/godot.osx.opt.universal.mono
|
|
$STRIP bin/godot.osx.opt.universal.mono
|
|
|
|
cp -f tmp-lib/*.dylib bin/data.mono.osx.64.release/Mono/lib/
|
|
cp -f tmp-lib/*.dylib bin/data.mono.osx.64.release_debug/Mono/lib/
|
|
|
|
mkdir -p /root/out/templates-mono
|
|
cp -rvp bin/* /root/out/templates-mono
|
|
rm -rf bin
|
|
fi
|
|
|
|
echo "macOS build successful"
|