From 938c72fa8f934c17b763d34735acbf1c18489c16 Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Mon, 17 Nov 2025 14:36:48 +0100 Subject: [PATCH] [godot] Backport Godot 4.5 compatibility fixes from 4.3-beta Backported three commits from 4.3-beta branch: - cc12304ba: Adds TOOLS_ENABLED guards for editor includes - e063bae54: Adds version macro compatibility for deprecated=no builds (module) - 3ffea502e: Adds version macro compatibility for deprecated=no builds (extension) Changes: 1. SpineCommon.h: - Added #include "core/version_generated.gen.h" - Added VERSION_MAJOR/MINOR/PATCH macro fallbacks for both module and extension builds - These macros are needed when building with deprecated=no in Godot 4.5+ 2. SpineSkeletonDataResource.cpp and SpineSprite.cpp: - Wrapped editor_interface.h includes with TOOLS_ENABLED guards - Required for building export templates (non-editor builds) in Godot 4.5+ This ensures spine-godot compiles correctly with Godot 4.5 in all build configurations. --- spine-godot/spine_godot/SpineCommon.h | 25 ++++++++++++++----- .../spine_godot/SpineSkeletonDataResource.cpp | 4 +++ spine-godot/spine_godot/SpineSprite.cpp | 4 ++- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/spine-godot/spine_godot/SpineCommon.h b/spine-godot/spine_godot/SpineCommon.h index c9cdda5d5..1cacf556b 100644 --- a/spine-godot/spine_godot/SpineCommon.h +++ b/spine-godot/spine_godot/SpineCommon.h @@ -30,8 +30,18 @@ #ifndef SPINE_COMMON_H #define SPINE_COMMON_H +#include "core/version_generated.gen.h" #ifdef SPINE_GODOT_EXTENSION #include + +// When running scons with deprecated=no, these are not defined in version.h in Godot 4.5.1 +// but our code for older versions of Godot relies on them. +#ifndef VERSION_MAJOR +#define VERSION_MAJOR GODOT_VERSION_MAJOR +#define VERSION_MINOR GODOT_VERSION_MINOR +#define VERSION_PATCH GODOT_VERSION_PATCH +#endif + #include #include using namespace godot; @@ -46,17 +56,20 @@ using namespace godot; #define RES Ref #define REF Ref #define GEOMETRY2D Geometry2D -#ifndef VERSION_MAJOR -#define VERSION_MAJOR GODOT_VERSION_MAJOR -#endif -#ifndef VERSION_MINOR -#define VERSION_MINOR GODOT_VERSION_MINOR -#endif // FIXME this doesn't do the same as the engine SNAME in terms of caching #define SNAME(name) StringName(name) #define RS RenderingServer #else #include "core/version.h" + +// When running scons with deprecated=no, these are not defined in version.h in Godot 4.5.1 +// but our code for older versions of Godot relies on them. +#ifndef VERSION_MAJOR +#define VERSION_MAJOR GODOT_VERSION_MAJOR +#define VERSION_MINOR GODOT_VERSION_MINOR +#define VERSION_PATCH GODOT_VERSION_PATCH +#endif + #if VERSION_MAJOR > 3 #include "core/core_bind.h" #include "core/error/error_macros.h" diff --git a/spine-godot/spine_godot/SpineSkeletonDataResource.cpp b/spine-godot/spine_godot/SpineSkeletonDataResource.cpp index 83ef759f3..050bd2563 100644 --- a/spine-godot/spine_godot/SpineSkeletonDataResource.cpp +++ b/spine-godot/spine_godot/SpineSkeletonDataResource.cpp @@ -33,11 +33,15 @@ #ifdef SPINE_GODOT_EXTENSION #include #include +#ifdef TOOLS_ENABLED #include +#endif #else #if VERSION_MAJOR > 3 #include "core/config/engine.h" +#ifdef TOOLS_ENABLED #include "editor/editor_interface.h" +#endif #else #include "core/engine.h" #endif diff --git a/spine-godot/spine_godot/SpineSprite.cpp b/spine-godot/spine_godot/SpineSprite.cpp index c29e250bf..ce479e291 100644 --- a/spine-godot/spine_godot/SpineSprite.cpp +++ b/spine-godot/spine_godot/SpineSprite.cpp @@ -41,7 +41,9 @@ #include #include #include +#ifdef TOOLS_ENABLED #include +#endif #include #include #include @@ -60,7 +62,7 @@ #include "scene/resources/mesh.h" #include "servers/rendering_server.h" #include "scene/resources/canvas_item_material.h" -#if VERSION_MINOR > 0 +#if VERSION_MINOR > 0 && defined(TOOLS_ENABLED) #include "editor/editor_interface.h" #endif #else