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
pull/1415/head
Dragos Daian 2024-03-15 09:57:36 +01:00
parent 56571dc584
commit 9e7cec9f42
67 changed files with 540 additions and 1 deletions

View File

@ -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 <godot_cpp/classes/a_star_grid2d.hpp>
```
with
```cpp
#include <godot_compat/classes/a_star_grid2d.hpp>
```
Inside, this file will have code for both godot and godot-cpp:
```cpp
#ifdef GODOT_MODULE
#include <core/math/a_star_grid_2d.h>
#else
#include <godot_cpp/classes/a_star_grid2d.hpp>
#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.

View File

@ -5,6 +5,9 @@ import re
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 = []

75
compat_generator.py Normal file
View File

@ -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)

33
header_matcher.py Normal file
View File

@ -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)

View File

@ -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 <godot_cpp/templates/vector.hpp>
namespace godot {
@ -59,4 +63,5 @@ public:
} // namespace godot
#endif
#endif // GODOT_EDITOR_PLUGIN_REGISTRATION_HPP

View File

@ -31,6 +31,10 @@
#ifndef GODOT_REF_HPP
#define GODOT_REF_HPP
#ifdef GODOT_MODULE
#include "core/object/ref_counted.h"
#else
#include <godot_cpp/core/defs.hpp>
#include <godot_cpp/classes/object.hpp>
@ -281,4 +285,5 @@ struct GetTypeInfo<const Ref<T> &, typename EnableIf<TypeInherits<RefCounted, T>
} // namespace godot
#endif
#endif // GODOT_REF_HPP

View File

@ -31,6 +31,10 @@
#ifndef GODOT_WRAPPED_HPP
#define GODOT_WRAPPED_HPP
#ifdef GODOT_MODULE
#include "core/object/object.h"
#else
#include <godot_cpp/core/memory.hpp>
#include <godot_cpp/core/property_info.hpp>
@ -506,4 +510,5 @@ private:
#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

View File

@ -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 <gdextension_interface.h>
#include <godot_cpp/core/method_ptrcall.hpp>
@ -693,4 +697,5 @@ void call_with_ptr_args_static_method_ret(R (*p_method)(P...), const GDExtension
#include <godot_cpp/classes/global_constants_binds.hpp>
#include <godot_cpp/variant/builtin_binds.hpp>
#endif
#endif // GODOT_BINDER_COMMON_HPP

View File

@ -31,6 +31,9 @@
#ifndef GODOT_BUILTIN_PTRCALL_HPP
#define GODOT_BUILTIN_PTRCALL_HPP
#ifdef GODOT_MODULE
#else
#include <gdextension_interface.h>
#include <godot_cpp/core/object.hpp>
@ -89,4 +92,5 @@ T _call_builtin_ptr_getter(const GDExtensionPtrGetter getter, GDExtensionConstTy
} // namespace godot
#endif
#endif // GODOT_BUILTIN_PTRCALL_HPP

View File

@ -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 <gdextension_interface.h>
#include <godot_cpp/core/defs.hpp>
@ -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

View File

@ -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 <cstddef>
#include <cstdint>
#include <cstring>
@ -127,4 +132,5 @@ struct BuildIndexSequence : BuildIndexSequence<N - 1, N - 1, Is...> {};
template <size_t... Is>
struct BuildIndexSequence<0, Is...> : IndexSequence<Is...> {};
#endif
#endif // GODOT_DEFS_HPP

View File

@ -31,6 +31,9 @@
#ifndef GODOT_ENGINE_PTRCALL_HPP
#define GODOT_ENGINE_PTRCALL_HPP
#ifdef GODOT_MODULE
#else
#include <gdextension_interface.h>
#include <godot_cpp/core/binder_common.hpp>
@ -94,4 +97,5 @@ void _call_utility_no_ret(const GDExtensionPtrUtilityFunction func, const Args &
} // namespace godot
#endif
#endif // GODOT_ENGINE_PTRCALL_HPP

View File

@ -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 <godot_cpp/core/defs.hpp>
#include <atomic>
@ -803,4 +807,5 @@ void _err_flush_stdout();
#define CHECK_METHOD_BIND(m_mb)
#endif
#endif
#endif // GODOT_ERROR_MACROS_HPP

View File

@ -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 <godot_cpp/core/defs.hpp>
#include <gdextension_interface.h>
@ -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

View File

@ -31,6 +31,10 @@
#ifndef GODOT_MEMORY_HPP
#define GODOT_MEMORY_HPP
#ifdef GODOT_MODULE
#include "core/os/memory.h"
#else
#include <cstddef>
#include <cstdint>
@ -217,4 +221,5 @@ struct _GlobalNilClass {
} // namespace godot
#endif
#endif // GODOT_MEMORY_HPP

View File

@ -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 <godot_cpp/core/binder_common.hpp>
#include <godot_cpp/core/type_info.hpp>
@ -732,4 +736,5 @@ MethodBind *create_static_method_bind(R (*p_method)(P...)) {
} // namespace godot
#endif
#endif // GODOT_METHOD_BIND_HPP

View File

@ -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 <godot_cpp/core/defs.hpp>
#include <godot_cpp/core/object.hpp>
@ -235,4 +239,5 @@ GDVIRTUAL_NATIVE_PTR(double);
} // namespace godot
#endif
#endif // GODOT_METHOD_PTRCALL_HPP

