From 9e7cec9f421fd3adc61f934a3bfe3ba04f6ece2f Mon Sep 17 00:00:00 2001 From: Dragos Daian Date: Fri, 15 Mar 2024 09:57:36 +0100 Subject: [PATCH] Generate godot compat for dual build generate compat generate compat Update ci.yml Update binding_generator.py generate compat generate compat lint python files Update compat_generator.py update docs Update binding_generator.py Update module_converter.py also collect defines Add module converter file that converts module based projects to godot_compat Update ci.yml update docs Update compat_generator.py lint python files generate compat generate compat generate compat generate compat Update ci.yml fix path issue when caling from outside Update binding_generator.py update to also take missing classes/structs Update binding_generator.py Generate godot compat for dual build generate compat generate compat Update ci.yml Update binding_generator.py generate compat generate compat lint python files Update compat_generator.py update docs Update binding_generator.py Update module_converter.py also collect defines Add module converter file that converts module based projects to godot_compat Update ci.yml update docs Update compat_generator.py lint python files generate compat generate compat generate compat generate compat Update ci.yml fix path issue when caling from outside Add support for build profiles. Allow enabling or disabling specific classes (which will not be built). Allow forwarding from `ClassDB` to `ClassDBSingleton` to support enumerations update to also take missing classes/structs Update binding_generator.py update update naming of files add godot mappings. update and run output_header_mapping.json Update README.md make godot_compat work without a file generated fix the test Update binding_generator.py Update binding_generator.py Update binding_generator.py use files from include too Update README.md lint lint lint Update CMakeLists.txt update to use all. fix linting a bit update wip fix posix path Update CMakeLists.txt Update binding_generator.py add using namespace godot; everywhere to includes fix includes Try fixes. generate new include files 123 Update binding_generator.py Update binding_generator.py Update binding_generator.py Update binding_generator.py update fix GODOT_MODULE_COMPAT fix manual includes to match. Update godot.hpp Update color_names.inc.hpp --- README.md | 61 +++++++++++++++ binding_generator.py | 54 ++++++++++++- compat_generator.py | 75 +++++++++++++++++++ header_matcher.py | 33 ++++++++ .../classes/editor_plugin_registration.hpp | 5 ++ include/godot_cpp/classes/ref.hpp | 5 ++ include/godot_cpp/classes/wrapped.hpp | 5 ++ include/godot_cpp/core/binder_common.hpp | 5 ++ include/godot_cpp/core/builtin_ptrcall.hpp | 4 + include/godot_cpp/core/class_db.hpp | 6 ++ include/godot_cpp/core/defs.hpp | 6 ++ include/godot_cpp/core/engine_ptrcall.hpp | 4 + include/godot_cpp/core/error_macros.hpp | 5 ++ include/godot_cpp/core/math.hpp | 6 ++ include/godot_cpp/core/memory.hpp | 5 ++ include/godot_cpp/core/method_bind.hpp | 5 ++ include/godot_cpp/core/method_ptrcall.hpp | 5 ++ include/godot_cpp/core/mutex_lock.hpp | 5 ++ include/godot_cpp/core/object.hpp | 5 ++ include/godot_cpp/core/object_id.hpp | 5 ++ include/godot_cpp/core/property_info.hpp | 5 ++ include/godot_cpp/core/type_info.hpp | 5 ++ include/godot_cpp/godot.hpp | 5 ++ include/godot_cpp/templates/cowdata.hpp | 5 ++ include/godot_cpp/templates/hash_map.hpp | 5 ++ include/godot_cpp/templates/hash_set.hpp | 5 ++ include/godot_cpp/templates/hashfuncs.hpp | 5 ++ include/godot_cpp/templates/list.hpp | 5 ++ include/godot_cpp/templates/local_vector.hpp | 5 ++ include/godot_cpp/templates/pair.hpp | 5 ++ include/godot_cpp/templates/rb_map.hpp | 5 ++ include/godot_cpp/templates/rb_set.hpp | 5 ++ include/godot_cpp/templates/rid_owner.hpp | 5 ++ include/godot_cpp/templates/safe_refcount.hpp | 5 ++ include/godot_cpp/templates/search_array.hpp | 5 ++ include/godot_cpp/templates/self_list.hpp | 5 ++ include/godot_cpp/templates/sort_array.hpp | 5 ++ include/godot_cpp/templates/spin_lock.hpp | 5 ++ .../godot_cpp/templates/thread_work_pool.hpp | 5 ++ include/godot_cpp/templates/vector.hpp | 5 ++ include/godot_cpp/templates/vmap.hpp | 5 ++ include/godot_cpp/templates/vset.hpp | 5 ++ include/godot_cpp/variant/aabb.hpp | 5 ++ include/godot_cpp/variant/array_helpers.hpp | 4 + include/godot_cpp/variant/basis.hpp | 5 ++ include/godot_cpp/variant/callable_custom.hpp | 5 ++ .../variant/callable_method_pointer.hpp | 5 ++ include/godot_cpp/variant/char_string.hpp | 5 ++ include/godot_cpp/variant/char_utils.hpp | 5 ++ include/godot_cpp/variant/color.hpp | 5 ++ include/godot_cpp/variant/color_names.inc.hpp | 5 ++ include/godot_cpp/variant/plane.hpp | 5 ++ include/godot_cpp/variant/projection.hpp | 5 ++ include/godot_cpp/variant/quaternion.hpp | 5 ++ include/godot_cpp/variant/rect2.hpp | 5 ++ include/godot_cpp/variant/rect2i.hpp | 5 ++ include/godot_cpp/variant/transform2d.hpp | 5 ++ include/godot_cpp/variant/transform3d.hpp | 5 ++ include/godot_cpp/variant/typed_array.hpp | 5 ++ include/godot_cpp/variant/variant.hpp | 5 ++ include/godot_cpp/variant/vector2.hpp | 5 ++ include/godot_cpp/variant/vector2i.hpp | 5 ++ include/godot_cpp/variant/vector3.hpp | 5 ++ include/godot_cpp/variant/vector3i.hpp | 5 ++ include/godot_cpp/variant/vector4.hpp | 5 ++ include/godot_cpp/variant/vector4i.hpp | 5 ++ tools/godotcpp.py | 8 ++ 67 files changed, 540 insertions(+), 1 deletion(-) create mode 100644 compat_generator.py create mode 100644 header_matcher.py diff --git a/README.md b/README.md index 005c8e723..630fac17f 100644 --- a/README.md +++ b/README.md @@ -147,3 +147,64 @@ generic reusable template. Or checkout the code for the [Summator example](https://github.com/paddy-exe/GDExtensionSummator) as shown in the [official documentation](https://docs.godotengine.org/en/latest/tutorials/scripting/gdextension/gdextension_cpp_example.html). + +## Godot and Godot Cpp Compatibility + +If you intend to target both building as a GDExtension and as a module using godot repo, you can generate compatibility includes that will target either GDExtension or module, based on the GODOT_MODULE define. + +If you want such headers, when running the build command, `scons`, pass the `godot_repo` param with the path to the godot repository. Eg. if you have the godot repository cloned at path `../godot`, then do: + +```sh +scons godot_repo="../godot" +``` + +This will generate something like this: +``` +gen/include/godot_cpp/.. +gen/include/godot_compat/.. +``` + +Now, all you need to do is when writing your addon/module, replace includes like these: + +```cpp +#include +``` + +with + +```cpp +#include +``` + +Inside, this file will have code for both godot and godot-cpp: + +```cpp +#ifdef GODOT_MODULE +#include +#else +#include +#endif +``` + +### Manually generate mapping files + +The mappings can be manually generated by running the `compat_generator.py` script. + +Example of how to run `compat_generator.py`: + +```sh +git clone godotengine/godot +python compat_generator.py godot +``` + +The first argument of `compat_generator.py` is the folder where the repo is (can be godot or godot-cpp repo). If this folder is not given, the current directory is assumed. The output of this is either `output_header_mapping_godot.json` or `output_header_mapping_godot_cpp.json` + +### Manually match the mapping files + +If you want to manually match the godot mapping file with the godot-cpp one, you can do that by running: + +```sh +python header_matcher.py +``` + +This will generate the `header_matches.json` file with matches from godot and godot_cpp repo. diff --git a/binding_generator.py b/binding_generator.py index 75e56fde1..00da4e890 100644 --- a/binding_generator.py +++ b/binding_generator.py @@ -5,6 +5,9 @@ import shutil from pathlib import Path +from compat_generator import map_header_files +from header_matcher import match_headers + def generate_mod_version(argcount, const=False, returns=False): s = """ @@ -378,11 +381,14 @@ def scons_generate_bindings(target, source, env): "32" if "32" in env["arch"] else "64", env["precision"], env["godot_cpp_gen_dir"], + env["godot_repo"], ) return None -def generate_bindings(api_filepath, use_template_get_node, bits="64", precision="single", output_dir="."): +def generate_bindings( + api_filepath, use_template_get_node, bits="64", precision="single", output_dir=".", godot_repo="" +): api = None target_dir = Path(output_dir) / "gen" @@ -402,6 +408,8 @@ def generate_bindings(api_filepath, use_template_get_node, bits="64", precision= generate_builtin_bindings(api, target_dir, real_t + "_" + bits) generate_engine_classes_bindings(api, target_dir, use_template_get_node) generate_utility_functions(api, target_dir) + if godot_repo != "": + generate_compat_includes(godot_repo, target_dir) CLASS_ALIASES = { @@ -1545,6 +1553,50 @@ def generate_engine_classes_bindings(api, output_dir, use_template_get_node): header_file.write("\n".join(result)) +def generate_compat_includes(godot_repo: Path, target_dir: Path): + file_types_mapping_godot_cpp_gen = map_header_files(target_dir) + file_types_mapping_godot = map_header_files(godot_repo) + # Match the headers + file_types_mapping = match_headers(file_types_mapping_godot_cpp_gen, file_types_mapping_godot) + for file_godot_cpp_name, file_godot_names in file_types_mapping.items(): + result = [] + with (Path(target_dir) / Path(file_godot_cpp_name)).open("r", encoding="utf-8") as header_file: + content = header_file.readlines() + # Find the last line (#endif guard) + last_endif_idx = len(content) - 1 + # Look for the marker for the header guard (usually #define) + marker_pos = next((i for i, line in enumerate(content) if line.startswith("#define")), -1) + + if marker_pos != -1: + # Add content before the last #endif + before_marker = content[: marker_pos + 1] # Include up to the marker line + after_marker = content[marker_pos + 1 : last_endif_idx] # Content excluding the final #endif + + result.extend(before_marker) # Append original content up to marker + result.append("\n") # Blank line for separation + + # Insert the #ifdef block + result.append("#ifdef GODOT_MODULE\n") + if len(file_godot_names) == 0: + print("No header found for", file_godot_cpp_name) + for file_godot_name in file_godot_names: + result.append(f'#include "{Path(file_godot_name).as_posix()}"\n') + result.append("#else\n") + + result.extend(after_marker) + + # Add the namespace and endif + result.append("#endif\n") + + # Finally, append the original final #endif line + result.append(content[last_endif_idx].strip()) + + else: + print(f"Marker not found in {file_godot_cpp_name}") + with (Path(target_dir) / Path(file_godot_cpp_name)).open("w+", encoding="utf-8") as header_file: + header_file.write("".join(result)) + + def generate_engine_class_header(class_api, used_classes, fully_used_classes, use_template_get_node): global singletons result = [] diff --git a/compat_generator.py b/compat_generator.py new file mode 100644 index 000000000..ae94a95b2 --- /dev/null +++ b/compat_generator.py @@ -0,0 +1,75 @@ +#!/usr/bin/env python + +import json +import os +import re +import sys + + +def parse_header_file(file_path): + types = {"classes": [], "structs": [], "defines": [], "enums": []} + + with open(file_path, "r", encoding="utf-8") as file: + content = file.read() + + # Regular expressions to match different types + struct_pattern = r"struct.*\s(\S+)\s*\{" + type_pattern = r"typedef.*\s(\S+)\s*\;" + enum_pattern = r"enum.*\s(\S+)\s*\{" + class_pattern = r"class\s+[\w\s]*?([a-zA-Z_]\w*)\s*[:{]" + define_pattern = r"#define\s+([a-zA-Z_]\w*)" + + # Extract classes + types["classes"] += re.findall(class_pattern, content) + + # Extract structs + struct_names = re.findall(struct_pattern, content) + types["structs"].extend(struct_names) + type_names = re.findall(type_pattern, content) + types["structs"].extend(type_names) + enum_names = re.findall(enum_pattern, content) + types["enums"].extend(enum_names) + + # Extract defines + define_matches = re.findall(define_pattern, content) + types["defines"] += define_matches + + # Debug the case where no classes or structs are found + # if len(types["classes"]) == 0 and len(types["structs"]) == 0 and len(types["defines"]) == 0: + # print(f"{file_path} missing things") + return types + + +def map_header_files(directory): + file_types_mapping = {} + for root, dirs, files in os.walk(directory): + if "thirdparty" in dirs: + dirs.remove("thirdparty") + if "tests" in dirs: + dirs.remove("tests") + if "test" in dirs: + dirs.remove("test") + if "misc" in dirs: + dirs.remove("misc") + if "gdextension" in dirs: + dirs.remove("gdextension") + for file in files: + if file.endswith(".h") or file.endswith(".hpp"): + relative_path = os.path.relpath(root, directory) + file_path = os.path.join(root, file) + file_types_mapping[f"{relative_path}/{file}"] = parse_header_file(file_path) + + return file_types_mapping + + +if __name__ == "__main__": + # Get current directory for godot-cpp + current_directory = os.path.join(os.getcwd(), "") + mapping_name = "" + if len(sys.argv) > 1: + mapping_name = "_godot" + current_directory = os.path.join(os.getcwd(), sys.argv[1]) + + file_types_mapping = map_header_files(current_directory) + with open(f"output_header_mapping{mapping_name}.json", "w") as json_file: + json.dump(file_types_mapping, json_file, indent=4) diff --git a/header_matcher.py b/header_matcher.py new file mode 100644 index 000000000..8dbdd5f53 --- /dev/null +++ b/header_matcher.py @@ -0,0 +1,33 @@ +import json +import os + +from compat_generator import map_header_files + + +def match_headers(mapping1, mapping2): + matches = {} + for header_file, data1 in mapping1.items(): + for header_file2, data2 in mapping2.items(): + # Check if classes/defines/structs in header_file1 are present in header_file2 + if header_file not in matches: + matches[header_file] = [] + if ( + any(class_name in data2["classes"] for class_name in data1["classes"]) + or any(define_name in data2["defines"] for define_name in data1["defines"]) + or any(define_name in data2["structs"] for define_name in data1["structs"]) + ): # or + # any(define_name in data2["enums"] for define_name in data1["enums"])): + matches[header_file].append(header_file2) + return matches + + +if __name__ == "__main__": + # Load the two header mappings + with open("output_header_mapping_godot.json", "r") as file: + mapping_godot = json.load(file) + file_types_mapping_godot_cpp_gen = map_header_files(os.path.join(os.getcwd(), "gen", "include")) + matches = match_headers(file_types_mapping_godot_cpp_gen, mapping_godot) + + # Optionally, you can save the matches to a file + with open("header_matches.json", "w") as outfile: + json.dump(matches, outfile, indent=4) diff --git a/include/godot_cpp/classes/editor_plugin_registration.hpp b/include/godot_cpp/classes/editor_plugin_registration.hpp index 7870bfc70..639e9f26e 100644 --- a/include/godot_cpp/classes/editor_plugin_registration.hpp +++ b/include/godot_cpp/classes/editor_plugin_registration.hpp @@ -31,6 +31,10 @@ #ifndef GODOT_EDITOR_PLUGIN_REGISTRATION_HPP #define GODOT_EDITOR_PLUGIN_REGISTRATION_HPP +#ifdef GODOT_MODULE +#include "editor/plugins/editor_plugin.h" +#else + #include namespace godot { @@ -59,4 +63,5 @@ class EditorPlugins { } // namespace godot +#endif #endif // GODOT_EDITOR_PLUGIN_REGISTRATION_HPP diff --git a/include/godot_cpp/classes/ref.hpp b/include/godot_cpp/classes/ref.hpp index 137b677bf..109300f32 100644 --- a/include/godot_cpp/classes/ref.hpp +++ b/include/godot_cpp/classes/ref.hpp @@ -31,6 +31,10 @@ #ifndef GODOT_REF_HPP #define GODOT_REF_HPP +#ifdef GODOT_MODULE +#include "core/object/ref_counted.h" +#else + #include #include @@ -281,4 +285,5 @@ struct GetTypeInfo &, typename EnableIf } // namespace godot +#endif #endif // GODOT_REF_HPP diff --git a/include/godot_cpp/classes/wrapped.hpp b/include/godot_cpp/classes/wrapped.hpp index a0bcec7b5..e03fdf3b7 100644 --- a/include/godot_cpp/classes/wrapped.hpp +++ b/include/godot_cpp/classes/wrapped.hpp @@ -31,6 +31,10 @@ #ifndef GODOT_WRAPPED_HPP #define GODOT_WRAPPED_HPP +#ifdef GODOT_MODULE +#include "core/object/object.h" +#else + #include #include @@ -506,4 +510,5 @@ public: #define GDVIRTUAL_IS_OVERRIDDEN(m_name) _gdvirtual_##m_name##_overridden() #define GDVIRTUAL_IS_OVERRIDDEN_PTR(m_obj, m_name) m_obj->_gdvirtual_##m_name##_overridden() +#endif #endif // GODOT_WRAPPED_HPP diff --git a/include/godot_cpp/core/binder_common.hpp b/include/godot_cpp/core/binder_common.hpp index 26ed4ca39..e8e161f3b 100644 --- a/include/godot_cpp/core/binder_common.hpp +++ b/include/godot_cpp/core/binder_common.hpp @@ -31,6 +31,10 @@ #ifndef GODOT_BINDER_COMMON_HPP #define GODOT_BINDER_COMMON_HPP +#ifdef GODOT_MODULE +#include "core/variant/binder_common.h" +#else + #include #include @@ -693,4 +697,5 @@ void call_with_ptr_args_static_method_ret(R (*p_method)(P...), const GDExtension #include #include +#endif #endif // GODOT_BINDER_COMMON_HPP diff --git a/include/godot_cpp/core/builtin_ptrcall.hpp b/include/godot_cpp/core/builtin_ptrcall.hpp index 286051fa8..45868158a 100644 --- a/include/godot_cpp/core/builtin_ptrcall.hpp +++ b/include/godot_cpp/core/builtin_ptrcall.hpp @@ -31,6 +31,9 @@ #ifndef GODOT_BUILTIN_PTRCALL_HPP #define GODOT_BUILTIN_PTRCALL_HPP +#ifdef GODOT_MODULE +#else + #include #include @@ -89,4 +92,5 @@ T _call_builtin_ptr_getter(const GDExtensionPtrGetter getter, GDExtensionConstTy } // namespace godot +#endif #endif // GODOT_BUILTIN_PTRCALL_HPP diff --git a/include/godot_cpp/core/class_db.hpp b/include/godot_cpp/core/class_db.hpp index 85bc0fb7b..8ff5555ba 100644 --- a/include/godot_cpp/core/class_db.hpp +++ b/include/godot_cpp/core/class_db.hpp @@ -31,6 +31,11 @@ #ifndef GODOT_CLASS_DB_HPP #define GODOT_CLASS_DB_HPP +#ifdef GODOT_MODULE +#include "core/core_bind.h" +#include "core/object/class_db.h" +#else + #include #include @@ -358,4 +363,5 @@ MethodBind *ClassDB::bind_vararg_method(uint32_t p_flags, StringName p_name, M p CLASSDB_SINGLETON_VARIANT_CAST; +#endif #endif // GODOT_CLASS_DB_HPP diff --git a/include/godot_cpp/core/defs.hpp b/include/godot_cpp/core/defs.hpp index 16812c2b4..14e9d0bad 100644 --- a/include/godot_cpp/core/defs.hpp +++ b/include/godot_cpp/core/defs.hpp @@ -31,6 +31,11 @@ #ifndef GODOT_DEFS_HPP #define GODOT_DEFS_HPP +#ifdef GODOT_MODULE +#include "core/math/math_defs.h" +#include "core/typedefs.h" +#else + #include #include #include @@ -127,4 +132,5 @@ struct BuildIndexSequence : BuildIndexSequence {}; template struct BuildIndexSequence<0, Is...> : IndexSequence {}; +#endif #endif // GODOT_DEFS_HPP diff --git a/include/godot_cpp/core/engine_ptrcall.hpp b/include/godot_cpp/core/engine_ptrcall.hpp index 555806b8e..2bafa9d70 100644 --- a/include/godot_cpp/core/engine_ptrcall.hpp +++ b/include/godot_cpp/core/engine_ptrcall.hpp @@ -31,6 +31,9 @@ #ifndef GODOT_ENGINE_PTRCALL_HPP #define GODOT_ENGINE_PTRCALL_HPP +#ifdef GODOT_MODULE +#else + #include #include @@ -94,4 +97,5 @@ void _call_utility_no_ret(const GDExtensionPtrUtilityFunction func, const Args & } // namespace godot +#endif #endif // GODOT_ENGINE_PTRCALL_HPP diff --git a/include/godot_cpp/core/error_macros.hpp b/include/godot_cpp/core/error_macros.hpp index a27c2cb02..70be14c0e 100644 --- a/include/godot_cpp/core/error_macros.hpp +++ b/include/godot_cpp/core/error_macros.hpp @@ -31,6 +31,10 @@ #ifndef GODOT_ERROR_MACROS_HPP #define GODOT_ERROR_MACROS_HPP +#ifdef GODOT_MODULE +#include "core/error/error_macros.h" +#else + #include #include @@ -803,4 +807,5 @@ void _err_flush_stdout(); #define CHECK_METHOD_BIND(m_mb) #endif +#endif #endif // GODOT_ERROR_MACROS_HPP diff --git a/include/godot_cpp/core/math.hpp b/include/godot_cpp/core/math.hpp index 1949360a9..d625111ce 100644 --- a/include/godot_cpp/core/math.hpp +++ b/include/godot_cpp/core/math.hpp @@ -31,6 +31,11 @@ #ifndef GODOT_MATH_HPP #define GODOT_MATH_HPP +#ifdef GODOT_MODULE +#include "core/math/math_defs.h" +#include "core/typedefs.h" +#else + #include #include @@ -816,4 +821,5 @@ inline float snap_scalar_separation(float p_offset, float p_step, float p_target } // namespace Math } // namespace godot +#endif #endif // GODOT_MATH_HPP diff --git a/include/godot_cpp/core/memory.hpp b/include/godot_cpp/core/memory.hpp index 1934ee458..b79571916 100644 --- a/include/godot_cpp/core/memory.hpp +++ b/include/godot_cpp/core/memory.hpp @@ -31,6 +31,10 @@ #ifndef GODOT_MEMORY_HPP #define GODOT_MEMORY_HPP +#ifdef GODOT_MODULE +#include "core/os/memory.h" +#else + #include #include @@ -217,4 +221,5 @@ struct _GlobalNilClass { } // namespace godot +#endif #endif // GODOT_MEMORY_HPP diff --git a/include/godot_cpp/core/method_bind.hpp b/include/godot_cpp/core/method_bind.hpp index f2da66ce0..71da1915b 100644 --- a/include/godot_cpp/core/method_bind.hpp +++ b/include/godot_cpp/core/method_bind.hpp @@ -31,6 +31,10 @@ #ifndef GODOT_METHOD_BIND_HPP #define GODOT_METHOD_BIND_HPP +#ifdef GODOT_MODULE +#include "core/object/method_bind.h" +#else + #include #include @@ -732,4 +736,5 @@ MethodBind *create_static_method_bind(R (*p_method)(P...)) { } // namespace godot +#endif #endif // GODOT_METHOD_BIND_HPP diff --git a/include/godot_cpp/core/method_ptrcall.hpp b/include/godot_cpp/core/method_ptrcall.hpp index 8889e8214..fae4f6c12 100644 --- a/include/godot_cpp/core/method_ptrcall.hpp +++ b/include/godot_cpp/core/method_ptrcall.hpp @@ -31,6 +31,10 @@ #ifndef GODOT_METHOD_PTRCALL_HPP #define GODOT_METHOD_PTRCALL_HPP +#ifdef GODOT_MODULE +#include "core/variant/method_ptrcall.h" +#else + #include #include @@ -235,4 +239,5 @@ GDVIRTUAL_NATIVE_PTR(double); } // namespace godot +#endif #endif // GODOT_METHOD_PTRCALL_HPP diff --git a/include/godot_cpp/core/mutex_lock.hpp b/include/godot_cpp/core/mutex_lock.hpp index aa81d4dcd..c30400d87 100644 --- a/include/godot_cpp/core/mutex_lock.hpp +++ b/include/godot_cpp/core/mutex_lock.hpp @@ -31,6 +31,10 @@ #ifndef GODOT_MUTEX_LOCK_HPP #define GODOT_MUTEX_LOCK_HPP +#ifdef GODOT_MODULE +#include "core/os/mutex.h" +#else + #include namespace godot { @@ -56,4 +60,5 @@ class MutexLock { } // namespace godot +#endif #endif // GODOT_MUTEX_LOCK_HPP diff --git a/include/godot_cpp/core/object.hpp b/include/godot_cpp/core/object.hpp index 917ec6cc4..d0c914bf1 100644 --- a/include/godot_cpp/core/object.hpp +++ b/include/godot_cpp/core/object.hpp @@ -31,6 +31,10 @@ #ifndef GODOT_OBJECT_HPP #define GODOT_OBJECT_HPP +#ifdef GODOT_MODULE +#include "core/object/object.h" +#else + #include #include @@ -149,4 +153,5 @@ const T *Object::cast_to(const Object *p_object) { } // namespace godot +#endif #endif // GODOT_OBJECT_HPP diff --git a/include/godot_cpp/core/object_id.hpp b/include/godot_cpp/core/object_id.hpp index 9f3bc96ff..8aa4e03a3 100644 --- a/include/godot_cpp/core/object_id.hpp +++ b/include/godot_cpp/core/object_id.hpp @@ -31,6 +31,10 @@ #ifndef GODOT_OBJECT_ID_HPP #define GODOT_OBJECT_ID_HPP +#ifdef GODOT_MODULE +#include "core/object/object_id.h" +#else + #include namespace godot { @@ -59,4 +63,5 @@ class ObjectID { } // namespace godot +#endif #endif // GODOT_OBJECT_ID_HPP diff --git a/include/godot_cpp/core/property_info.hpp b/include/godot_cpp/core/property_info.hpp index dd71d48af..f58976e91 100644 --- a/include/godot_cpp/core/property_info.hpp +++ b/include/godot_cpp/core/property_info.hpp @@ -31,6 +31,10 @@ #ifndef GODOT_PROPERTY_INFO_HPP #define GODOT_PROPERTY_INFO_HPP +#ifdef GODOT_MODULE +#include "core/object/object.h" +#else + #include #include @@ -129,4 +133,5 @@ struct PropertyInfo { } // namespace godot +#endif #endif // GODOT_PROPERTY_INFO_HPP diff --git a/include/godot_cpp/core/type_info.hpp b/include/godot_cpp/core/type_info.hpp index b78f7e73b..53ca71535 100644 --- a/include/godot_cpp/core/type_info.hpp +++ b/include/godot_cpp/core/type_info.hpp @@ -31,6 +31,10 @@ #ifndef GODOT_TYPE_INFO_HPP #define GODOT_TYPE_INFO_HPP +#ifdef GODOT_MODULE +#include "core/variant/type_info.h" +#else + #include #include #include @@ -417,4 +421,5 @@ MAKE_TYPED_ARRAY_INFO(IPAddress, Variant::STRING) } // namespace godot +#endif #endif // GODOT_TYPE_INFO_HPP diff --git a/include/godot_cpp/godot.hpp b/include/godot_cpp/godot.hpp index 61dbb9606..655a45935 100644 --- a/include/godot_cpp/godot.hpp +++ b/include/godot_cpp/godot.hpp @@ -31,6 +31,10 @@ #ifndef GODOT_GODOT_HPP #define GODOT_GODOT_HPP +#ifdef GODOT_MODULE +#include "modules/register_module_types.h" +#else + #include namespace godot { @@ -263,4 +267,5 @@ class GDExtensionBinding { } // namespace godot +#endif #endif // GODOT_GODOT_HPP diff --git a/include/godot_cpp/templates/cowdata.hpp b/include/godot_cpp/templates/cowdata.hpp index dcb74eccc..362c4fad4 100644 --- a/include/godot_cpp/templates/cowdata.hpp +++ b/include/godot_cpp/templates/cowdata.hpp @@ -31,6 +31,10 @@ #ifndef GODOT_COWDATA_HPP #define GODOT_COWDATA_HPP +#ifdef GODOT_MODULE +#include "core/templates/cowdata.h" +#else + #include #include #include @@ -489,4 +493,5 @@ CowData::~CowData() { } // namespace godot +#endif #endif // GODOT_COWDATA_HPP diff --git a/include/godot_cpp/templates/hash_map.hpp b/include/godot_cpp/templates/hash_map.hpp index 59cd8e0b0..49868ca5e 100644 --- a/include/godot_cpp/templates/hash_map.hpp +++ b/include/godot_cpp/templates/hash_map.hpp @@ -31,6 +31,10 @@ #ifndef GODOT_HASH_MAP_HPP #define GODOT_HASH_MAP_HPP +#ifdef GODOT_MODULE +#include "core/templates/hash_map.h" +#else + #include #include #include @@ -588,4 +592,5 @@ class HashMap { } // namespace godot +#endif #endif // GODOT_HASH_MAP_HPP diff --git a/include/godot_cpp/templates/hash_set.hpp b/include/godot_cpp/templates/hash_set.hpp index 1845a1bb4..4550d3ce9 100644 --- a/include/godot_cpp/templates/hash_set.hpp +++ b/include/godot_cpp/templates/hash_set.hpp @@ -31,6 +31,10 @@ #ifndef GODOT_HASH_SET_HPP #define GODOT_HASH_SET_HPP +#ifdef GODOT_MODULE +#include "core/templates/hash_set.h" +#else + #include #include #include @@ -474,4 +478,5 @@ class HashSet { } // namespace godot +#endif #endif // GODOT_HASH_SET_HPP diff --git a/include/godot_cpp/templates/hashfuncs.hpp b/include/godot_cpp/templates/hashfuncs.hpp index 40b10a9e2..056310c1e 100644 --- a/include/godot_cpp/templates/hashfuncs.hpp +++ b/include/godot_cpp/templates/hashfuncs.hpp @@ -31,6 +31,10 @@ #ifndef GODOT_HASHFUNCS_HPP #define GODOT_HASHFUNCS_HPP +#ifdef GODOT_MODULE +#include "core/templates/hashfuncs.h" +#else + // Needed for fastmod. #if defined(_MSC_VER) #include @@ -523,4 +527,5 @@ static _FORCE_INLINE_ uint32_t fastmod(const uint32_t n, const uint64_t c, const } // namespace godot +#endif #endif // GODOT_HASHFUNCS_HPP diff --git a/include/godot_cpp/templates/list.hpp b/include/godot_cpp/templates/list.hpp index fa5960565..06390cfc5 100644 --- a/include/godot_cpp/templates/list.hpp +++ b/include/godot_cpp/templates/list.hpp @@ -31,6 +31,10 @@ #ifndef GODOT_LIST_HPP #define GODOT_LIST_HPP +#ifdef GODOT_MODULE +#include "core/templates/list.h" +#else + #include #include #include @@ -784,4 +788,5 @@ class List { } // namespace godot +#endif #endif // GODOT_LIST_HPP diff --git a/include/godot_cpp/templates/local_vector.hpp b/include/godot_cpp/templates/local_vector.hpp index c5481e48a..450589814 100644 --- a/include/godot_cpp/templates/local_vector.hpp +++ b/include/godot_cpp/templates/local_vector.hpp @@ -31,6 +31,10 @@ #ifndef GODOT_LOCAL_VECTOR_HPP #define GODOT_LOCAL_VECTOR_HPP +#ifdef GODOT_MODULE +#include "core/templates/local_vector.h" +#else + #include #include #include @@ -340,4 +344,5 @@ using TightLocalVector = LocalVector; } // namespace godot +#endif #endif // GODOT_LOCAL_VECTOR_HPP diff --git a/include/godot_cpp/templates/pair.hpp b/include/godot_cpp/templates/pair.hpp index f87541305..6bb127e59 100644 --- a/include/godot_cpp/templates/pair.hpp +++ b/include/godot_cpp/templates/pair.hpp @@ -31,6 +31,10 @@ #ifndef GODOT_PAIR_HPP #define GODOT_PAIR_HPP +#ifdef GODOT_MODULE +#include "core/templates/pair.h" +#else + namespace godot { template @@ -104,4 +108,5 @@ struct KeyValueSort { } // namespace godot +#endif #endif // GODOT_PAIR_HPP diff --git a/include/godot_cpp/templates/rb_map.hpp b/include/godot_cpp/templates/rb_map.hpp index 6ab71fd7e..cb5e14fb6 100644 --- a/include/godot_cpp/templates/rb_map.hpp +++ b/include/godot_cpp/templates/rb_map.hpp @@ -31,6 +31,10 @@ #ifndef GODOT_RB_MAP_HPP #define GODOT_RB_MAP_HPP +#ifdef GODOT_MODULE +#include "core/templates/rb_map.h" +#else + #include #include #include @@ -762,4 +766,5 @@ class RBMap { } // namespace godot +#endif #endif // GODOT_RB_MAP_HPP diff --git a/include/godot_cpp/templates/rb_set.hpp b/include/godot_cpp/templates/rb_set.hpp index 69aa8d7f9..5bb59a6cb 100644 --- a/include/godot_cpp/templates/rb_set.hpp +++ b/include/godot_cpp/templates/rb_set.hpp @@ -31,6 +31,10 @@ #ifndef GODOT_RB_SET_HPP #define GODOT_RB_SET_HPP +#ifdef GODOT_MODULE +#include "core/templates/rb_set.h" +#else + #include // based on the very nice implementation of rb-trees by: @@ -711,4 +715,5 @@ class RBSet { } // namespace godot +#endif #endif // GODOT_RB_SET_HPP diff --git a/include/godot_cpp/templates/rid_owner.hpp b/include/godot_cpp/templates/rid_owner.hpp index 1dd4a3933..5a89c32b9 100644 --- a/include/godot_cpp/templates/rid_owner.hpp +++ b/include/godot_cpp/templates/rid_owner.hpp @@ -31,6 +31,10 @@ #ifndef GODOT_RID_OWNER_HPP #define GODOT_RID_OWNER_HPP +#ifdef GODOT_MODULE +#include "core/templates/rid_owner.h" +#else + #include #include #include @@ -462,4 +466,5 @@ class RID_Owner { } // namespace godot +#endif #endif // GODOT_RID_OWNER_HPP diff --git a/include/godot_cpp/templates/safe_refcount.hpp b/include/godot_cpp/templates/safe_refcount.hpp index 98cb04b20..c2d5eb93b 100644 --- a/include/godot_cpp/templates/safe_refcount.hpp +++ b/include/godot_cpp/templates/safe_refcount.hpp @@ -31,6 +31,10 @@ #ifndef GODOT_SAFE_REFCOUNT_HPP #define GODOT_SAFE_REFCOUNT_HPP +#ifdef GODOT_MODULE +#include "core/templates/safe_refcount.h" +#else + #if !defined(NO_THREADS) #include @@ -332,4 +336,5 @@ class SafeRefCount { } // namespace godot +#endif #endif // GODOT_SAFE_REFCOUNT_HPP diff --git a/include/godot_cpp/templates/search_array.hpp b/include/godot_cpp/templates/search_array.hpp index 11a9db525..0b2989262 100644 --- a/include/godot_cpp/templates/search_array.hpp +++ b/include/godot_cpp/templates/search_array.hpp @@ -31,6 +31,10 @@ #ifndef GODOT_SEARCH_ARRAY_HPP #define GODOT_SEARCH_ARRAY_HPP +#ifdef GODOT_MODULE +#include "core/templates/search_array.h" +#else + #include namespace godot { @@ -68,4 +72,5 @@ class SearchArray { } // namespace godot +#endif #endif // GODOT_SEARCH_ARRAY_HPP diff --git a/include/godot_cpp/templates/self_list.hpp b/include/godot_cpp/templates/self_list.hpp index f7a65f689..9d942d36b 100644 --- a/include/godot_cpp/templates/self_list.hpp +++ b/include/godot_cpp/templates/self_list.hpp @@ -31,6 +31,10 @@ #ifndef GODOT_SELF_LIST_HPP #define GODOT_SELF_LIST_HPP +#ifdef GODOT_MODULE +#include "core/templates/self_list.h" +#else + #include #include @@ -140,4 +144,5 @@ class SelfList { } // namespace godot +#endif #endif // GODOT_SELF_LIST_HPP diff --git a/include/godot_cpp/templates/sort_array.hpp b/include/godot_cpp/templates/sort_array.hpp index 7ce5c7842..12bbf6fd5 100644 --- a/include/godot_cpp/templates/sort_array.hpp +++ b/include/godot_cpp/templates/sort_array.hpp @@ -31,6 +31,10 @@ #ifndef GODOT_SORT_ARRAY_HPP #define GODOT_SORT_ARRAY_HPP +#ifdef GODOT_MODULE +#include "core/templates/sort_array.h" +#else + #include namespace godot { @@ -320,4 +324,5 @@ class SortArray { } // namespace godot +#endif #endif // GODOT_SORT_ARRAY_HPP diff --git a/include/godot_cpp/templates/spin_lock.hpp b/include/godot_cpp/templates/spin_lock.hpp index 530d545e3..12050ac22 100644 --- a/include/godot_cpp/templates/spin_lock.hpp +++ b/include/godot_cpp/templates/spin_lock.hpp @@ -31,6 +31,10 @@ #ifndef GODOT_SPIN_LOCK_HPP #define GODOT_SPIN_LOCK_HPP +#ifdef GODOT_MODULE +#include "core/os/spin_lock.h" +#else + #include namespace godot { @@ -51,4 +55,5 @@ class SpinLock { } // namespace godot +#endif #endif // GODOT_SPIN_LOCK_HPP diff --git a/include/godot_cpp/templates/thread_work_pool.hpp b/include/godot_cpp/templates/thread_work_pool.hpp index cb20c6e97..093df5aeb 100644 --- a/include/godot_cpp/templates/thread_work_pool.hpp +++ b/include/godot_cpp/templates/thread_work_pool.hpp @@ -31,6 +31,10 @@ #ifndef GODOT_THREAD_WORK_POOL_HPP #define GODOT_THREAD_WORK_POOL_HPP +#ifdef GODOT_MODULE +#include "core/object/worker_thread_pool.h" +#else + #include #include #include @@ -202,4 +206,5 @@ class ThreadWorkPool { } // namespace godot +#endif #endif // GODOT_THREAD_WORK_POOL_HPP diff --git a/include/godot_cpp/templates/vector.hpp b/include/godot_cpp/templates/vector.hpp index aaa84f338..674819257 100644 --- a/include/godot_cpp/templates/vector.hpp +++ b/include/godot_cpp/templates/vector.hpp @@ -31,6 +31,10 @@ #ifndef GODOT_VECTOR_HPP #define GODOT_VECTOR_HPP +#ifdef GODOT_MODULE +#include "core/templates/vector.h" +#else + /** * @class Vector * Vector container. Regular Vector Container. Use with care and for smaller arrays when possible. Use Vector for large arrays. @@ -333,4 +337,5 @@ void Vector::fill(T p_elem) { } // namespace godot +#endif #endif // GODOT_VECTOR_HPP diff --git a/include/godot_cpp/templates/vmap.hpp b/include/godot_cpp/templates/vmap.hpp index 926ccd390..f28d8bc6c 100644 --- a/include/godot_cpp/templates/vmap.hpp +++ b/include/godot_cpp/templates/vmap.hpp @@ -31,6 +31,10 @@ #ifndef GODOT_VMAP_HPP #define GODOT_VMAP_HPP +#ifdef GODOT_MODULE +#include "core/templates/vmap.h" +#else + #include namespace godot { @@ -201,4 +205,5 @@ class VMap { } // namespace godot +#endif #endif // GODOT_VMAP_HPP diff --git a/include/godot_cpp/templates/vset.hpp b/include/godot_cpp/templates/vset.hpp index ce21ba83f..2064b896e 100644 --- a/include/godot_cpp/templates/vset.hpp +++ b/include/godot_cpp/templates/vset.hpp @@ -31,6 +31,10 @@ #ifndef GODOT_VSET_HPP #define GODOT_VSET_HPP +#ifdef GODOT_MODULE +#include "core/templates/vset.h" +#else + #include namespace godot { @@ -142,4 +146,5 @@ class VSet { } // namespace godot +#endif #endif // GODOT_VSET_HPP diff --git a/include/godot_cpp/variant/aabb.hpp b/include/godot_cpp/variant/aabb.hpp index b827112af..e8010024c 100644 --- a/include/godot_cpp/variant/aabb.hpp +++ b/include/godot_cpp/variant/aabb.hpp @@ -31,6 +31,10 @@ #ifndef GODOT_AABB_HPP #define GODOT_AABB_HPP +#ifdef GODOT_MODULE +#include "core/math/aabb.h" +#else + #include #include @@ -492,4 +496,5 @@ AABB AABB::quantized(real_t p_unit) const { } // namespace godot +#endif #endif // GODOT_AABB_HPP diff --git a/include/godot_cpp/variant/array_helpers.hpp b/include/godot_cpp/variant/array_helpers.hpp index 3d948aab5..956c655d7 100644 --- a/include/godot_cpp/variant/array_helpers.hpp +++ b/include/godot_cpp/variant/array_helpers.hpp @@ -31,6 +31,9 @@ #ifndef GODOT_ARRAY_HELPERS_HPP #define GODOT_ARRAY_HELPERS_HPP +#ifdef GODOT_MODULE +#else + namespace godot { namespace helpers { template @@ -52,4 +55,5 @@ T append_all(T appendable) { } // namespace helpers } // namespace godot +#endif #endif // GODOT_ARRAY_HELPERS_HPP diff --git a/include/godot_cpp/variant/basis.hpp b/include/godot_cpp/variant/basis.hpp index f3ebe15fe..a273d7ac0 100644 --- a/include/godot_cpp/variant/basis.hpp +++ b/include/godot_cpp/variant/basis.hpp @@ -31,6 +31,10 @@ #ifndef GODOT_BASIS_HPP #define GODOT_BASIS_HPP +#ifdef GODOT_MODULE +#include "core/math/basis.h" +#else + #include #include #include @@ -316,4 +320,5 @@ real_t Basis::determinant() const { } // namespace godot +#endif #endif // GODOT_BASIS_HPP diff --git a/include/godot_cpp/variant/callable_custom.hpp b/include/godot_cpp/variant/callable_custom.hpp index 48a814221..5a474079d 100644 --- a/include/godot_cpp/variant/callable_custom.hpp +++ b/include/godot_cpp/variant/callable_custom.hpp @@ -31,6 +31,10 @@ #ifndef GODOT_CALLABLE_CUSTOM_HPP #define GODOT_CALLABLE_CUSTOM_HPP +#ifdef GODOT_MODULE +#include "core/variant/callable.h" +#else + #include #include @@ -62,4 +66,5 @@ class CallableCustom : public CallableCustomBase { } // namespace godot +#endif #endif // GODOT_CALLABLE_CUSTOM_HPP diff --git a/include/godot_cpp/variant/callable_method_pointer.hpp b/include/godot_cpp/variant/callable_method_pointer.hpp index f3d688b45..775f1ef80 100644 --- a/include/godot_cpp/variant/callable_method_pointer.hpp +++ b/include/godot_cpp/variant/callable_method_pointer.hpp @@ -31,6 +31,10 @@ #ifndef GODOT_CALLABLE_METHOD_POINTER_HPP #define GODOT_CALLABLE_METHOD_POINTER_HPP +#ifdef GODOT_MODULE +#include "core/object/callable_method_pointer.h" +#else + #include #include @@ -270,4 +274,5 @@ Callable create_custom_callable_static_function_pointer(R (*p_method)(P...)) { } // namespace godot +#endif #endif // GODOT_CALLABLE_METHOD_POINTER_HPP diff --git a/include/godot_cpp/variant/char_string.hpp b/include/godot_cpp/variant/char_string.hpp index 991c0392a..c245a5f8c 100644 --- a/include/godot_cpp/variant/char_string.hpp +++ b/include/godot_cpp/variant/char_string.hpp @@ -31,6 +31,10 @@ #ifndef GODOT_CHAR_STRING_HPP #define GODOT_CHAR_STRING_HPP +#ifdef GODOT_MODULE +#include "core/string/ustring.h" +#else + #include #include @@ -139,4 +143,5 @@ typedef CharStringT CharWideString; } // namespace godot +#endif #endif // GODOT_CHAR_STRING_HPP diff --git a/include/godot_cpp/variant/char_utils.hpp b/include/godot_cpp/variant/char_utils.hpp index 066f7945d..97562c43f 100644 --- a/include/godot_cpp/variant/char_utils.hpp +++ b/include/godot_cpp/variant/char_utils.hpp @@ -31,6 +31,10 @@ #ifndef GODOT_CHAR_UTILS_HPP #define GODOT_CHAR_UTILS_HPP +#ifdef GODOT_MODULE +#include "core/string/char_utils.h" +#else + static _FORCE_INLINE_ bool is_ascii_upper_case(char32_t c) { return (c >= 'A' && c <= 'Z'); } @@ -87,4 +91,5 @@ static _FORCE_INLINE_ bool is_underscore(char32_t p_char) { return (p_char == '_'); } +#endif #endif // GODOT_CHAR_UTILS_HPP diff --git a/include/godot_cpp/variant/color.hpp b/include/godot_cpp/variant/color.hpp index 0e837bc9f..c563777da 100644 --- a/include/godot_cpp/variant/color.hpp +++ b/include/godot_cpp/variant/color.hpp @@ -31,6 +31,10 @@ #ifndef GODOT_COLOR_HPP #define GODOT_COLOR_HPP +#ifdef GODOT_MODULE +#include "core/math/color.h" +#else + #include namespace godot { @@ -286,4 +290,5 @@ _FORCE_INLINE_ Color operator*(float p_scalar, const Color &p_color) { } // namespace godot +#endif #endif // GODOT_COLOR_HPP diff --git a/include/godot_cpp/variant/color_names.inc.hpp b/include/godot_cpp/variant/color_names.inc.hpp index d7708e5d6..1f6c1e856 100644 --- a/include/godot_cpp/variant/color_names.inc.hpp +++ b/include/godot_cpp/variant/color_names.inc.hpp @@ -31,6 +31,10 @@ #ifndef GODOT_COLOR_NAMES_INC_HPP #define GODOT_COLOR_NAMES_INC_HPP +#ifdef GODOT_MODULE +#include "core/math/color_names.inc" +#else + namespace godot { // Names from https://en.wikipedia.org/wiki/X11_color_names @@ -193,4 +197,5 @@ static NamedColor named_colors[] = { } // namespace godot +#endif #endif // GODOT_COLOR_NAMES_INC_HPP diff --git a/include/godot_cpp/variant/plane.hpp b/include/godot_cpp/variant/plane.hpp index 829f801f4..37a37a0d1 100644 --- a/include/godot_cpp/variant/plane.hpp +++ b/include/godot_cpp/variant/plane.hpp @@ -31,6 +31,10 @@ #ifndef GODOT_PLANE_HPP #define GODOT_PLANE_HPP +#ifdef GODOT_MODULE +#include "core/math/plane.h" +#else + #include #include @@ -138,4 +142,5 @@ bool Plane::operator!=(const Plane &p_plane) const { } // namespace godot +#endif #endif // GODOT_PLANE_HPP diff --git a/include/godot_cpp/variant/projection.hpp b/include/godot_cpp/variant/projection.hpp index 1de6c0244..af908cee7 100644 --- a/include/godot_cpp/variant/projection.hpp +++ b/include/godot_cpp/variant/projection.hpp @@ -31,6 +31,10 @@ #ifndef GODOT_PROJECTION_HPP #define GODOT_PROJECTION_HPP +#ifdef GODOT_MODULE +#include "core/math/projection.h" +#else + #include #include #include @@ -168,4 +172,5 @@ Vector3 Projection::xform(const Vector3 &p_vec3) const { } // namespace godot +#endif #endif // GODOT_PROJECTION_HPP diff --git a/include/godot_cpp/variant/quaternion.hpp b/include/godot_cpp/variant/quaternion.hpp index 5de91b207..d35a0ba82 100644 --- a/include/godot_cpp/variant/quaternion.hpp +++ b/include/godot_cpp/variant/quaternion.hpp @@ -31,6 +31,10 @@ #ifndef GODOT_QUATERNION_HPP #define GODOT_QUATERNION_HPP +#ifdef GODOT_MODULE +#include "core/math/quaternion.h" +#else + #include #include @@ -235,4 +239,5 @@ _FORCE_INLINE_ Quaternion operator*(const real_t &p_real, const Quaternion &p_qu } // namespace godot +#endif #endif // GODOT_QUATERNION_HPP diff --git a/include/godot_cpp/variant/rect2.hpp b/include/godot_cpp/variant/rect2.hpp index 31c81aa27..d77f24bfb 100644 --- a/include/godot_cpp/variant/rect2.hpp +++ b/include/godot_cpp/variant/rect2.hpp @@ -31,6 +31,10 @@ #ifndef GODOT_RECT2_HPP #define GODOT_RECT2_HPP +#ifdef GODOT_MODULE +#include "core/math/rect2.h" +#else + #include #include @@ -370,4 +374,5 @@ struct _NO_DISCARD_ Rect2 { } // namespace godot +#endif #endif // GODOT_RECT2_HPP diff --git a/include/godot_cpp/variant/rect2i.hpp b/include/godot_cpp/variant/rect2i.hpp index 57b090592..8dd21cbda 100644 --- a/include/godot_cpp/variant/rect2i.hpp +++ b/include/godot_cpp/variant/rect2i.hpp @@ -31,6 +31,10 @@ #ifndef GODOT_RECT2I_HPP #define GODOT_RECT2I_HPP +#ifdef GODOT_MODULE +#include "core/math/rect2i.h" +#else + #include #include @@ -242,4 +246,5 @@ struct _NO_DISCARD_ Rect2i { } // namespace godot +#endif #endif // GODOT_RECT2I_HPP diff --git a/include/godot_cpp/variant/transform2d.hpp b/include/godot_cpp/variant/transform2d.hpp index d73323f31..655149fe4 100644 --- a/include/godot_cpp/variant/transform2d.hpp +++ b/include/godot_cpp/variant/transform2d.hpp @@ -31,6 +31,10 @@ #ifndef GODOT_TRANSFORM2D_HPP #define GODOT_TRANSFORM2D_HPP +#ifdef GODOT_MODULE +#include "core/math/transform_2d.h" +#else + #include #include #include @@ -248,4 +252,5 @@ PackedVector2Array Transform2D::xform_inv(const PackedVector2Array &p_array) con } // namespace godot +#endif #endif // GODOT_TRANSFORM2D_HPP diff --git a/include/godot_cpp/variant/transform3d.hpp b/include/godot_cpp/variant/transform3d.hpp index 6fa5999ed..eae994d24 100644 --- a/include/godot_cpp/variant/transform3d.hpp +++ b/include/godot_cpp/variant/transform3d.hpp @@ -31,6 +31,10 @@ #ifndef GODOT_TRANSFORM3D_HPP #define GODOT_TRANSFORM3D_HPP +#ifdef GODOT_MODULE +#include "core/math/transform_3d.h" +#else + #include #include #include @@ -273,4 +277,5 @@ _FORCE_INLINE_ Plane Transform3D::xform_inv_fast(const Plane &p_plane, const Tra } // namespace godot +#endif #endif // GODOT_TRANSFORM3D_HPP diff --git a/include/godot_cpp/variant/typed_array.hpp b/include/godot_cpp/variant/typed_array.hpp index 36bbcc971..7a8259669 100644 --- a/include/godot_cpp/variant/typed_array.hpp +++ b/include/godot_cpp/variant/typed_array.hpp @@ -31,6 +31,10 @@ #ifndef GODOT_TYPED_ARRAY_HPP #define GODOT_TYPED_ARRAY_HPP +#ifdef GODOT_MODULE +#include "core/variant/typed_array.h" +#else + #include #include @@ -139,4 +143,5 @@ MAKE_TYPED_ARRAY(PackedColorArray, Variant::PACKED_COLOR_ARRAY) } // namespace godot +#endif #endif // GODOT_TYPED_ARRAY_HPP diff --git a/include/godot_cpp/variant/variant.hpp b/include/godot_cpp/variant/variant.hpp index b0d57fbbd..c49e50592 100644 --- a/include/godot_cpp/variant/variant.hpp +++ b/include/godot_cpp/variant/variant.hpp @@ -31,6 +31,10 @@ #ifndef GODOT_VARIANT_HPP #define GODOT_VARIANT_HPP +#ifdef GODOT_MODULE +#include "core/variant/variant.h" +#else + #include #include @@ -367,4 +371,5 @@ using PackedRealArray = PackedFloat32Array; } // namespace godot +#endif #endif // GODOT_VARIANT_HPP diff --git a/include/godot_cpp/variant/vector2.hpp b/include/godot_cpp/variant/vector2.hpp index 8f08985f3..a6c2da851 100644 --- a/include/godot_cpp/variant/vector2.hpp +++ b/include/godot_cpp/variant/vector2.hpp @@ -31,6 +31,10 @@ #ifndef GODOT_VECTOR2_HPP #define GODOT_VECTOR2_HPP +#ifdef GODOT_MODULE +#include "core/math/vector2.h" +#else + #include #include @@ -331,4 +335,5 @@ typedef Vector2 Point2; } // namespace godot +#endif #endif // GODOT_VECTOR2_HPP diff --git a/include/godot_cpp/variant/vector2i.hpp b/include/godot_cpp/variant/vector2i.hpp index 0d787c3fc..ed2aba48b 100644 --- a/include/godot_cpp/variant/vector2i.hpp +++ b/include/godot_cpp/variant/vector2i.hpp @@ -31,6 +31,10 @@ #ifndef GODOT_VECTOR2I_HPP #define GODOT_VECTOR2I_HPP +#ifdef GODOT_MODULE +#include "core/math/vector2i.h" +#else + #include #include @@ -169,4 +173,5 @@ typedef Vector2i Point2i; } // namespace godot +#endif #endif // GODOT_VECTOR2I_HPP diff --git a/include/godot_cpp/variant/vector3.hpp b/include/godot_cpp/variant/vector3.hpp index f256c3895..c096b8b3c 100644 --- a/include/godot_cpp/variant/vector3.hpp +++ b/include/godot_cpp/variant/vector3.hpp @@ -31,6 +31,10 @@ #ifndef GODOT_VECTOR3_HPP #define GODOT_VECTOR3_HPP +#ifdef GODOT_MODULE +#include "core/math/vector3.h" +#else + #include #include @@ -538,4 +542,5 @@ Vector3 Vector3::reflect(const Vector3 &p_normal) const { } // namespace godot +#endif #endif // GODOT_VECTOR3_HPP diff --git a/include/godot_cpp/variant/vector3i.hpp b/include/godot_cpp/variant/vector3i.hpp index b2cdbbdfd..65a9ab43c 100644 --- a/include/godot_cpp/variant/vector3i.hpp +++ b/include/godot_cpp/variant/vector3i.hpp @@ -31,6 +31,10 @@ #ifndef GODOT_VECTOR3I_HPP #define GODOT_VECTOR3I_HPP +#ifdef GODOT_MODULE +#include "core/math/vector3i.h" +#else + #include #include @@ -340,4 +344,5 @@ void Vector3i::zero() { } // namespace godot +#endif #endif // GODOT_VECTOR3I_HPP diff --git a/include/godot_cpp/variant/vector4.hpp b/include/godot_cpp/variant/vector4.hpp index 866e522ba..77bb8229f 100644 --- a/include/godot_cpp/variant/vector4.hpp +++ b/include/godot_cpp/variant/vector4.hpp @@ -31,6 +31,10 @@ #ifndef GODOT_VECTOR4_HPP #define GODOT_VECTOR4_HPP +#ifdef GODOT_MODULE +#include "core/math/vector4.h" +#else + #include #include @@ -319,4 +323,5 @@ _FORCE_INLINE_ Vector4 operator*(const int64_t p_scalar, const Vector4 &p_vec) { } // namespace godot +#endif #endif // GODOT_VECTOR4_HPP diff --git a/include/godot_cpp/variant/vector4i.hpp b/include/godot_cpp/variant/vector4i.hpp index 8e9510fd0..abf224f55 100644 --- a/include/godot_cpp/variant/vector4i.hpp +++ b/include/godot_cpp/variant/vector4i.hpp @@ -31,6 +31,10 @@ #ifndef GODOT_VECTOR4I_HPP #define GODOT_VECTOR4I_HPP +#ifdef GODOT_MODULE +#include "core/math/vector4i.h" +#else + #include #include @@ -368,4 +372,5 @@ void Vector4i::zero() { } // namespace godot +#endif #endif // GODOT_VECTOR4I_HPP diff --git a/tools/godotcpp.py b/tools/godotcpp.py index b2a63dc1e..dda876301 100644 --- a/tools/godotcpp.py +++ b/tools/godotcpp.py @@ -228,6 +228,14 @@ def options(opts, env): validator=validate_file, ) ) + opts.Add( + PathVariable( + key="godot_repo", + help="Path to a custom directory containing Godot repository. Used to generate godot_compat bindings.", + default=env.get("godot_repo", ""), + validator=validate_dir, + ) + ) opts.Add( BoolVariable( key="generate_bindings",