[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.
This commit is contained in:
Mario Zechner 2025-11-17 14:36:48 +01:00
parent a6c9cc2225
commit 938c72fa8f
3 changed files with 26 additions and 7 deletions

View File

@ -30,8 +30,18 @@
#ifndef SPINE_COMMON_H
#define SPINE_COMMON_H
#include "core/version_generated.gen.h"
#ifdef SPINE_GODOT_EXTENSION
#include <godot_cpp/core/version.hpp>
// 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 <godot_cpp/classes/ref_counted.hpp>
#include <godot_cpp/variant/string_name.hpp>
using namespace godot;
@ -46,17 +56,20 @@ using namespace godot;
#define RES Ref<Resource>
#define REF Ref<RefCounted>
#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"

View File

@ -33,11 +33,15 @@
#ifdef SPINE_GODOT_EXTENSION
#include <godot_cpp/classes/encoded_object_as_id.hpp>
#include <godot_cpp/classes/engine.hpp>
#ifdef TOOLS_ENABLED
#include <godot_cpp/classes/editor_interface.hpp>
#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

View File

@ -41,7 +41,9 @@
#include <godot_cpp/variant/array.hpp>
#include <godot_cpp/classes/mesh.hpp>
#include <godot_cpp/classes/rendering_server.hpp>
#ifdef TOOLS_ENABLED
#include <godot_cpp/classes/editor_interface.hpp>
#endif
#include <godot_cpp/classes/control.hpp>
#include <godot_cpp/classes/viewport.hpp>
#include <godot_cpp/classes/scene_tree.hpp>
@ -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