(graph: graphlib.TopologicalSorter, source_file: Path)
| 62 | |
| 63 | |
| 64 | def build_graph(graph: graphlib.TopologicalSorter, source_file: Path) -> None: |
| 65 | assert source_file.is_absolute() |
| 66 | global processed_headers |
| 67 | if source_file in processed_headers: |
| 68 | return |
| 69 | processed_headers.add(source_file.resolve()) |
| 70 | |
| 71 | with source_file.open("r") as f: |
| 72 | for line in f.readlines(): |
| 73 | if not line.startswith('#include "'): |
| 74 | continue |
| 75 | header_path = line.split('"')[1] |
| 76 | header_real_path = resolve_include(source_file, header_path) |
| 77 | if header_real_path is None: |
| 78 | logging.error(f"Could not find {header_path} included in {source_file}") |
| 79 | sys.exit(1) |
| 80 | logging.debug( |
| 81 | f"Resolved {header_path} in {source_file} to {header_real_path}" |
| 82 | ) |
| 83 | graph.add(source_file, header_real_path) |
| 84 | build_graph(graph, header_real_path) |
| 85 | |
| 86 | |
| 87 | def create_merged_header(): |
no test coverage detected