Skip to content

Commit

Permalink
use files from include too
Browse files Browse the repository at this point in the history
  • Loading branch information
Ughuuu committed Oct 20, 2024
1 parent 2539e07 commit 1d515ab
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
16 changes: 8 additions & 8 deletions binding_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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"
Expand All @@ -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))


Expand Down
2 changes: 2 additions & 0 deletions compat_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 1d515ab

Please sign in to comment.