MCPcopy Create free account
hub / github.com/Pagghiu/SaneCppLibraries / build_dependency_map

Function build_dependency_map

Support/Dependencies/include_parser.py:9–33  ·  view source on GitHub ↗

Parses include statements in source files to build a direct dependency map.

(project_root, libraries)

Source from the content-addressed store, hash-verified

7
8
9def build_dependency_map(project_root, libraries):
10 """
11 Parses include statements in source files to build a direct dependency map.
12 """
13 libraries_set = set(libraries)
14 dep_map = {lib: set() for lib in libraries}
15 include_regex = re.compile(config.INCLUDE_PATTERN)
16
17 for lib in libraries:
18 files = library_scanner.collect_source_files(project_root, lib)
19 for fpath in files:
20 try:
21 with open(fpath, 'r', encoding='utf-8', errors='ignore') as f:
22 for line in f:
23 match = include_regex.search(line)
24 if match:
25 # Skip if marked as optional
26 if config.OPTIONAL_DEPENDENCY_MARKER in line:
27 continue
28 dep = match.group(1)
29 if dep != lib and dep in libraries_set:
30 dep_map[lib].add(dep)
31 except Exception as e:
32 print(f"Warning: Could not read {fpath}: {e}")
33 return dep_map

Callers

nothing calls this directly

Calls 3

printFunction · 0.85
compileMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected