Browse Source

[godot] Rework extension build system.

badlogic 9 months ago
parent
commit
72846c46f0

+ 1 - 0
.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

+ 55 - 0
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 <Godot branch or tag> <dev> 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

+ 14 - 11
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 <Godot version> <dev:true|false> <mono:true|false>?"
+    echo "Usage: ./setup-extension.sh <Godot version> <dev:true|false>"
     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
 

+ 18 - 0
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"

+ 3 - 3
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"