diff --git a/spine-godot/.vscode/launch.json b/spine-godot/.vscode/launch.json index c26dd235a..50dcdd124 100644 --- a/spine-godot/.vscode/launch.json +++ b/spine-godot/.vscode/launch.json @@ -36,17 +36,14 @@ "program": "godot/bin/godot.windows.editor.dev.x86_64.exe", "args": ["-e", "--path", "example-v4-extension"], "cwd": "${workspaceFolder}", + "preLaunchTask": "build-extension", "linux": { "type": "lldb", - "request": "launch", - "name": "debug editor extension", "program": "${workspaceFolder}/godot/bin/godot.linux.editor.dev.x86_64" }, "osx": { "type": "lldb", - "request": "launch", - "name": "debug editor extension", - "program": "/Applications/Godot 4.3 Debug.app/Contents/MacOS/Godot" + "program": "${workspaceFolder}/godot/bin/godot.macos.editor.dev.arm64" } }, { diff --git a/spine-godot/.vscode/settings.json b/spine-godot/.vscode/settings.json index 7c184d712..05c009d72 100644 --- a/spine-godot/.vscode/settings.json +++ b/spine-godot/.vscode/settings.json @@ -1,20 +1,11 @@ { "cmake.configureOnOpen": false, "C_Cpp.intelliSenseEngine": "default", + "C_Cpp.default.browse.path": [ + "${workspaceFolder}" + ], "dotnet.defaultSolution": "disable", "files.associations": { - "__bit_reference": "cpp", - "__hash_table": "cpp", - "__tree": "cpp", - "map": "cpp", - "set": "cpp", - "string": "cpp", - "string_view": "cpp", - "unordered_map": "cpp", - "unordered_set": "cpp", - "vector": "cpp", - "__split_buffer": "cpp", - "deque": "cpp", - "list": "cpp" + "*.inc": "cpp" } } diff --git a/spine-godot/.vscode/tasks.json b/spine-godot/.vscode/tasks.json index bb0801ff1..23214a998 100644 --- a/spine-godot/.vscode/tasks.json +++ b/spine-godot/.vscode/tasks.json @@ -30,6 +30,30 @@ ] }, }, + { + "label": "build-extension", + "group": "build", + "type": "shell", + "command": "scons", + "options": { + "cwd": "${workspaceFolder}" + }, + "args": [ + "-j", + "16", + "target=editor", + "dev_build=yes", + ], + "problemMatcher": "$msCompile", + "windows": { + "args": [ + "-j", + "16", + "target=editor", + "dev_build=yes", + ] + }, + }, { "label": "build-v3", "group": "build", diff --git a/spine-godot/CMakeLists.txt b/spine-godot/CMakeLists.txt deleted file mode 100644 index 453df922a..000000000 --- a/spine-godot/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ -cmake_minimum_required(VERSION 3.14) - -project(spine_godot_extension) - -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_EXPORT_COMPILE_COMMANDS ON) - -file(GLOB INCLUDES "spine_godot/**/*.h") -file(GLOB SOURCES "spine_godot/*.cpp") -string(REPLACE ";" "\n" SOURCES_LIST "${SOURCES}") -message(STATUS "Source files:\n${SOURCES_LIST}") - -include_directories( - spine_godot - spine_godot/spine-cpp/include - godot-cpp/gdextension - godot-cpp/include - godot-cpp/gen/include -) - -add_library(spine_godot_extension SHARED ${SOURCES}) -target_compile_definitions(spine_godot_extension PRIVATE SPINE_GODOT_EXTENSION) - -# Link Godot's GDExtension API -target_link_libraries(spine_godot_extension PRIVATE godot-cpp) diff --git a/spine-godot/build/livepp-v4.patch b/spine-godot/build/livepp-v4.patch deleted file mode 100644 index bd651d320..000000000 --- a/spine-godot/build/livepp-v4.patch +++ /dev/null @@ -1,127 +0,0 @@ -diff --git a/methods.py b/methods.py -index 7ede259..4e0b2e6 100644 ---- a/methods.py -+++ b/methods.py -@@ -809,6 +809,7 @@ def generate_vs_project(env, num_jobs): - "platform=windows", - f"target={configuration_getter}", - "progress=no", -+ "livepp=%s" % env["livepp"], - "-j%s" % num_jobs, - ] - -diff --git a/platform/windows/detect.py b/platform/windows/detect.py -index 1b55574..8bc0fb1 100644 ---- a/platform/windows/detect.py -+++ b/platform/windows/detect.py -@@ -164,7 +164,7 @@ def detect_build_env_arch(): - - - def get_opts(): -- from SCons.Variables import BoolVariable, EnumVariable -+ from SCons.Variables import BoolVariable, EnumVariable, PathVariable - - mingw = os.getenv("MINGW_PREFIX", "") - -@@ -189,6 +189,7 @@ def get_opts(): - BoolVariable("use_static_cpp", "Link MinGW/MSVC C++ runtime libraries statically", True), - BoolVariable("use_asan", "Use address sanitizer (ASAN)", False), - BoolVariable("debug_crt", "Compile with MSVC's debug CRT (/MDd)", False), -+ PathVariable("livepp", "Path to the Live++ installation", "", PathVariable.PathAccept), - ] - - -@@ -458,6 +459,21 @@ def configure_msvc(env, vcvars_msvc_config): - - env.AppendUnique(LINKFLAGS=["/STACK:" + str(STACK_SIZE)]) - -+ # Check if LIVEPP_PATH is set and add #define. Perform -+ # some sanity checks. -+ if env.get("livepp"): -+ if env["target"] == "editor": -+ if os.path.exists(env.get("livepp")): -+ print("Found Live++ at %s" % env.get("livepp")) -+ env.AppendUnique(CPPDEFINES=["LIVEPP_PATH=%s" % env.get("livepp")]) -+ env.AppendUnique(CPPPATH=[env.get("livepp")]) -+ env.AppendUnique(LINKFLAGS=["/FUNCTIONPADMIN"]) -+ else: -+ print("Specified Live++ path does not exist") -+ else: -+ print("Live++ can only be used with targets 'editor'") -+ else: -+ print("No Live++ specified.") - - def configure_mingw(env): - # Workaround for MinGW. See: -diff --git a/platform/windows/godot_windows.cpp b/platform/windows/godot_windows.cpp -index a26d3ba..8b8e2a8 100644 ---- a/platform/windows/godot_windows.cpp -+++ b/platform/windows/godot_windows.cpp -@@ -34,6 +34,11 @@ - #include - #include - -+#ifdef LIVEPP_PATH -+#include "API/LPP_API.h" -+HMODULE livePP; -+#endif -+ - // For export templates, add a section; the exporter will patch it to enclose - // the data appended to the executable (bundled PCK) - #ifndef TOOLS_ENABLED -@@ -149,6 +154,16 @@ char *wc_to_utf8(const wchar_t *wc) { - } - - int widechar_main(int argc, wchar_t **argv) { -+#ifdef LIVEPP_PATH -+#define _MKSTR_L(x) _STR_L(x) -+#define _STR_L(x) L#x -+ livePP = lpp::lppLoadAndRegister(_MKSTR_L(LIVEPP_PATH), "Godot"); -+ lpp::lppEnableAllCallingModulesSync(livePP); -+ lpp::lppInstallExceptionHandler(livePP); -+#undef _MKSTR_L -+#undef _STR_L -+#endif -+ - OS_Windows os(nullptr); - - setlocale(LC_CTYPE, ""); -@@ -185,6 +200,11 @@ int widechar_main(int argc, wchar_t **argv) { - } - delete[] argv_utf8; - -+#ifdef LIVEPP_PATH -+ lpp::lppShutdown(livePP); -+ ::FreeLibrary(livePP); -+#endif -+ - return os.get_exit_code(); - } - -diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp -index 08299d9..362de3b 100644 ---- a/platform/windows/os_windows.cpp -+++ b/platform/windows/os_windows.cpp -@@ -55,6 +55,11 @@ - #include - #include - -+#ifdef LIVEPP_PATH -+#include "API/LPP_API.h" -+extern HMODULE livePP; -+#endif -+ - extern "C" { - __declspec(dllexport) DWORD NvOptimusEnablement = 1; - __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1; -@@ -1296,6 +1301,10 @@ void OS_Windows::run() { - if (Main::iteration()) { - break; - } -+ -+#ifdef LIVEPP_PATH -+ lpp::lppSyncPoint(livePP); -+#endif - } - - main_loop->finalize(); diff --git a/spine-godot/build/livepp.patch b/spine-godot/build/livepp.patch deleted file mode 100644 index 42b0f7d97..000000000 --- a/spine-godot/build/livepp.patch +++ /dev/null @@ -1,127 +0,0 @@ -diff --git a/methods.py b/methods.py -index 436fe63..d6c81b9 100644 ---- a/methods.py -+++ b/methods.py -@@ -782,6 +782,7 @@ def generate_vs_project(env, num_jobs): - f"target={configuration_getter}", - "progress=no", - "tools=!tools!", -+ "livepp=%s" % env["livepp"], - "-j%s" % num_jobs, - ] - -diff --git a/platform/windows/detect.py b/platform/windows/detect.py -index e6829ae..3a7e38d 100644 ---- a/platform/windows/detect.py -+++ b/platform/windows/detect.py -@@ -44,7 +44,7 @@ def can_build(): - - - def get_opts(): -- from SCons.Variables import BoolVariable, EnumVariable -+ from SCons.Variables import BoolVariable, EnumVariable, PathVariable - - mingw32 = "" - mingw64 = "" -@@ -73,6 +73,7 @@ def get_opts(): - BoolVariable("use_thinlto", "Use ThinLTO", False), - BoolVariable("use_static_cpp", "Link MinGW/MSVC C++ runtime libraries statically", True), - BoolVariable("use_asan", "Use address sanitizer (ASAN)", False), -+ PathVariable("livepp", "Path to the Live++ installation", "", PathVariable.PathAccept), - ] - - -@@ -305,6 +306,22 @@ def configure_msvc(env, manual_msvc_config): - - env.AppendUnique(LINKFLAGS=["/STACK:" + str(STACK_SIZE)]) - -+ # Check if LIVEPP_PATH is set and add #define. Perform -+ # some sanity checks. -+ if env.get("livepp"): -+ if env["target"] == "release_debug" or env["target"] == "debug": -+ if os.path.exists(env.get("livepp")): -+ print("Found Live++ at %s" % env.get("livepp")) -+ env.AppendUnique(CPPDEFINES=["LIVEPP_PATH=%s" % env.get("livepp")]) -+ env.AppendUnique(CPPPATH=[env.get("livepp")]) -+ env.AppendUnique(LINKFLAGS=["/FUNCTIONPADMIN"]) -+ else: -+ print("Specified Live++ path does not exist") -+ else: -+ print("Live++ can only be used with targets 'debug' and 'release_debug'") -+ else: -+ print("No Live++ specified.") -+ - - def configure_mingw(env): - # Workaround for MinGW. See: -diff --git a/platform/windows/godot_windows.cpp b/platform/windows/godot_windows.cpp -index ef70c33..957158e 100644 ---- a/platform/windows/godot_windows.cpp -+++ b/platform/windows/godot_windows.cpp -@@ -34,6 +34,11 @@ - #include - #include - -+#ifdef LIVEPP_PATH -+#include "API/LPP_API.h" -+HMODULE livePP; -+#endif -+ - // For export templates, add a section; the exporter will patch it to enclose - // the data appended to the executable (bundled PCK) - #ifndef TOOLS_ENABLED -@@ -147,6 +152,16 @@ char *wc_to_utf8(const wchar_t *wc) { - } - - __declspec(dllexport) int widechar_main(int argc, wchar_t **argv) { -+#ifdef LIVEPP_PATH -+#define _MKSTR_L(x) _STR_L(x) -+#define _STR_L(x) L#x -+ livePP = lpp::lppLoadAndRegister(_MKSTR_L(LIVEPP_PATH), "Godot"); -+ lpp::lppEnableAllCallingModulesSync(livePP); -+ lpp::lppInstallExceptionHandler(livePP); -+#undef _MKSTR_L -+#undef _STR_L -+#endif -+ - OS_Windows os(NULL); - - setlocale(LC_CTYPE, ""); -@@ -180,6 +195,11 @@ __declspec(dllexport) int widechar_main(int argc, wchar_t **argv) { - } - delete[] argv_utf8; - -+#ifdef LIVEPP_PATH -+ lpp::lppShutdown(livePP); -+ ::FreeLibrary(livePP); -+#endif -+ - return os.get_exit_code(); - }; - -diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp -index 4977d11..6642be9 100644 ---- a/platform/windows/os_windows.cpp -+++ b/platform/windows/os_windows.cpp -@@ -53,6 +53,11 @@ - #include - #include - -+#ifdef LIVEPP_PATH -+#include "API/LPP_API.h" -+extern HMODULE livePP; -+#endif -+ - static const WORD MAX_CONSOLE_LINES = 1500; - - extern "C" { -@@ -3542,6 +3547,9 @@ void OS_Windows::run() { - process_events(); // get rid of pending events - if (Main::iteration()) - break; -+#ifdef LIVEPP_PATH -+ lpp::lppSyncPoint(livePP); -+#endif - }; - - main_loop->finish(); diff --git a/spine-godot/build/paths.md b/spine-godot/build/paths.md deleted file mode 100644 index d9a3b9f7c..000000000 --- a/spine-godot/build/paths.md +++ /dev/null @@ -1,12 +0,0 @@ -# Godot binary paths -## 4.0+ -* Windows - * Editor - * Debug: godot/bin/godot.windows.editor.dev.x86_64.exe - * Release: godot/bin/godot.windows.editor.x86_64.exe - * Template - * Debug: godot.windows.template_debug.x86_64.exe - * Release: godot.windows.template_release.x86_64.exe -* macOS - * Editor - * Debug: \ No newline at end of file diff --git a/spine-godot/build/setup-extension.sh b/spine-godot/build/setup-extension.sh new file mode 100755 index 000000000..6110c2eab --- /dev/null +++ b/spine-godot/build/setup-extension.sh @@ -0,0 +1,69 @@ +#!/bin/bash +set -e + +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 + echo "e.g.:" + echo " ./setup-extension.sh 4.2.2-stable true" + + exit 1 +fi + +godot_branch=${1%/} +dev=${2%/} +mono=false +godot_cpp_repo=https://github.com/godotengine/godot-cpp.git +godot_repo=https://github.com/godotengine/godot.git + +if [[ $# -eq 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 + +godot_cpp_branch=$(echo $godot_branch | cut -d- -f1) + +cpus=2 +if [ "$OSTYPE" == "msys" ]; then + cpus=$NUMBER_OF_PROCESSORS +elif [[ "$OSTYPE" == "darwin"* ]]; then + cpus=$(sysctl -n hw.logicalcpu) +else + cpus=$(grep -c ^processor /proc/cpuinfo) +fi + +echo "godot-cpp branch: $godot_cpp_branch" +echo "godot branch: $godot_branch" +echo "dev: $dev" +echo "mono: $mono" +echo "cpus: $cpus" + +pushd .. + +rm -rf godot-cpp +git clone $godot_cpp_repo +pushd godot-cpp +git checkout $godot_cpp_branch +popd + +rm -rf godot +git clone $godot_repo +pushd godot +git checkout $godot_branch +scons target=editor dev_build=true optimize=debug --jobs=$cpus +popd + +popd +popd > /dev/null \ No newline at end of file diff --git a/spine-godot/build/setup.sh b/spine-godot/build/setup.sh index 69d2244d2..00df6a004 100755 --- a/spine-godot/build/setup.sh +++ b/spine-godot/build/setup.sh @@ -67,18 +67,6 @@ if [ $dev = "true" ]; then rm -rf example/.import rm -rf example/.godot - #if [ "$OSTYPE" = "msys" ]; then - # pushd godot - # if [[ $branch == 3* ]]; then - # echo "Applying V3 Live++ patch" - # git apply ../build/livepp.patch - # else - # echo "Applying V4 Live++ patch" - # git apply ../build/livepp-v4.patch - # fi - # popd - #fi - if [ `uname` == 'Darwin' ] && [ ! -d "$HOME/VulkanSDK" ]; then ./build/install-macos-vulkan-sdk.sh fi diff --git a/spine-godot/example-v4-extension/bin/macos/macos.framework/libspine_godot.macos.template_debug b/spine-godot/example-v4-extension/bin/macos/macos.framework/libspine_godot.macos.template_debug deleted file mode 100755 index 1e96e6461..000000000 Binary files a/spine-godot/example-v4-extension/bin/macos/macos.framework/libspine_godot.macos.template_debug and /dev/null differ diff --git a/spine-godot/spine_godot/register_types.cpp b/spine-godot/spine_godot/register_types.cpp index 581a3c13f..bc5ca04b9 100644 --- a/spine-godot/spine_godot/register_types.cpp +++ b/spine-godot/spine_godot/register_types.cpp @@ -80,7 +80,6 @@ static void editor_init_callback() { #ifdef SPINE_GODOT_EXTENSION void initialize_spine_godot_module(ModuleInitializationLevel level) { - printf(">>>>>>>>>>>> level: %i\n", level); if (level == MODULE_INITIALIZATION_LEVEL_EDITOR) { GDREGISTER_CLASS(SpineAtlasResourceImportPlugin); GDREGISTER_CLASS(SpineJsonResourceImportPlugin); @@ -88,7 +87,6 @@ void initialize_spine_godot_module(ModuleInitializationLevel level) { GDREGISTER_CLASS(SpineSkeletonDataResourceInspectorPlugin); GDREGISTER_CLASS(SpineEditorPlugin); EditorPlugins::add_plugin_class(StringName("SpineEditorPlugin")); - printf(">>>>>>>>>>>> registered editor plugin"); } if (level != MODULE_INITIALIZATION_LEVEL_SCENE) return; #else diff --git a/spine-godot/gdextension.gd b/spine-godot/spine_godot_extension.gdextension similarity index 98% rename from spine-godot/gdextension.gd rename to spine-godot/spine_godot_extension.gdextension index cec50fdad..72bf26dca 100644 --- a/spine-godot/gdextension.gd +++ b/spine-godot/spine_godot_extension.gdextension @@ -5,7 +5,7 @@ compatibility_minimum = "4.1" [libraries] -macos.debug = "res://bin/macos/macos.framework/libspine_godot.macos.editor" +macos.debug = "res://bin/macos/macos.framework/libspine_godot.macos.template_debug" macos.release = "res://bin/macos/macos.framework/libspine_godot.macos.template_release" ios.debug = "res://bin/ios/ios.framework/libspine_godot.ios.template_debug" ios.release = "res://bin/ios/ios.framework/libspine_godot.ios.template_release"