From bdb9e130bcd8b1ce5f07b66c1e8b413648275d7e Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Wed, 19 Jul 2023 11:56:34 +0200 Subject: [PATCH] [godot] Add mono flag to 4.x build. --- spine-godot/build/build-v4.sh | 43 ++++++++++++++++++++++++++++------- spine-godot/build/setup.sh | 31 +++++++++++++++++++++---- 2 files changed, 61 insertions(+), 13 deletions(-) diff --git a/spine-godot/build/build-v4.sh b/spine-godot/build/build-v4.sh index ef967d5c4f..a39230f32f 100755 --- a/spine-godot/build/build-v4.sh +++ b/spine-godot/build/build-v4.sh @@ -11,6 +11,26 @@ fi target="" dev="false" +mono="false" + +if [ $# -gt 0 ]; then + if [ $# -gt 1 ]; then + echo "Usage: $0 [mono:true|false]" + exit 1 + else + if [ "$1" == "true" ] || [ "$1" == "false" ]; then + mono="$1" + else + echo "Invalid value for the 'mono' argument. It should be either 'true' or 'false'." + exit 1 + fi + fi +fi + +if [ -f "../godot/custom.py" ]; then + dev="true" +fi + if [ -f "../godot/custom.py" ]; then dev="true" fi @@ -26,16 +46,23 @@ fi echo "CPUS: $cpus" +mono_module="" +mono_extension="" +if [ $mono = "true" ]; then + mono_module="module_mono_enabled=yes" + mono_extension=".mono" +fi + pushd ../godot -if [ `uname` == 'Darwin' ] && [ $dev = "false" ]; then - scons $target arch=x86_64 compiledb=yes custom_modules="../spine_godot" opengl3=yes --jobs=$cpus - scons $target arch=arm64 compiledb=yes custom_modules="../spine_godot" opengl3=yes --jobs=$cpus +if [ `uname` == 'Darwin' ] && [ $dev = "false" ]; then + scons $target $mono_module arch=x86_64 compiledb=yes custom_modules="../spine_godot" opengl3=yes --jobs=$cpus + scons $target $mono_module arch=arm64 compiledb=yes custom_modules="../spine_godot" opengl3=yes --jobs=$cpus pushd bin cp -r ../misc/dist/macos_tools.app . mv macos_tools.app Godot.app mkdir -p Godot.app/Contents/MacOS - lipo -create godot.macos.editor.arm64 godot.macos.editor.x86_64 -output Godot + lipo -create godot.macos.editor.arm64$mono_extension godot.macos.editor.x86_64$mono_extension -output Godot strip -S -x Godot cp Godot Godot.app/Contents/MacOS/Godot chmod +x Godot.app/Contents/MacOS/Godot @@ -47,11 +74,11 @@ else if [ "$dev" = "true" ]; then target="$target dev_build=true" fi - scons $target compiledb=yes custom_modules="../spine_godot" opengl3=yes --jobs=$cpus + scons $target $mono_module compiledb=yes custom_modules="../spine_godot" opengl3=yes --jobs=$cpus cp compile_commands.json ../build - if [ -f "bin/godot.linuxbsd.editor.x86_64" ]; then - strip bin/godot.linuxbsd.editor.x86_64 - chmod a+x bin/godot.linuxbsd.editor.x86_64 + if [ -f "bin/godot.linuxbsd.editor.x86_64$mono_extension" ]; then + strip bin/godot.linuxbsd.editor.x86_64$mono_extension + chmod a+x bin/godot.linuxbsd.editor.x86_64$mono_extension fi fi popd diff --git a/spine-godot/build/setup.sh b/spine-godot/build/setup.sh index a48f1a8a44..07be7f1140 100755 --- a/spine-godot/build/setup.sh +++ b/spine-godot/build/setup.sh @@ -4,18 +4,36 @@ set -e dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" pushd "$dir" > /dev/null -if [ ! "$#" -eq 2 ]; then - echo "Usage: ./setup.sh " +if [ $# -lt 2 ] || [ $# -gt 3 ]; then + echo "Usage: ./setup.sh [mono:true|false]?" echo echo "e.g.:" - echo " ./setup.sh 3.4.4-stable true" - echo " ./setup.sh master false" - echo + echo " ./setup.sh 3.5.2-stable true" + echo " ./setup.sh master false true" + echo + echo "Note: the 'mono' parameter only works for Godot 4.x+!" + exit 1 fi branch=${1%/} dev=${2%/} +mono=false + +if [[ $# -eq 3 && "$branch" != 3* ]]; then + mono=${3%/} +fi + +if [ "$dev" != "true" ] && [ "$dev" != "false" ]; then + echo "Invalid value for the 'dev' argument. It should be either 'true' or 'false'." + exit 1 +fi + +if [ "$mono" != "true" ] && [ "$mono" != "false" ]; then + echo "Invalid value for the 'mono' argument. It should be either 'true' or 'false'." + exit 1 +fi + pushd .. rm -rf godot @@ -23,6 +41,9 @@ git clone --depth 1 https://github.com/godotengine/godot.git -b $branch if [ $dev = "true" ]; then cp -r .idea godot cp build/custom.py godot + if [ "$mono" = "true" ]; then + echo "module_mono_enabled=\"yes\"" >> godot/custom.py + fi cp ../formatters/.clang-format . rm -rf example/.import rm -rf example/.godot