Skip to content

Commit 9dba6a6

Browse files
committed
update to use all. fix linting a bit
1 parent c56e847 commit 9dba6a6

3 files changed

Lines changed: 17 additions & 12 deletions

File tree

binding_generator.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
import json
44
import re
55
import shutil
6-
import os
6+
from pathlib import Path
77
from compat_generator import map_header_files
88
from header_matcher import match_headers
9-
from pathlib import Path
109

1110

1211
def generate_mod_version(argcount, const=False, returns=False):
@@ -261,7 +260,7 @@ def get_file_list(api_filepath, output_dir, headers=False, sources=False, profil
261260
include_gen_folder / "classes" / "global_constants.hpp",
262261
include_gen_folder / "classes" / "global_constants_binds.hpp",
263262
include_gen_folder / "core" / "version.hpp",
264-
]:
263+
]:
265264
files.append(str(path.as_posix()))
266265
if sources:
267266
utility_functions_source_path = source_gen_folder / "variant" / "utility_functions.cpp"
@@ -386,7 +385,9 @@ def scons_generate_bindings(target, source, env):
386385
return None
387386

388387

389-
def generate_bindings(api_filepath, use_template_get_node, bits="64", precision="single", output_dir=".", godot_repo = ""):
388+
def generate_bindings(
389+
api_filepath, use_template_get_node, bits="64", precision="single", output_dir=".", godot_repo=""
390+
):
390391
api = None
391392

392393
target_dir = Path(output_dir) / "gen"
@@ -1552,7 +1553,8 @@ def generate_engine_classes_bindings(api, output_dir, use_template_get_node):
15521553

15531554

15541555
def generate_compat_includes(godot_repo: Path, output_dir: Path, target_dir: Path):
1555-
target_dir = output_dir
1556+
# Uncomment this to change include files
1557+
# target_dir = output_dir
15561558
file_types_mapping_godot_cpp_gen = map_header_files(target_dir)
15571559
file_types_mapping_godot = map_header_files(godot_repo)
15581560
# Match the headers
@@ -1575,17 +1577,19 @@ def generate_compat_includes(godot_repo: Path, output_dir: Path, target_dir: Pat
15751577
result.append("\n") # Blank line for separation
15761578

15771579
# Insert the #ifdef block
1578-
result.append(f"#ifdef GODOT_MODULE_COMPAT\n")
1580+
result.append("#ifdef GODOT_MODULE_COMPAT\n")
15791581
if len(file_godot_names) == 0:
15801582
print("No header found for", file_godot_cpp_name)
15811583
for file_godot_name in file_godot_names:
15821584
result.append(f"#include <{Path(file_godot_name).as_posix()}>\n")
1583-
result.append(f"#else\n")
1585+
result.append("#else\n")
15841586

1585-
result.extend(after_marker) # Append the remaining content inside the guard
1587+
for line in after_marker:
1588+
if line.strip() not in {"namespace godot {", "} // namespace godot"}:
1589+
result.append(line)
15861590

15871591
# Add the namespace and endif
1588-
result.append(f"#endif\n")
1592+
result.append("#endif\n")
15891593

15901594
# Finally, append the original final #endif line
15911595
result.append(content[last_endif_idx].strip())

compat_generator.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/usr/bin/env python
22

3+
import json
34
import re
45
import os
5-
import json
66
import sys
77

88

@@ -35,7 +35,7 @@ def parse_header_file(file_path):
3535
types["defines"] += define_matches
3636

3737
# Debug the case where no classes or structs are found
38-
#if len(types["classes"]) == 0 and len(types["structs"]) == 0 and len(types["defines"]) == 0:
38+
# if len(types["classes"]) == 0 and len(types["structs"]) == 0 and len(types["defines"]) == 0:
3939
# print(f"{file_path} missing things")
4040
return types
4141

@@ -67,7 +67,7 @@ def map_header_files(directory):
6767
current_directory = os.path.join(os.getcwd(), "")
6868
mapping_name = ""
6969
if len(sys.argv) > 1:
70-
mapping_name = f"_godot"
70+
mapping_name = "_godot"
7171
current_directory = os.path.join(os.getcwd(), sys.argv[1])
7272

7373
file_types_mapping = map_header_files(current_directory)

header_matcher.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import json
22
import os
3+
34
from compat_generator import map_header_files
45

56
def match_headers(mapping1, mapping2):

0 commit comments

Comments
 (0)