From 29335d8f5cc2b87f0129f1388a008ec4a90ba504 Mon Sep 17 00:00:00 2001 From: Fredia Huya-Kouadio Date: Wed, 1 Nov 2023 09:09:05 -0700 Subject: [PATCH 1/4] Update the environment variables used to access the Android NDK toolchain (cherry picked from commit 86dbd5fa0d6f581666e0626fe99bc2f2b00b5e49) --- tools/android.py | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/tools/android.py b/tools/android.py index 0e688551..479ee15c 100644 --- a/tools/android.py +++ b/tools/android.py @@ -11,20 +11,32 @@ def options(opts): "18" if "32" in ARGUMENTS.get("arch", "arm64") else "21", ) opts.Add( - "ANDROID_NDK_ROOT", - "Path to your Android NDK installation. By default, uses ANDROID_NDK_ROOT from your defined environment variables.", - os.environ.get("ANDROID_NDK_ROOT", None), + "ANDROID_HOME", + "Path to your Android SDK installation. By default, uses ANDROID_HOME from your defined environment variables.", + os.environ.get("ANDROID_HOME", os.environ.get("ANDROID_SDK_ROOT")), ) def exists(env): - return "ANDROID_NDK_ROOT" in os.environ or "ANDROID_NDK_ROOT" in ARGUMENTS + return get_android_ndk_root(env) is not None + + +# This must be kept in sync with the value in https://github.com/godotengine/godot/blob/master/platform/android/detect.py#L58. +def get_ndk_version(): + return "23.2.8568313" + + +def get_android_ndk_root(env): + if env["ANDROID_HOME"]: + return env["ANDROID_HOME"] + "/ndk/" + get_ndk_version() + else: + return os.environ.get("ANDROID_NDK_ROOT") def generate(env): - if "ANDROID_NDK_ROOT" not in env: + if get_android_ndk_root(env) is None: raise ValueError( - "To build for Android, ANDROID_NDK_ROOT must be defined. Please set ANDROID_NDK_ROOT to the root folder of your Android NDK installation." + "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." ) if env["arch"] not in ("arm64", "x86_64", "arm32", "x86_32"): @@ -42,7 +54,7 @@ def generate(env): api_level = 21 # Setup toolchain - toolchain = env["ANDROID_NDK_ROOT"] + "/toolchains/llvm/prebuilt/" + toolchain = get_android_ndk_root(env) + "/toolchains/llvm/prebuilt/" if sys.platform == "win32" or sys.platform == "msys": toolchain += "windows" import platform as pltfm From 805cdde0b7811ee4d1184c132049f6dfa092d7e7 Mon Sep 17 00:00:00 2001 From: Thaddeus Crews Date: Wed, 1 Nov 2023 12:44:14 -0500 Subject: [PATCH 2/4] GDCLASS synced by ending with "private:" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • Matches implementation used by modules and godot itself • Apply same to GDEXTENSION_CLASS, setup with same diff-friendly spacers as GDCLASS (cherry picked from commit 6eb5d450bd28903f6a0fe45f8065fa70448e5793) --- include/godot_cpp/classes/wrapped.hpp | 186 ++++++++++++++------------ 1 file changed, 97 insertions(+), 89 deletions(-) diff --git a/include/godot_cpp/classes/wrapped.hpp b/include/godot_cpp/classes/wrapped.hpp index ed923c1c..4683070e 100644 --- a/include/godot_cpp/classes/wrapped.hpp +++ b/include/godot_cpp/classes/wrapped.hpp @@ -325,97 +325,105 @@ public: _gde_binding_create_callback, \ _gde_binding_free_callback, \ _gde_binding_reference_callback, \ - }; + }; \ + \ +private: // Don't use this for your classes, use GDCLASS() instead. -#define GDEXTENSION_CLASS_ALIAS(m_class, m_alias_for, m_inherits) \ -private: \ - inline static ::godot::internal::EngineClassRegistration _gde_engine_class_registration_helper; \ - void operator=(const m_class &p_rval) {} \ - \ -protected: \ - virtual const GDExtensionInstanceBindingCallbacks *_get_bindings_callbacks() const override { \ - return &_gde_binding_callbacks; \ - } \ - \ - m_class(const char *p_godot_class) : m_inherits(p_godot_class) {} \ - m_class(GodotObject *p_godot_object) : m_inherits(p_godot_object) {} \ - \ - static void (*_get_bind_methods())() { \ - return nullptr; \ - } \ - \ - static void (Wrapped::*_get_notification())(int) { \ - return nullptr; \ - } \ - \ - static bool (Wrapped::*_get_set())(const ::godot::StringName &p_name, const Variant &p_property) { \ - return nullptr; \ - } \ - \ - static bool (Wrapped::*_get_get())(const ::godot::StringName &p_name, Variant &r_ret) const { \ - return nullptr; \ - } \ - \ - static void (Wrapped::*_get_get_property_list())(List * p_list) const { \ - return nullptr; \ - } \ - \ - static bool (Wrapped::*_get_property_can_revert())(const ::godot::StringName &p_name) const { \ - return nullptr; \ - } \ - \ - static bool (Wrapped::*_get_property_get_revert())(const ::godot::StringName &p_name, Variant &) const { \ - return nullptr; \ - } \ - \ - static String (Wrapped::*_get_to_string())() const { \ - return nullptr; \ - } \ - \ -public: \ - typedef m_class self_type; \ - \ - static void initialize_class() {} \ - \ - static ::godot::StringName &get_class_static() { \ - static ::godot::StringName string_name = ::godot::StringName(#m_alias_for); \ - return string_name; \ - } \ - \ - static ::godot::StringName &get_parent_class_static() { \ - return m_inherits::get_class_static(); \ - } \ - \ - static GDExtensionObjectPtr create(void *data) { \ - return nullptr; \ - } \ - \ - static GDExtensionClassInstancePtr recreate(void *data, GDExtensionObjectPtr obj) { \ - return nullptr; \ - } \ - \ - static void free(void *data, GDExtensionClassInstancePtr ptr) { \ - } \ - \ - static void *_gde_binding_create_callback(void *p_token, void *p_instance) { \ - /* Do not call memnew here, we don't want the post-initializer to be called */ \ - return new ("") m_class((GodotObject *)p_instance); \ - } \ - static void _gde_binding_free_callback(void *p_token, void *p_instance, void *p_binding) { \ - /* Explicitly call the deconstructor to ensure proper lifecycle for non-trivial members */ \ - reinterpret_cast(p_binding)->~m_class(); \ - Memory::free_static(reinterpret_cast(p_binding)); \ - } \ - static GDExtensionBool _gde_binding_reference_callback(void *p_token, void *p_instance, GDExtensionBool p_reference) { \ - return true; \ - } \ - static constexpr GDExtensionInstanceBindingCallbacks _gde_binding_callbacks = { \ - _gde_binding_create_callback, \ - _gde_binding_free_callback, \ - _gde_binding_reference_callback, \ - }; \ - m_class() : m_class(#m_alias_for) {} +#define GDEXTENSION_CLASS_ALIAS(m_class, m_alias_for, m_inherits) /******************************************************************************************************************/ \ +private: \ + inline static ::godot::internal::EngineClassRegistration _gde_engine_class_registration_helper; \ + void operator=(const m_class &p_rval) {} \ + \ +protected: \ + virtual const GDExtensionInstanceBindingCallbacks *_get_bindings_callbacks() const override { \ + return &_gde_binding_callbacks; \ + } \ + \ + m_class(const char *p_godot_class) : m_inherits(p_godot_class) {} \ + m_class(GodotObject *p_godot_object) : m_inherits(p_godot_object) {} \ + \ + static void (*_get_bind_methods())() { \ + return nullptr; \ + } \ + \ + static void (Wrapped::*_get_notification())(int) { \ + return nullptr; \ + } \ + \ + static bool (Wrapped::*_get_set())(const ::godot::StringName &p_name, const Variant &p_property) { \ + return nullptr; \ + } \ + \ + static bool (Wrapped::*_get_get())(const ::godot::StringName &p_name, Variant &r_ret) const { \ + return nullptr; \ + } \ + \ + static inline bool has_get_property_list() { \ + return false; \ + } \ + \ + static void (Wrapped::*_get_get_property_list())(List * p_list) const { \ + return nullptr; \ + } \ + \ + static bool (Wrapped::*_get_property_can_revert())(const ::godot::StringName &p_name) const { \ + return nullptr; \ + } \ + \ + static bool (Wrapped::*_get_property_get_revert())(const ::godot::StringName &p_name, Variant &) const { \ + return nullptr; \ + } \ + \ + static void (Wrapped::*_get_validate_property())(::godot::PropertyInfo & p_property) const { \ + return nullptr; \ + } \ + \ + static String (Wrapped::*_get_to_string())() const { \ + return nullptr; \ + } \ + \ +public: \ + typedef m_class self_type; \ + \ + static void initialize_class() {} \ + \ + static ::godot::StringName &get_class_static() { \ + static ::godot::StringName string_name = ::godot::StringName(#m_alias_for); \ + return string_name; \ + } \ + \ + static ::godot::StringName &get_parent_class_static() { \ + return m_inherits::get_class_static(); \ + } \ + \ + static GDExtensionObjectPtr create(void *data) { \ + return nullptr; \ + } \ + \ + static void free(void *data, GDExtensionClassInstancePtr ptr) { \ + } \ + \ + static void *_gde_binding_create_callback(void *p_token, void *p_instance) { \ + /* Do not call memnew here, we don't want the post-initializer to be called */ \ + return new ("") m_class((GodotObject *)p_instance); \ + } \ + static void _gde_binding_free_callback(void *p_token, void *p_instance, void *p_binding) { \ + /* Explicitly call the deconstructor to ensure proper lifecycle for non-trivial members */ \ + reinterpret_cast(p_binding)->~m_class(); \ + Memory::free_static(reinterpret_cast(p_binding)); \ + } \ + static GDExtensionBool _gde_binding_reference_callback(void *p_token, void *p_instance, GDExtensionBool p_reference) { \ + return true; \ + } \ + static constexpr GDExtensionInstanceBindingCallbacks _gde_binding_callbacks = { \ + _gde_binding_create_callback, \ + _gde_binding_free_callback, \ + _gde_binding_reference_callback, \ + }; \ + m_class() : m_class(#m_alias_for) {} \ + \ +private: // Don't use this for your classes, use GDCLASS() instead. #define GDEXTENSION_CLASS(m_class, m_inherits) GDEXTENSION_CLASS_ALIAS(m_class, m_class, m_inherits) From a1ae58448c75cd7402a48a045be4034fd1846ad9 Mon Sep 17 00:00:00 2001 From: Thaddeus Crews Date: Mon, 6 Nov 2023 10:43:24 -0600 Subject: [PATCH 3/4] fix is_msvc and use_hot_reload variables (cherry picked from commit 648b8c4489bdf0fe1d2beff737a147c5c38d66d7) --- tools/godotcpp.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tools/godotcpp.py b/tools/godotcpp.py index 925b214d..efe632ab 100644 --- a/tools/godotcpp.py +++ b/tools/godotcpp.py @@ -239,6 +239,15 @@ def generate(env): print("Building for architecture " + env["arch"] + " on platform " + env["platform"]) + tool = Tool(env["platform"], toolpath=["tools"]) + + if tool is None or not tool.exists(env): + raise ValueError("Required toolchain not found for platform " + env["platform"]) + + tool.generate(env) + target_tool = Tool("targets", toolpath=["tools"]) + target_tool.generate(env) + # Disable exception handling. Godot doesn't use exceptions anywhere, and this # saves around 20% of binary size and very significant build time. if env["disable_exceptions"]: @@ -249,15 +258,6 @@ def generate(env): elif env.get("is_msvc", False): env.Append(CXXFLAGS=["/EHsc"]) - tool = Tool(env["platform"], toolpath=["tools"]) - - if tool is None or not tool.exists(env): - raise ValueError("Required toolchain not found for platform " + env["platform"]) - - tool.generate(env) - target_tool = Tool("targets", toolpath=["tools"]) - target_tool.generate(env) - # Require C++17 if env.get("is_msvc", False): env.Append(CXXFLAGS=["/std:c++17"]) From 731a10a4ea4db0f278676585f1a732fc7c83e84d Mon Sep 17 00:00:00 2001 From: Alex Drozd Date: Mon, 6 Nov 2023 22:32:52 +0100 Subject: [PATCH 4/4] ignoring venv in .gitignore (cherry picked from commit 92dd34ae968a48c35a34e778550577a1d6d86205) --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index 7c87766f..d4b57481 100644 --- a/.gitignore +++ b/.gitignore @@ -191,3 +191,7 @@ godot.creator.* # compile commands (https://clang.llvm.org/docs/JSONCompilationDatabase.html) compile_commands.json + +# Python development +.venv +venv