33import json
44import re
55import shutil
6- import os
6+ from pathlib import Path
77from compat_generator import map_header_files
88from header_matcher import match_headers
9- from pathlib import Path
109
1110
1211def 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
15541555def 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 ())
0 commit comments