Skip to content

Commit 5783b96

Browse files
committed
fix path issue when caling from outside
1 parent 99a1eb7 commit 5783b96

File tree

3 files changed

+11
-16
lines changed

3 files changed

+11
-16
lines changed

binding_generator.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ def generate_bindings(api_filepath, use_template_get_node, bits="64", precision=
311311
generate_builtin_bindings(api, target_dir, real_t + "_" + bits)
312312
generate_engine_classes_bindings(api, target_dir, use_template_get_node)
313313
generate_utility_functions(api, target_dir)
314-
generate_compat_includes(target_dir)
314+
generate_compat_includes(Path(output_dir), target_dir)
315315

316316

317317
builtin_classes = []
@@ -1445,17 +1445,19 @@ def generate_engine_classes_bindings(api, output_dir, use_template_get_node):
14451445
header_file.write("\n".join(result))
14461446

14471447

1448-
def generate_compat_includes(output_dir):
1449-
file_types_mapping_godot_cpp = map_header_files("gen/include")
1450-
godot_compat = Path("output_header_mapping_godot.json")
1448+
def generate_compat_includes(output_dir: Path, target_dir: Path):
1449+
file_types_mapping_godot_cpp_gen = map_header_files(target_dir / "include")
1450+
file_types_mapping_godot_cpp = map_header_files(output_dir / "include") | file_types_mapping_godot_cpp_gen
1451+
godot_compat = output_dir / "output_header_mapping_godot.json"
14511452
if not godot_compat.exists():
1453+
print("Skipping godot_compat")
14521454
return
14531455
with godot_compat.open() as file:
14541456
mapping2 = json.load(file)
14551457
# Match the headers
14561458
file_types_mapping = match_headers(file_types_mapping_godot_cpp, mapping2)
14571459

1458-
include_gen_folder = Path(output_dir) / "include"
1460+
include_gen_folder = Path(target_dir) / "include"
14591461
for file_godot_cpp_name, file_godot_names in file_types_mapping.items():
14601462
header_filename = file_godot_cpp_name.replace("godot_cpp", "godot_compat")
14611463
header_filepath = include_gen_folder / header_filename
@@ -1476,8 +1478,8 @@ def generate_compat_includes(output_dir):
14761478
result.append(f"#endif")
14771479
result.append("")
14781480
result.append(f"#endif // ! {header_guard}")
1479-
with header_filepath.open("w+", encoding="utf-8") as header_file:
1480-
header_file.write("\n".join(result))
1481+
#with header_filepath.open("w+", encoding="utf-8") as header_file:
1482+
# header_file.write("\n".join(result))
14811483

14821484

14831485
def generate_engine_class_header(class_api, used_classes, fully_used_classes, use_template_get_node):

compat_generator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55

66

77
def parse_header_file(file_path):
8-
print(file_path)
98
types = {"classes": [], "structs": [], "defines": []}
10-
# print(file_path)
119

1210
with open(file_path, "r", encoding="utf-8") as file:
1311
content = file.read()
@@ -40,6 +38,8 @@ def map_header_files(directory):
4038
dirs.remove("thirdparty")
4139
if "tests" in dirs:
4240
dirs.remove("tests")
41+
if "test" in dirs:
42+
dirs.remove("test")
4343
if "misc" in dirs:
4444
dirs.remove("misc")
4545
for file in files:

header_matcher.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,6 @@ def match_headers(mapping1, mapping2):
2626
# Match the headers
2727
matches = match_headers(mapping1, mapping2)
2828

29-
# Output the matches
30-
for header_file, matching_files in matches.items():
31-
print(f"{header_file} matches with:")
32-
for matching_file in matching_files:
33-
print(f"- {matching_file}")
34-
print()
35-
3629
# Optionally, you can save the matches to a file
3730
with open("header_matches.json", "w") as outfile:
3831
json.dump(matches, outfile, indent=4)

0 commit comments

Comments
 (0)