View File

@ -31,6 +31,10 @@
#ifndef GODOT_MUTEX_LOCK_HPP
#define GODOT_MUTEX_LOCK_HPP
#ifdef GODOT_MODULE
#include "core/os/mutex.h"
#else
#include <godot_cpp/classes/mutex.hpp>
namespace godot {
@ -56,4 +60,5 @@ public:
} // namespace godot
#endif
#endif // GODOT_MUTEX_LOCK_HPP

View File

@ -31,6 +31,10 @@
#ifndef GODOT_OBJECT_HPP
#define GODOT_OBJECT_HPP
#ifdef GODOT_MODULE
#include "core/object/object.h"
#else
#include <godot_cpp/core/defs.hpp>
#include <godot_cpp/core/object_id.hpp>
@ -149,4 +153,5 @@ const T *Object::cast_to(const Object *p_object) {
} // namespace godot
#endif
#endif // GODOT_OBJECT_HPP

View File

@ -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 <godot_cpp/core/defs.hpp>
namespace godot {
@ -59,4 +63,5 @@ public:
} // namespace godot
#endif
#endif // GODOT_OBJECT_ID_HPP

View File

@ -31,6 +31,10 @@
#ifndef GODOT_PROPERTY_INFO_HPP
#define GODOT_PROPERTY_INFO_HPP
#ifdef GODOT_MODULE
#include "core/object/object.h"
#else
#include <godot_cpp/core/defs.hpp>
#include <godot_cpp/classes/global_constants.hpp>
@ -129,4 +133,5 @@ struct PropertyInfo {
} // namespace godot
#endif
#endif // GODOT_PROPERTY_INFO_HPP

View File

@ -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 <godot_cpp/core/object.hpp>
#include <godot_cpp/variant/typed_array.hpp>
#include <godot_cpp/variant/variant.hpp>
@ -417,4 +421,5 @@ MAKE_TYPED_ARRAY_INFO(IPAddress, Variant::STRING)
} // namespace godot
#endif
#endif // GODOT_TYPE_INFO_HPP

View File

@ -31,6 +31,10 @@
#ifndef GODOT_GODOT_HPP
#define GODOT_GODOT_HPP
#ifdef GODOT_MODULE
#include "modules/register_module_types.h"
#else
#include <gdextension_interface.h>
namespace godot {
@ -263,4 +267,5 @@ public:
} // namespace godot
#endif
#endif // GODOT_GODOT_HPP

View File

@ -31,6 +31,10 @@
#ifndef GODOT_COWDATA_HPP
#define GODOT_COWDATA_HPP
#ifdef GODOT_MODULE
#include "core/templates/cowdata.h"
#else
#include <godot_cpp/classes/global_constants.hpp>
#include <godot_cpp/core/error_macros.hpp>
#include <godot_cpp/core/math.hpp>
@ -489,4 +493,5 @@ CowData<T>::~CowData() {
} // namespace godot
#endif
#endif // GODOT_COWDATA_HPP

