MCPcopy Create free account
hub / github.com/SpartanJ/eepp / find_missing_includes

Function find_missing_includes

projects/scripts/find_missing_includes.py:28–94  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

26
27
28def find_missing_includes():
29 script_dir = os.path.dirname(os.path.abspath(__file__))
30 repo_root = os.path.abspath(os.path.join(script_dir, "..", ".."))
31
32 include_base_dir = os.path.join(repo_root, "include")
33 eepp_dir = os.path.join(include_base_dir, "eepp")
34
35 if not os.path.exists(eepp_dir):
36 print(f"Error: Could not find {eepp_dir}")
37 return
38
39 print("Scanning eepp modules for missing includes...\n")
40
41 total_missing = 0
42
43 # 1. Find all master module headers (e.g., ui.hpp, core.hpp, scene.hpp)
44 for item in sorted(os.listdir(eepp_dir)):
45 if not item.endswith(".hpp") or item == "ee.hpp" or item == "version.hpp":
46 continue
47
48 module_name = item[:-4] # strip .hpp (e.g., 'core')
49 module_dir = os.path.join(eepp_dir, module_name)
50
51 # Only process if there is a matching directory (e.g., include/eepp/core/)
52 if os.path.isdir(module_dir):
53 master_header_path = os.path.join(eepp_dir, item)
54
55 # 2. Extract includes from the main module header
56 existing_includes = extract_includes_from_file(master_header_path)
57
58 # --- THE CORE EXCEPTION ---
59 # If this is the core module, also grab includes from eepp/core/core.hpp
60 if module_name == "core":
61 core_inner_path = os.path.join(module_dir, "core.hpp")
62 existing_includes.update(extract_includes_from_file(core_inner_path))
63
64 # 3. Walk the module's directory recursively to find all .hpp files
65 missing_in_module = []
66 for root, dirs, files in os.walk(module_dir):
67 for file in files:
68 if file.endswith(".hpp"):
69 full_path = os.path.join(root, file)
70
71 rel_path = os.path.relpath(full_path, include_base_dir)
72 rel_path = rel_path.replace(os.sep, "/")
73
74 # Skip the inner core.hpp file itself so it doesn't get flagged
75 if module_name == "core" and rel_path == "eepp/core/core.hpp":
76 continue
77
78 # 4. Check if the file is missing from the known includes
79 if rel_path not in existing_includes:
80 missing_in_module.append(f"#include <{rel_path}>")
81
82 # 5. Print results nicely
83 if missing_in_module:
84 print(f"--- Missing in {item} ---")
85 for missing in sorted(missing_in_module):

Callers 1

Calls 6

joinMethod · 0.45
existsMethod · 0.45
updateMethod · 0.45
replaceMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected