Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow configuring cc/cxx on analyze #112

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions libscanbuild/analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
COMPILER_WRAPPER_CXX = 'analyze-c++'
ENVIRONMENT_KEY = 'ANALYZE_BUILD'


@command_entry_point
def scan_build():
# type: () -> int
Expand Down Expand Up @@ -81,7 +80,7 @@ def analyze_build():
# will re-assign the report directory as new output
with report_directory(args.output, args.keep_empty) as args.output:
# run the analyzer against a compilation db
compilations = CompilationDatabase.load(args.cdb)
compilations = CompilationDatabase.load(args.cdb, cc=args.cc, cxx=args.cxx)
run_analyzer_parallel(compilations, args)
# cover report generation and bug counting
number_of_bugs = document(args)
Expand Down Expand Up @@ -304,7 +303,6 @@ def run(opts):
that the needed parameters received. (This is done by the 'require'
decorator. It's like an 'assert' to check the contract between the
caller and the called method.) """

command = [opts['compiler'], '-c'] + opts['flags'] + [opts['source']]
logging.debug("Run analyzer against '%s'", command)
return exclude(opts)
Expand Down
2 changes: 1 addition & 1 deletion libscanbuild/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,10 @@ def create_analyze_parser(from_build_command):
""" Creates a parser for command-line arguments to 'analyze'. """

parser = create_default_parser()
parser_add_compilers(parser)

if from_build_command:
parser_add_prefer_wrapper(parser)
parser_add_compilers(parser)

parser.add_argument(
'--intercept-first',
Expand Down
8 changes: 4 additions & 4 deletions libscanbuild/compilation.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def as_db_entry(self):
}

@classmethod
def from_db_entry(cls, entry):
def from_db_entry(cls, entry, cc, cxx):
# type: (Type[Compilation], Dict[str, str]) -> Iterable[Compilation]
""" Parser method for compilation entry.

Expand All @@ -148,7 +148,7 @@ def from_db_entry(cls, entry):
command = shell_split(entry['command']) if 'command' in entry else \
entry['arguments']
execution = Execution(cmd=command, cwd=entry['directory'], pid=0)
return cls.iter_from_execution(execution)
return cls.iter_from_execution(execution, cc=cc, cxx=cxx)

@classmethod
def iter_from_execution(cls, # type: Type[Compilation]
Expand Down Expand Up @@ -293,7 +293,7 @@ def save(filename, iterator):
json.dump(entries, handle, sort_keys=True, indent=4)

@staticmethod
def load(filename):
def load(filename, cc='cc', cxx='c++'):
# type: (str) -> Iterable[Compilation]
""" Load compilations from file.

Expand All @@ -302,7 +302,7 @@ def load(filename):

with open(filename, 'r') as handle:
for entry in json.load(handle):
for compilation in Compilation.from_db_entry(entry):
for compilation in Compilation.from_db_entry(entry, cc=cc, cxx=cxx):
yield compilation


Expand Down