Skip to content
  • Sponsor godotengine/godot-cpp

  • Notifications You must be signed in to change notification settings
  • Fork 648
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 631cd5f

Browse files
authoredNov 13, 2023
Merge pull request #1306 from dsnopek/4.1-cherrypicks-6
Cherry-picks for the godot-cpp 4.1 branch - 6th batch
2 parents c5f47b2 + 731a10a commit 631cd5f

File tree

4 files changed

+129
-105
lines changed

4 files changed

+129
-105
lines changed
 

‎.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,3 +191,7 @@ godot.creator.*
191191

192192
# compile commands (https://clang.llvm.org/docs/JSONCompilationDatabase.html)
193193
compile_commands.json
194+
195+
# Python development
196+
.venv
197+
venv

‎include/godot_cpp/classes/wrapped.hpp

Lines changed: 97 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -325,97 +325,105 @@ public:
325325
_gde_binding_create_callback, \
326326
_gde_binding_free_callback, \
327327
_gde_binding_reference_callback, \
328-
};
328+
}; \
329+
\
330+
private:
329331

330332
// Don't use this for your classes, use GDCLASS() instead.
331-
#define GDEXTENSION_CLASS_ALIAS(m_class, m_alias_for, m_inherits) \
332-
private: \
333-
inline static ::godot::internal::EngineClassRegistration<m_class> _gde_engine_class_registration_helper; \
334-
void operator=(const m_class &p_rval) {} \
335-
\
336-
protected: \
337-
virtual const GDExtensionInstanceBindingCallbacks *_get_bindings_callbacks() const override { \
338-
return &_gde_binding_callbacks; \
339-
} \
340-
\
341-
m_class(const char *p_godot_class) : m_inherits(p_godot_class) {} \
342-
m_class(GodotObject *p_godot_object) : m_inherits(p_godot_object) {} \
343-
\
344-
static void (*_get_bind_methods())() { \
345-
return nullptr; \
346-
} \
347-
\
348-
static void (Wrapped::*_get_notification())(int) { \
349-
return nullptr; \
350-
} \
351-
\
352-
static bool (Wrapped::*_get_set())(const ::godot::StringName &p_name, const Variant &p_property) { \
353-
return nullptr; \
354-
} \
355-
\
356-
static bool (Wrapped::*_get_get())(const ::godot::StringName &p_name, Variant &r_ret) const { \
357-
return nullptr; \
358-
} \
359-
\
360-
static void (Wrapped::*_get_get_property_list())(List<PropertyInfo> * p_list) const { \
361-
return nullptr; \
362-
} \
363-
\
364-
static bool (Wrapped::*_get_property_can_revert())(const ::godot::StringName &p_name) const { \
365-
return nullptr; \
366-
} \
367-
\
368-
static bool (Wrapped::*_get_property_get_revert())(const ::godot::StringName &p_name, Variant &) const { \
369-
return nullptr; \
370-
} \
371-
\
372-
static String (Wrapped::*_get_to_string())() const { \
373-
return nullptr; \
374-
} \
375-
\
376-
public: \
377-
typedef m_class self_type; \
378-
\
379-
static void initialize_class() {} \
380-
\
381-
static ::godot::StringName &get_class_static() { \
382-
static ::godot::StringName string_name = ::godot::StringName(#m_alias_for); \
383-
return string_name; \
384-
} \
385-
\
386-
static ::godot::StringName &get_parent_class_static() { \
387-
return m_inherits::get_class_static(); \
388-
} \
389-
\
390-
static GDExtensionObjectPtr create(void *data) { \
391-
return nullptr; \
392-
} \
393-
\
394-
static GDExtensionClassInstancePtr recreate(void *data, GDExtensionObjectPtr obj) { \
395-
return nullptr; \
396-
} \
397-
\
398-
static void free(void *data, GDExtensionClassInstancePtr ptr) { \
399-
} \
400-
\
401-
static void *_gde_binding_create_callback(void *p_token, void *p_instance) { \
402-
/* Do not call memnew here, we don't want the post-initializer to be called */ \
403-
return new ("") m_class((GodotObject *)p_instance); \
404-
} \
405-
static void _gde_binding_free_callback(void *p_token, void *p_instance, void *p_binding) { \
406-
/* Explicitly call the deconstructor to ensure proper lifecycle for non-trivial members */ \
407-
reinterpret_cast<m_class *>(p_binding)->~m_class(); \
408-
Memory::free_static(reinterpret_cast<m_class *>(p_binding)); \
409-
} \
410-
static GDExtensionBool _gde_binding_reference_callback(void *p_token, void *p_instance, GDExtensionBool p_reference) { \
411-
return true; \
412-
} \
413-
static constexpr GDExtensionInstanceBindingCallbacks _gde_binding_callbacks = { \
414-
_gde_binding_create_callback, \
415-
_gde_binding_free_callback, \
416-
_gde_binding_reference_callback, \
417-
}; \
418-
m_class() : m_class(#m_alias_for) {}
333+
#define GDEXTENSION_CLASS_ALIAS(m_class, m_alias_for, m_inherits) /******************************************************************************************************************/ \
334+
private: \
335+
inline static ::godot::internal::EngineClassRegistration<m_class> _gde_engine_class_registration_helper; \
336+
void operator=(const m_class &p_rval) {} \
337+
\
338+
protected: \
339+
virtual const GDExtensionInstanceBindingCallbacks *_get_bindings_callbacks() const override { \
340+
return &_gde_binding_callbacks; \
341+
} \
342+
\
343+
m_class(const char *p_godot_class) : m_inherits(p_godot_class) {} \
344+
m_class(GodotObject *p_godot_object) : m_inherits(p_godot_object) {} \
345+
\
346+
static void (*_get_bind_methods())() { \
347+
return nullptr; \
348+
} \
349+
\
350+
static void (Wrapped::*_get_notification())(int) { \
351+
return nullptr; \
352+
} \
353+
\
354+
static bool (Wrapped::*_get_set())(const ::godot::StringName &p_name, const Variant &p_property) { \
355+
return nullptr; \
356+
} \
357+
\
358+
static bool (Wrapped::*_get_get())(const ::godot::StringName &p_name, Variant &r_ret) const { \
359+
return nullptr; \
360+
} \
361+
\
362+
static inline bool has_get_property_list() { \
363+
return false; \
364+
} \
365+
\
366+
static void (Wrapped::*_get_get_property_list())(List<PropertyInfo> * p_list) const { \
367+
return nullptr; \
368+
} \
369+
\
370+
static bool (Wrapped::*_get_property_can_revert())(const ::godot::StringName &p_name) const { \
371+
return nullptr; \
372+
} \
373+
\
374+
static bool (Wrapped::*_get_property_get_revert())(const ::godot::StringName &p_name, Variant &) const { \
375+
return nullptr; \
376+
} \
377+
\
378+
static void (Wrapped::*_get_validate_property())(::godot::PropertyInfo & p_property) const { \
379+
return nullptr; \
380+
} \
381+
\
382+
static String (Wrapped::*_get_to_string())() const { \
383+
return nullptr; \
384+
} \
385+
\
386+
public: \
387+
typedef m_class self_type; \
388+
\
389+
static void initialize_class() {} \
390+
\
391+
static ::godot::StringName &get_class_static() { \
392+
static ::godot::StringName string_name = ::godot::StringName(#m_alias_for); \
393+
return string_name; \
394+
} \
395+
\
396+
static ::godot::StringName &get_parent_class_static() { \
397+
return m_inherits::get_class_static(); \
398+
} \
399+
\
400+
static GDExtensionObjectPtr create(void *data) { \
401+
return nullptr; \
402+
} \
403+
\
404+
static void free(void *data, GDExtensionClassInstancePtr ptr) { \
405+
} \
406+
\
407+
static void *_gde_binding_create_callback(void *p_token, void *p_instance) { \
408+
/* Do not call memnew here, we don't want the post-initializer to be called */ \
409+
return new ("") m_class((GodotObject *)p_instance); \
410+
} \
411+
static void _gde_binding_free_callback(void *p_token, void *p_instance, void *p_binding) { \
412+
/* Explicitly call the deconstructor to ensure proper lifecycle for non-trivial members */ \
413+
reinterpret_cast<m_class *>(p_binding)->~m_class(); \
414+
Memory::free_static(reinterpret_cast<m_class *>(p_binding)); \
415+
} \
416+
static GDExtensionBool _gde_binding_reference_callback(void *p_token, void *p_instance, GDExtensionBool p_reference) { \
417+
return true; \
418+
} \
419+
static constexpr GDExtensionInstanceBindingCallbacks _gde_binding_callbacks = { \
420+
_gde_binding_create_callback, \
421+
_gde_binding_free_callback, \
422+
_gde_binding_reference_callback, \
423+
}; \
424+
m_class() : m_class(#m_alias_for) {} \
425+
\
426+
private:
419427

420428
// Don't use this for your classes, use GDCLASS() instead.
421429
#define GDEXTENSION_CLASS(m_class, m_inherits) GDEXTENSION_CLASS_ALIAS(m_class, m_class, m_inherits)

‎tools/android.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,32 @@ def options(opts):
1111
"18" if "32" in ARGUMENTS.get("arch", "arm64") else "21",
1212
)
1313
opts.Add(
14-
"ANDROID_NDK_ROOT",
15-
"Path to your Android NDK installation. By default, uses ANDROID_NDK_ROOT from your defined environment variables.",
16-
os.environ.get("ANDROID_NDK_ROOT", None),
14+
"ANDROID_HOME",
15+
"Path to your Android SDK installation. By default, uses ANDROID_HOME from your defined environment variables.",
16+
os.environ.get("ANDROID_HOME", os.environ.get("ANDROID_SDK_ROOT")),
1717
)
1818

1919

2020
def exists(env):
21-
return "ANDROID_NDK_ROOT" in os.environ or "ANDROID_NDK_ROOT" in ARGUMENTS
21+
return get_android_ndk_root(env) is not None
22+
23+
24+
# This must be kept in sync with the value in https://github.com/godotengine/godot/blob/master/platform/android/detect.py#L58.
25+
def get_ndk_version():
26+
return "23.2.8568313"
27+
28+
29+
def get_android_ndk_root(env):
30+
if env["ANDROID_HOME"]:
31+
return env["ANDROID_HOME"] + "/ndk/" + get_ndk_version()
32+
else:
33+
return os.environ.get("ANDROID_NDK_ROOT")
2234

2335

2436
def generate(env):
25-
if "ANDROID_NDK_ROOT" not in env:
37+
if get_android_ndk_root(env) is None:
2638
raise ValueError(
27-
"To build for Android, ANDROID_NDK_ROOT must be defined. Please set ANDROID_NDK_ROOT to the root folder of your Android NDK installation."
39+
"To build for Android, the path to the NDK must be defined. Please set ANDROID_HOME to the root folder of your Android SDK installation."
2840
)
2941

3042
if env["arch"] not in ("arm64", "x86_64", "arm32", "x86_32"):
@@ -42,7 +54,7 @@ def generate(env):
4254
api_level = 21
4355

4456
# Setup toolchain
45-
toolchain = env["ANDROID_NDK_ROOT"] + "/toolchains/llvm/prebuilt/"
57+
toolchain = get_android_ndk_root(env) + "/toolchains/llvm/prebuilt/"
4658
if sys.platform == "win32" or sys.platform == "msys":
4759
toolchain += "windows"
4860
import platform as pltfm

‎tools/godotcpp.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,15 @@ def generate(env):
239239

240240
print("Building for architecture " + env["arch"] + " on platform " + env["platform"])
241241

242+
tool = Tool(env["platform"], toolpath=["tools"])
243+
244+
if tool is None or not tool.exists(env):
245+
raise ValueError("Required toolchain not found for platform " + env["platform"])
246+
247+
tool.generate(env)
248+
target_tool = Tool("targets", toolpath=["tools"])
249+
target_tool.generate(env)
250+
242251
# Disable exception handling. Godot doesn't use exceptions anywhere, and this
243252
# saves around 20% of binary size and very significant build time.
244253
if env["disable_exceptions"]:
@@ -249,15 +258,6 @@ def generate(env):
249258
elif env.get("is_msvc", False):
250259
env.Append(CXXFLAGS=["/EHsc"])
251260

252-
tool = Tool(env["platform"], toolpath=["tools"])
253-
254-
if tool is None or not tool.exists(env):
255-
raise ValueError("Required toolchain not found for platform " + env["platform"])
256-
257-
tool.generate(env)
258-
target_tool = Tool("targets", toolpath=["tools"])
259-
target_tool.generate(env)
260-
261261
# Require C++17
262262
if env.get("is_msvc", False):
263263
env.Append(CXXFLAGS=["/std:c++17"])

0 commit comments

Comments
 (0)
Please sign in to comment.