Parse a JSON compilation database entry into new Invocation.
(cls, entry, extra_args)
| 283 | |
| 284 | @classmethod |
| 285 | def from_compile_command(cls, entry, extra_args): |
| 286 | """ Parse a JSON compilation database entry into new Invocation. """ |
| 287 | if 'arguments' in entry: |
| 288 | # arguments is a command-line in list form. |
| 289 | command = entry['arguments'] |
| 290 | source_file = entry['file'] |
| 291 | elif 'command' in entry: |
| 292 | # command is a command-line in string form, split to list. |
| 293 | command = split_command(entry['command']) |
| 294 | source_file = entry['file'] |
| 295 | else: |
| 296 | raise ValueError('Invalid compilation database entry: %s' % entry) |
| 297 | |
| 298 | # Rewrite the compile command for IWYU |
| 299 | compile_command, compile_args = command[0], command[1:] |
| 300 | if is_msvc_driver(compile_command): |
| 301 | # If the compiler is cl-compatible, let IWYU be cl-compatible. |
| 302 | extra_args = ['--driver-mode=cl'] + extra_args |
| 303 | |
| 304 | command = [IWYU_EXECUTABLE] + extra_args + compile_args |
| 305 | return cls(command, entry['directory'], source_file) |
| 306 | |
| 307 | def start(self, verbose): |
| 308 | """ Run invocation and collect output. """ |
no test coverage detected