View File

@ -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 <godot_cpp/core/error_macros.hpp>
#include <godot_cpp/core/memory.hpp>
#include <godot_cpp/templates/hashfuncs.hpp>
@ -588,4 +592,5 @@ public:
} // namespace godot
#endif
#endif // GODOT_HASH_MAP_HPP

View File

@ -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 <godot_cpp/core/error_macros.hpp>
#include <godot_cpp/core/memory.hpp>
#include <godot_cpp/templates/hash_map.hpp>
@ -474,4 +478,5 @@ public:
} // namespace godot
#endif
#endif // GODOT_HASH_SET_HPP

View File

@ -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 <intrin.h>
@ -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

View File

@ -31,6 +31,10 @@
#ifndef GODOT_LIST_HPP
#define GODOT_LIST_HPP
#ifdef GODOT_MODULE
#include "core/templates/list.h"
#else
#include <godot_cpp/core/error_macros.hpp>
#include <godot_cpp/core/memory.hpp>
#include <godot_cpp/templates/sort_array.hpp>
@ -784,4 +788,5 @@ public:
} // namespace godot
#endif
#endif // GODOT_LIST_HPP

View File

@ -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 <godot_cpp/core/error_macros.hpp>
#include <godot_cpp/core/memory.hpp>
#include <godot_cpp/templates/sort_array.hpp>
@ -340,4 +344,5 @@ using TightLocalVector = LocalVector<T, U, force_trivial, true>;
} // namespace godot
#endif
#endif // GODOT_LOCAL_VECTOR_HPP

View File

@ -31,6 +31,10 @@
#ifndef GODOT_PAIR_HPP
#define GODOT_PAIR_HPP
#ifdef GODOT_MODULE
#include "core/templates/pair.h"
#else
namespace godot {
template <typename F, typename S>
@ -104,4 +108,5 @@ struct KeyValueSort {
} // namespace godot
#endif
#endif // GODOT_PAIR_HPP

View File

@ -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 <godot_cpp/core/error_macros.hpp>
#include <godot_cpp/core/memory.hpp>
#include <godot_cpp/templates/pair.hpp>
@ -762,4 +766,5 @@ public:
} // namespace godot
#endif
#endif // GODOT_RB_MAP_HPP

View File

@ -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 <godot_cpp/core/memory.hpp>
// based on the very nice implementation of rb-trees by:
@ -711,4 +715,5 @@ public:
} // namespace godot
#endif
#endif // GODOT_RB_SET_HPP

View File

@ -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 <godot_cpp/core/memory.hpp>
#include <godot_cpp/godot.hpp>
#include <godot_cpp/templates/list.hpp>
@ -462,4 +466,5 @@ public:
} // namespace godot
#endif
#endif // GODOT_RID_OWNER_HPP

View File

@ -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 <atomic>
@ -332,4 +336,5 @@ public:
} // namespace godot
#endif
#endif // GODOT_SAFE_REFCOUNT_HPP

View File

@ -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 <godot_cpp/templates/sort_array.hpp>
namespace godot {
@ -68,4 +72,5 @@ public:
} // namespace godot
#endif
#endif // GODOT_SEARCH_ARRAY_HPP

View File

@ -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 <godot_cpp/core/defs.hpp>
#include <godot_cpp/core/error_macros.hpp>
@ -140,4 +144,5 @@ public:
} // namespace godot
#endif
#endif // GODOT_SELF_LIST_HPP

View File

@ -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 <godot_cpp/core/error_macros.hpp>
namespace godot {
@ -320,4 +324,5 @@ public:
} // namespace godot
#endif
#endif // GODOT_SORT_ARRAY_HPP

View File

@ -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 <atomic>
namespace godot {
@ -51,4 +55,5 @@ public:
} // namespace godot
#endif
#endif // GODOT_SPIN_LOCK_HPP

View File

