diff --git a/binding_generator.py b/binding_generator.py index 8e0ff24eb4..b151a4b110 100644 --- a/binding_generator.py +++ b/binding_generator.py @@ -423,7 +423,7 @@ def generate_bindings(api_filepath, use_template_get_node, bits="64", precision= 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) + generate_compat_includes(godot_repo, output_dir, target_dir) CLASS_ALIASES = { @@ -1567,19 +1567,19 @@ 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 / "include") +def generate_compat_includes(godot_repo: Path, output_dir: Path, target_dir: Path): + file_types_mapping_godot_cpp_gen = map_header_files(output_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) - include_gen_folder = Path(target_dir) / "include" for file_godot_cpp_name, file_godot_names in file_types_mapping.items(): - header_filename = file_godot_cpp_name.replace("godot_cpp", "godot_compat") - header_filepath = include_gen_folder / header_filename + header_filepath = file_godot_cpp_name.replace("godot_cpp", "godot_compat") + if "gen/include" not in header_filepath: + header_filepath = header_filepath.replace("include/", "gen/include/") Path(os.path.dirname(header_filepath)).mkdir(parents=True, exist_ok=True) result = [] - snake_header_name = camel_to_snake(header_filename) + snake_header_name = camel_to_snake(header_filepath) add_header(f"{snake_header_name}.hpp", result) header_guard = f"GODOT_COMPAT_{os.path.splitext(os.path.basename(header_filepath).upper())[0]}_HPP" @@ -1594,7 +1594,7 @@ def generate_compat_includes(godot_repo: Path, target_dir: Path): result.append(f"#endif") result.append("") result.append(f"#endif // ! {header_guard}") - with header_filepath.open("w+", encoding="utf-8") as header_file: + with Path(header_filepath).open("w+", encoding="utf-8") as header_file: header_file.write("\n".join(result)) diff --git a/compat_generator.py b/compat_generator.py index 6eacc2a8fb..b37eb9c76b 100644 --- a/compat_generator.py +++ b/compat_generator.py @@ -45,6 +45,8 @@ def map_header_files(directory): 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)