From 72846c46f057fceffebb31eb7cbc184d981deb41 Mon Sep 17 00:00:00 2001 From: badlogic Date: Tue, 10 Dec 2024 15:45:17 +0100 Subject: [PATCH] [godot] Rework extension build system. --- .gitignore | 1 + spine-godot/build/build-extension.sh | 55 +++++++++++++++++++ spine-godot/build/setup-extension.sh | 25 +++++---- .../spine_godot_extension.dev.gdextension | 18 ++++++ spine-godot/spine_godot_extension.gdextension | 6 +- 5 files changed, 91 insertions(+), 14 deletions(-) create mode 100644 spine-godot/build/build-extension.sh create mode 100644 spine-godot/spine_godot_extension.dev.gdextension diff --git a/.gitignore b/.gitignore index 44fc44069..e38d0973b 100644 --- a/.gitignore +++ b/.gitignore @@ -216,3 +216,4 @@ spine-godot/bin spine-godot/example-v4-extension/bin/macos/macos.framework/libspine_godot.macos.editor spine-godot/.idea spine-godot/build/version.txt +spine-godot/vc140.pdb diff --git a/spine-godot/build/build-extension.sh b/spine-godot/build/build-extension.sh new file mode 100644 index 000000000..4574d73ee --- /dev/null +++ b/spine-godot/build/build-extension.sh @@ -0,0 +1,55 @@ +#!/bin/bash +set -e + +dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" +pushd "$dir" > /dev/null + +if [ ! -d ../godot-cpp ]; then + echo "No godot-cpp clone found. Run ./setup-extension.sh first." + exit 1 +fi + +options="" +dev="false" +platform=${1%/} + +if [ -f "../godot-cpp/dev" ]; then + dev="true" + echo "DEV build" +fi + +if [ $dev == "true" ]; then + options="$options dev_build=true" +fi + +if [ -z $platform ]; then + echo "Platform: current" +else + echo "Platform: $platform" + platform="platform=$platform" +fi + +cpus=2 +if [ "$OSTYPE" == "msys" ]; then + os="windows" + cpus=$NUMBER_OF_PROCESSORS +elif [[ "$OSTYPE" == "darwin"* ]]; then + os="macos" + cpus=$(sysctl -n hw.logicalcpu) + if [ `uname -m` == "arm64" ]; then + echo "Would do Apple Silicon specific setup" + fi +else + os="linux" + cpus=$(grep -c ^processor /proc/cpuinfo) +fi + +echo "CPUS: $cpus" + +pushd .. +scons -j $cpus $options $platform target=editor +scons -j $cpus $options $platform target=template_debug +scons -j $cpus $options $platform target=template_release +popd + +popd \ No newline at end of file diff --git a/spine-godot/build/setup-extension.sh b/spine-godot/build/setup-extension.sh index c66e02e49..882944b7c 100755 --- a/spine-godot/build/setup-extension.sh +++ b/spine-godot/build/setup-extension.sh @@ -5,7 +5,7 @@ dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" pushd "$dir" > /dev/null if [ $# -lt 2 ] || [ $# -gt 3 ]; then - echo "Usage: ./setup-extension.sh ?" + echo "Usage: ./setup-extension.sh " echo echo "e.g.:" echo " ./setup-extension.sh 4.2.2-stable true" @@ -53,17 +53,20 @@ echo "cpus: $cpus" pushd .. rm -rf godot-cpp -git clone $godot_cpp_repo -pushd godot-cpp -git checkout $godot_cpp_branch -popd +git clone --depth 1 $godot_cpp_repo -b $godot_cpp_branch -rm -rf godot -git clone $godot_repo -pushd godot -git checkout $godot_branch -scons target=editor dev_build=true optimize=debug --jobs=$cpus -popd +if [ $dev == "true" ]; then + echo "Dev build, creating godot-cpp/dev" + touch godot-cpp/dev + rm -rf godot + git clone --depth 1 $godot_repo -b $godot_branch + pushd godot + scons target=editor dev_build=true optimize=debug --jobs=$cpus + popd + cp spine_godot_extension.dev.gdextension example-v4-extension/bin/spine_godot_extension.gdextension +else + cp spine_godot_extension.gdextension example-v4-extension/bin +fi cp -r ../spine-cpp/spine-cpp spine_godot diff --git a/spine-godot/spine_godot_extension.dev.gdextension b/spine-godot/spine_godot_extension.dev.gdextension new file mode 100644 index 000000000..d4d2d8495 --- /dev/null +++ b/spine-godot/spine_godot_extension.dev.gdextension @@ -0,0 +1,18 @@ +[configuration] + +entry_symbol = "spine_godot_library_init" +compatibility_minimum = "4.1" + +[libraries] + +macos.editor = "res://bin/macos/macos.framework/libspine_godot.macos.dev.editor" +macos.debug = "res://bin/macos/macos.framework/libspine_godot.macos.dev.template_debug" +macos.release = "res://bin/macos/macos.framework/libspine_godot.macos.template_release" + +windows.editor.x86_64 = "res://bin/windows/libspine_godot.windows.editor.dev.x86_64.dll" +windows.debug.x86_64 = "res://bin/windows/libspine_godot.windows.template_debug.dev.x86_64.dll" +windows.release.x86_64 = "res://bin/windows/libspine_godot.windows.template_release.dev.x86_64.dll" + +linux.editor.x86_64 = "res://bin/linux/libspine_godot.linux.editor.dev.x86_64.so" +linux.debug.x86_64 = "res://bin/linux/libspine_godot.linux.template_debug.dev.x86_64.so" +linux.release.x86_64 = "res://bin/linux/libspine_godot.linux.template_release.dev.x86_64.so" \ No newline at end of file diff --git a/spine-godot/spine_godot_extension.gdextension b/spine-godot/spine_godot_extension.gdextension index 7c82eb754..d618c2892 100644 --- a/spine-godot/spine_godot_extension.gdextension +++ b/spine-godot/spine_godot_extension.gdextension @@ -12,9 +12,9 @@ macos.release = "res://bin/macos/macos.framework/libspine_godot.macos.template_r ios.debug = "res://bin/ios/ios.framework/libspine_godot.ios.template_debug" ios.release = "res://bin/ios/ios.framework/libspine_godot.ios.template_release" -windows.editor.x86_32 = "res://bin/windows/libspine_godot.windows.editor.x86_32.dll" -windows.debug.x86_32 = "res://bin/windows/libspine_godot.windows.template_debug.x86_32.dll" -windows.release.x86_32 = "res://bin/windows/libspine_godot.windows.template_release.x86_32.dll" +windows.editor.dev.x86_64 = "res://bin/windows/libspine_godot.windows.editor.dev.x86_64.dll" +windows.debug.dev.x86_64 = "res://bin/windows/libspine_godot.windows.template_debug.dev.x86_64.dll" +windows.release.dev.x86_64 = "res://bin/windows/libspine_godot.windows.template_release.dev.x86_64.dll" windows.editor.x86_64 = "res://bin/windows/libspine_godot.windows.editor.x86_64.dll" windows.debug.x86_64 = "res://bin/windows/libspine_godot.windows.template_debug.x86_64.dll"