@ -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 <godot_cpp/classes/os.hpp>
#include <godot_cpp/classes/semaphore.hpp>
#include <godot_cpp/core/error_macros.hpp>
@ -202,4 +206,5 @@ public:
} // namespace godot
#endif
#endif // GODOT_THREAD_WORK_POOL_HPP

View File

@ -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<T>::fill(T p_elem) {
} // namespace godot
#endif
#endif // GODOT_VECTOR_HPP

View File

@ -31,6 +31,10 @@
#ifndef GODOT_VMAP_HPP
#define GODOT_VMAP_HPP
#ifdef GODOT_MODULE
#include "core/templates/vmap.h"
#else
#include <godot_cpp/templates/cowdata.hpp>
namespace godot {
@ -201,4 +205,5 @@ public:
} // namespace godot
#endif
#endif // GODOT_VMAP_HPP

View File

@ -31,6 +31,10 @@
#ifndef GODOT_VSET_HPP
#define GODOT_VSET_HPP
#ifdef GODOT_MODULE
#include "core/templates/vset.h"
#else
#include <godot_cpp/templates/vector.hpp>
namespace godot {
@ -142,4 +146,5 @@ public:
} // namespace godot
#endif
#endif // GODOT_VSET_HPP

View File

@ -31,6 +31,10 @@
#ifndef GODOT_AABB_HPP
#define GODOT_AABB_HPP
#ifdef GODOT_MODULE
#include "core/math/aabb.h"
#else
#include <godot_cpp/variant/plane.hpp>
#include <godot_cpp/variant/vector3.hpp>
@ -492,4 +496,5 @@ AABB AABB::quantized(real_t p_unit) const {
} // namespace godot
#endif
#endif // GODOT_AABB_HPP

View File

@ -31,6 +31,9 @@
#ifndef GODOT_ARRAY_HELPERS_HPP
#define GODOT_ARRAY_HELPERS_HPP
#ifdef GODOT_MODULE
#else
namespace godot {
namespace helpers {
template <typename T, typename ValueT>
@ -52,4 +55,5 @@ T append_all(T appendable) {
} // namespace helpers
} // namespace godot
#endif
#endif // GODOT_ARRAY_HELPERS_HPP

View File

@ -31,6 +31,10 @@
#ifndef GODOT_BASIS_HPP
#define GODOT_BASIS_HPP
#ifdef GODOT_MODULE
#include "core/math/basis.h"
#else
#include <godot_cpp/classes/global_constants.hpp>
#include <godot_cpp/variant/quaternion.hpp>
#include <godot_cpp/variant/vector3.hpp>
@ -316,4 +320,5 @@ real_t Basis::determinant() const {
} // namespace godot
#endif
#endif // GODOT_BASIS_HPP

View File

@ -31,6 +31,10 @@
#ifndef GODOT_CALLABLE_CUSTOM_HPP
#define GODOT_CALLABLE_CUSTOM_HPP
#ifdef GODOT_MODULE
#include "core/variant/callable.h"
#else
#include <godot_cpp/core/object_id.hpp>
#include <godot_cpp/variant/string_name.hpp>
@ -62,4 +66,5 @@ public:
} // namespace godot
#endif
#endif // GODOT_CALLABLE_CUSTOM_HPP

View File

@ -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 <godot_cpp/core/binder_common.hpp>
#include <godot_cpp/variant/variant.hpp>
@ -270,4 +274,5 @@ Callable create_custom_callable_static_function_pointer(R (*p_method)(P...)) {
} // namespace godot
#endif
#endif // GODOT_CALLABLE_METHOD_POINTER_HPP

View File

@ -31,6 +31,10 @@
#ifndef GODOT_CHAR_STRING_HPP
#define GODOT_CHAR_STRING_HPP
#ifdef GODOT_MODULE
#include "core/string/ustring.h"
#else
#include <godot_cpp/templates/cowdata.hpp>
#include <cstddef>
@ -139,4 +143,5 @@ typedef CharStringT<wchar_t> CharWideString;
} // namespace godot
#endif
#endif // GODOT_CHAR_STRING_HPP

View File

@ -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

View File

