MCPcopy Create free account
hub / github.com/Bareflank/hypervisor / from_compile_command

Method from_compile_command

utils/iwyu_tool.py:285–305  ·  view source on GitHub ↗

Parse a JSON compilation database entry into new Invocation.

(cls, entry, extra_args)

Source from the content-addressed store, hash-verified

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. """

Callers 1

mainFunction · 0.80

Calls 2

split_commandFunction · 0.85
is_msvc_driverFunction · 0.85

Tested by

no test coverage detected