godot-cpp/header_matcher.py

34 lines
1.3 KiB
Python
Raw Normal View History

Generate godot compat for dual build generate compat generate compat Update ci.yml Update binding_generator.py generate compat generate compat lint python files Update compat_generator.py update docs Update binding_generator.py Update module_converter.py also collect defines Add module converter file that converts module based projects to godot_compat Update ci.yml update docs Update compat_generator.py lint python files generate compat generate compat generate compat generate compat Update ci.yml fix path issue when caling from outside Update binding_generator.py update to also take missing classes/structs Update binding_generator.py Generate godot compat for dual build generate compat generate compat Update ci.yml Update binding_generator.py generate compat generate compat lint python files Update compat_generator.py update docs Update binding_generator.py Update module_converter.py also collect defines Add module converter file that converts module based projects to godot_compat Update ci.yml update docs Update compat_generator.py lint python files generate compat generate compat generate compat generate compat Update ci.yml fix path issue when caling from outside Add support for build profiles. Allow enabling or disabling specific classes (which will not be built). Allow forwarding from `ClassDB` to `ClassDBSingleton` to support enumerations update to also take missing classes/structs Update binding_generator.py update update naming of files add godot mappings. update and run output_header_mapping.json Update README.md make godot_compat work without a file generated fix the test Update binding_generator.py Update binding_generator.py Update binding_generator.py use files from include too Update README.md lint lint lint Update CMakeLists.txt update to use all. fix linting a bit update wip fix posix path Update CMakeLists.txt Update binding_generator.py add using namespace godot; everywhere to includes fix includes Try fixes. generate new include files 123 Update binding_generator.py Update binding_generator.py Update binding_generator.py Update binding_generator.py update fix GODOT_MODULE_COMPAT fix manual includes to match. Update godot.hpp Update color_names.inc.hpp
2024-03-15 08:57:36 +00:00
import json
import os
from compat_generator import map_header_files
def match_headers(mapping1, mapping2):
matches = {}
for header_file, data1 in mapping1.items():
for header_file2, data2 in mapping2.items():
# Check if classes/defines/structs in header_file1 are present in header_file2
if header_file not in matches:
matches[header_file] = []
if (
any(class_name in data2["classes"] for class_name in data1["classes"])
or any(define_name in data2["defines"] for define_name in data1["defines"])
or any(define_name in data2["structs"] for define_name in data1["structs"])
): # or
# any(define_name in data2["enums"] for define_name in data1["enums"])):
matches[header_file].append(header_file2)
return matches
if __name__ == "__main__":
# Load the two header mappings
with open("output_header_mapping_godot.json", "r") as file:
mapping_godot = json.load(file)
file_types_mapping_godot_cpp_gen = map_header_files(os.path.join(os.getcwd(), "gen", "include"))
matches = match_headers(file_types_mapping_godot_cpp_gen, mapping_godot)
# Optionally, you can save the matches to a file
with open("header_matches.json", "w") as outfile:
json.dump(matches, outfile, indent=4)