@ -31,6 +31,10 @@
#ifndef GODOT_COLOR_HPP
#define GODOT_COLOR_HPP
#ifdef GODOT_MODULE
#include "core/math/color.h"
#else
#include <godot_cpp/core/math.hpp>
namespace godot {
@ -286,4 +290,5 @@ _FORCE_INLINE_ Color operator*(float p_scalar, const Color &p_color) {
} // namespace godot
#endif
#endif // GODOT_COLOR_HPP

View File

@ -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

View File

@ -31,6 +31,10 @@
#ifndef GODOT_PLANE_HPP
#define GODOT_PLANE_HPP
#ifdef GODOT_MODULE
#include "core/math/plane.h"
#else
#include <godot_cpp/classes/global_constants.hpp>
#include <godot_cpp/variant/vector3.hpp>
@ -138,4 +142,5 @@ bool Plane::operator!=(const Plane &p_plane) const {
} // namespace godot
#endif
#endif // GODOT_PLANE_HPP

View File

@ -31,6 +31,10 @@
#ifndef GODOT_PROJECTION_HPP
#define GODOT_PROJECTION_HPP
#ifdef GODOT_MODULE
#include "core/math/projection.h"
#else
#include <godot_cpp/core/math.hpp>
#include <godot_cpp/variant/vector3.hpp>
#include <godot_cpp/variant/vector4.hpp>
@ -168,4 +172,5 @@ Vector3 Projection::xform(const Vector3 &p_vec3) const {
} // namespace godot
#endif
#endif // GODOT_PROJECTION_HPP

View File

@ -31,6 +31,10 @@
#ifndef GODOT_QUATERNION_HPP
#define GODOT_QUATERNION_HPP
#ifdef GODOT_MODULE
#include "core/math/quaternion.h"
#else
#include <godot_cpp/core/math.hpp>
#include <godot_cpp/variant/vector3.hpp>
@ -235,4 +239,5 @@ _FORCE_INLINE_ Quaternion operator*(const real_t &p_real, const Quaternion &p_qu
} // namespace godot
#endif
#endif // GODOT_QUATERNION_HPP

View File

@ -31,6 +31,10 @@
#ifndef GODOT_RECT2_HPP
#define GODOT_RECT2_HPP
#ifdef GODOT_MODULE
#include "core/math/rect2.h"
#else
#include <godot_cpp/classes/global_constants.hpp>
#include <godot_cpp/variant/vector2.hpp>
@ -370,4 +374,5 @@ struct _NO_DISCARD_ Rect2 {
} // namespace godot
#endif
#endif // GODOT_RECT2_HPP

View File

@ -31,6 +31,10 @@
#ifndef GODOT_RECT2I_HPP
#define GODOT_RECT2I_HPP
#ifdef GODOT_MODULE
#include "core/math/rect2i.h"
#else
#include <godot_cpp/classes/global_constants.hpp>
#include <godot_cpp/variant/vector2i.hpp>
@ -242,4 +246,5 @@ struct _NO_DISCARD_ Rect2i {
} // namespace godot
#endif
#endif // GODOT_RECT2I_HPP

View File

@ -31,6 +31,10 @@
#ifndef GODOT_TRANSFORM2D_HPP
#define GODOT_TRANSFORM2D_HPP
#ifdef GODOT_MODULE
#include "core/math/transform_2d.h"
#else
#include <godot_cpp/variant/packed_vector2_array.hpp>
#include <godot_cpp/variant/rect2.hpp>
#include <godot_cpp/variant/vector2.hpp>
@ -248,4 +252,5 @@ PackedVector2Array Transform2D::xform_inv(const PackedVector2Array &p_array) con
} // namespace godot
#endif
#endif // GODOT_TRANSFORM2D_HPP

View File

@ -31,6 +31,10 @@
#ifndef GODOT_TRANSFORM3D_HPP
#define GODOT_TRANSFORM3D_HPP
#ifdef GODOT_MODULE
#include "core/math/transform_3d.h"
#else
#include <godot_cpp/core/math.hpp>
#include <godot_cpp/variant/aabb.hpp>
#include <godot_cpp/variant/basis.hpp>
@ -273,4 +277,5 @@ _FORCE_INLINE_ Plane Transform3D::xform_inv_fast(const Plane &p_plane, const Tra
} // namespace godot
#endif
#endif // GODOT_TRANSFORM3D_HPP

