MCPcopy Create free account
hub / github.com/FastLED/FastLED / main

Function main

ci/iwyu_wrapper.py:122–224  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

120
121
122def main():
123 # Find IWYU binary
124 iwyu_binary = find_iwyu_binary()
125 if not iwyu_binary:
126 print("ERROR: include-what-you-use binary not found", file=sys.stderr)
127 print("Install via: pip install clang-tool-chain", file=sys.stderr)
128 sys.exit(1)
129 assert iwyu_binary is not None
130
131 # Parse arguments
132 # Format: iwyu_wrapper.py [iwyu-specific-args] -- compiler [compiler-args] source.cpp
133 # IWYU expects: include-what-you-use [iwyu-opts] [compiler-args] source.cpp
134 # The compiler itself is not passed to IWYU - IWYU uses its own Clang frontend
135
136 args = sys.argv[1:]
137 compiler_executable: str | None = None
138 compiler_args: list[str] = []
139 iwyu_specific_args: list[str] = []
140
141 # Split at '--' separator if present
142 if "--" in args:
143 separator_idx = args.index("--")
144 iwyu_specific_args = args[:separator_idx]
145 # Skip the compiler path after '--' and take the rest
146 # Format after '--': compiler_path [compiler_args...]
147 if len(args) > separator_idx + 1:
148 # Skip compiler executable, take only its arguments
149 compiler_and_args = args[separator_idx + 1 :]
150 # First element after '--' is the compiler path, rest are compiler args
151 if len(compiler_and_args) > 0:
152 # Save compiler path for querying include paths
153 compiler_executable = compiler_and_args[0]
154 # Skip the compiler path itself (IWYU doesn't need it)
155 compiler_args = compiler_and_args[1:]
156 else:
157 compiler_args = []
158 else:
159 compiler_args = []
160 else:
161 # No separator - all args go to IWYU
162 iwyu_specific_args = []
163 compiler_args = args
164
165 # Extract include paths from the actual compiler
166 # This ensures IWYU can find stdlib headers like <initializer_list>
167 extra_includes: list[str] = []
168 if compiler_executable:
169 extra_includes = get_compiler_include_paths(compiler_executable)
170
171 # Strip PCH flags from compiler_args since IWYU doesn't support PCH
172 # Remove: -include-pch path -Werror=invalid-pch -fpch-validate-input-files-content
173 filtered_args: list[str] = []
174 skip_next = False
175 for i, arg in enumerate(compiler_args):
176 if skip_next:
177 skip_next = False
178 continue
179 if arg == "-include-pch":

Callers 1

iwyu_wrapper.pyFile · 0.70

Calls 5

find_iwyu_binaryFunction · 0.85
printFunction · 0.50
appendMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected