Skip to content

Commit

Permalink
Fix invocation of intercept-build and support argvector and relative …
Browse files Browse the repository at this point in the history
…paths
  • Loading branch information
whisperity committed Mar 14, 2017
1 parent 4f5de87 commit eb8eab9
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
28 changes: 27 additions & 1 deletion libcodechecker/analyze/log_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,40 @@ def parse_compile_commands_json(logfile, add_compiler_defaults=False):
counter = 0
for entry in data:
sourcefile = entry['file']

if not os.path.isabs(sourcefile):
# Newest versions of intercept-build can create the 'file' in the
# JSON Compilation Database as a relative path.
sourcefile = os.path.join(os.path.abspath(entry['directory']),
sourcefile)

lang = option_parser.get_language(sourcefile[sourcefile.rfind('.'):])

if not lang:
continue

action = build_action.BuildAction(counter)

command = entry['command']
if 'command' in entry:
command = entry['command']
elif 'arguments' in entry:
# Newest versions of intercept-build create an argument vector
# instead of a command string.
for i in range(0, len(entry['arguments'])):
arg = entry['arguments'][i]
if ' ' in arg:
# If there is an argument with a space in it, the join
# below will mess the invocation up. (-DVAR=va lue will be
# passed as -DVAR=va)
#
# Build.json created by ld-logger escapes these strings
# and they never reach the analyser later on.
#
# TODO: Better handle this. (See issue #505.)
entry['arguments'][i] = '\"' + arg + '\"'
command = ' '.join(entry['arguments'])
else:
raise KeyError("No valid 'command' or 'arguments' entry found!")
results = option_parser.parse_options(command)

action.original_command = command
Expand Down
4 changes: 3 additions & 1 deletion libcodechecker/log/build_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ def perform_build_command(logfile, command, context, silent=False):
if host_check.check_intercept(original_env):
LOG.debug_analyzer("with intercept ...")
final_command = command
command = "intercept-build " + "--cdb " + logfile + " " + final_command
command = ' '.join(["intercept-build",
"--cdb", logfile,
"sh -c \"" + final_command + "\""])
log_env = original_env
LOG.debug_analyzer(command)

Expand Down
2 changes: 1 addition & 1 deletion libcodechecker/log/host_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def check_intercept(env):
"""
Simple check if intercept (scan-build-py) is available.
"""
intercept_cmd = ['intercept-build']
intercept_cmd = ['intercept-build', '--help']
try:
res = subprocess.call(intercept_cmd,
env=env,
Expand Down

0 comments on commit eb8eab9

Please sign in to comment.