View File

@ -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 <godot_cpp/variant/array.hpp>
#include <godot_cpp/variant/variant.hpp>
@ -139,4 +143,5 @@ MAKE_TYPED_ARRAY(PackedColorArray, Variant::PACKED_COLOR_ARRAY)
} // namespace godot
#endif
#endif // GODOT_TYPED_ARRAY_HPP

View File

@ -31,6 +31,10 @@
#ifndef GODOT_VARIANT_HPP
#define GODOT_VARIANT_HPP
#ifdef GODOT_MODULE
#include "core/variant/variant.h"
#else
#include <godot_cpp/core/defs.hpp>
#include <godot_cpp/variant/builtin_types.hpp>
@ -367,4 +371,5 @@ using PackedRealArray = PackedFloat32Array;
} // namespace godot
#endif
#endif // GODOT_VARIANT_HPP

View File

@ -31,6 +31,10 @@
#ifndef GODOT_VECTOR2_HPP
#define GODOT_VECTOR2_HPP
#ifdef GODOT_MODULE
#include "core/math/vector2.h"
#else
#include <godot_cpp/core/error_macros.hpp>
#include <godot_cpp/core/math.hpp>
@ -331,4 +335,5 @@ typedef Vector2 Point2;
} // namespace godot
#endif
#endif // GODOT_VECTOR2_HPP

View File

@ -31,6 +31,10 @@
#ifndef GODOT_VECTOR2I_HPP
#define GODOT_VECTOR2I_HPP
#ifdef GODOT_MODULE
#include "core/math/vector2i.h"
#else
#include <godot_cpp/core/error_macros.hpp>
#include <godot_cpp/core/math.hpp>
@ -169,4 +173,5 @@ typedef Vector2i Point2i;
} // namespace godot
#endif
#endif // GODOT_VECTOR2I_HPP

View File

@ -31,6 +31,10 @@
#ifndef GODOT_VECTOR3_HPP
#define GODOT_VECTOR3_HPP
#ifdef GODOT_MODULE
#include "core/math/vector3.h"
#else
#include <godot_cpp/core/error_macros.hpp>
#include <godot_cpp/core/math.hpp>
@ -538,4 +542,5 @@ Vector3 Vector3::reflect(const Vector3 &p_normal) const {
} // namespace godot
#endif
#endif // GODOT_VECTOR3_HPP

View File

@ -31,6 +31,10 @@
#ifndef GODOT_VECTOR3I_HPP
#define GODOT_VECTOR3I_HPP
#ifdef GODOT_MODULE
#include "core/math/vector3i.h"
#else
#include <godot_cpp/core/error_macros.hpp>
#include <godot_cpp/core/math.hpp>
@ -340,4 +344,5 @@ void Vector3i::zero() {
} // namespace godot
#endif
#endif // GODOT_VECTOR3I_HPP

View File

@ -31,6 +31,10 @@
#ifndef GODOT_VECTOR4_HPP
#define GODOT_VECTOR4_HPP
#ifdef GODOT_MODULE
#include "core/math/vector4.h"
#else
#include <godot_cpp/core/error_macros.hpp>
#include <godot_cpp/core/math.hpp>
@ -319,4 +323,5 @@ _FORCE_INLINE_ Vector4 operator*(const int64_t p_scalar, const Vector4 &p_vec) {
} // namespace godot
#endif
#endif // GODOT_VECTOR4_HPP

View File

@ -31,6 +31,10 @@
#ifndef GODOT_VECTOR4I_HPP
#define GODOT_VECTOR4I_HPP
#ifdef GODOT_MODULE
#include "core/math/vector4i.h"
#else
#include <godot_cpp/core/error_macros.hpp>
#include <godot_cpp/core/math.hpp>
@ -368,4 +372,5 @@ void Vector4i::zero() {
} // namespace godot
#endif
#endif // GODOT_VECTOR4I_HPP

View File

@ -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",