Skip to content

Commit 938c72f

Browse files
committed
[godot] Backport Godot 4.5 compatibility fixes from 4.3-beta
Backported three commits from 4.3-beta branch: - cc12304: Adds TOOLS_ENABLED guards for editor includes - e063bae: Adds version macro compatibility for deprecated=no builds (module) - 3ffea50: 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.
1 parent a6c9cc2 commit 938c72f

File tree

3 files changed

+26
-7
lines changed

3 files changed

+26
-7
lines changed

spine-godot/spine_godot/SpineCommon.h

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,18 @@
3030
#ifndef SPINE_COMMON_H
3131
#define SPINE_COMMON_H
3232

33+
#include "core/version_generated.gen.h"
3334
#ifdef SPINE_GODOT_EXTENSION
3435
#include <godot_cpp/core/version.hpp>
36+
37+
// When running scons with deprecated=no, these are not defined in version.h in Godot 4.5.1
38+
// but our code for older versions of Godot relies on them.
39+
#ifndef VERSION_MAJOR
40+
#define VERSION_MAJOR GODOT_VERSION_MAJOR
41+
#define VERSION_MINOR GODOT_VERSION_MINOR
42+
#define VERSION_PATCH GODOT_VERSION_PATCH
43+
#endif
44+
3545
#include <godot_cpp/classes/ref_counted.hpp>
3646
#include <godot_cpp/variant/string_name.hpp>
3747
using namespace godot;
@@ -46,17 +56,20 @@ using namespace godot;
4656
#define RES Ref<Resource>
4757
#define REF Ref<RefCounted>
4858
#define GEOMETRY2D Geometry2D
49-
#ifndef VERSION_MAJOR
50-
#define VERSION_MAJOR GODOT_VERSION_MAJOR
51-
#endif
52-
#ifndef VERSION_MINOR
53-
#define VERSION_MINOR GODOT_VERSION_MINOR
54-
#endif
5559
// FIXME this doesn't do the same as the engine SNAME in terms of caching
5660
#define SNAME(name) StringName(name)
5761
#define RS RenderingServer
5862
#else
5963
#include "core/version.h"
64+
65+
// When running scons with deprecated=no, these are not defined in version.h in Godot 4.5.1
66+
// but our code for older versions of Godot relies on them.
67+
#ifndef VERSION_MAJOR
68+
#define VERSION_MAJOR GODOT_VERSION_MAJOR
69+
#define VERSION_MINOR GODOT_VERSION_MINOR
70+
#define VERSION_PATCH GODOT_VERSION_PATCH
71+
#endif
72+
6073
#if VERSION_MAJOR > 3
6174
#include "core/core_bind.h"
6275
#include "core/error/error_macros.h"

spine-godot/spine_godot/SpineSkeletonDataResource.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,15 @@
3333
#ifdef SPINE_GODOT_EXTENSION
3434
#include <godot_cpp/classes/encoded_object_as_id.hpp>
3535
#include <godot_cpp/classes/engine.hpp>
36+
#ifdef TOOLS_ENABLED
3637
#include <godot_cpp/classes/editor_interface.hpp>
38+
#endif
3739
#else
3840
#if VERSION_MAJOR > 3
3941
#include "core/config/engine.h"
42+
#ifdef TOOLS_ENABLED
4043
#include "editor/editor_interface.h"
44+
#endif
4145
#else
4246
#include "core/engine.h"
4347
#endif

spine-godot/spine_godot/SpineSprite.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@
4141
#include <godot_cpp/variant/array.hpp>
4242
#include <godot_cpp/classes/mesh.hpp>
4343
#include <godot_cpp/classes/rendering_server.hpp>
44+
#ifdef TOOLS_ENABLED
4445
#include <godot_cpp/classes/editor_interface.hpp>
46+
#endif
4547
#include <godot_cpp/classes/control.hpp>
4648
#include <godot_cpp/classes/viewport.hpp>
4749
#include <godot_cpp/classes/scene_tree.hpp>
@@ -60,7 +62,7 @@
6062
#include "scene/resources/mesh.h"
6163
#include "servers/rendering_server.h"
6264
#include "scene/resources/canvas_item_material.h"
63-
#if VERSION_MINOR > 0
65+
#if VERSION_MINOR > 0 && defined(TOOLS_ENABLED)
6466
#include "editor/editor_interface.h"
6567
#endif
6668
#else

0 commit comments

Comments
 (0)