def scan_build(): """ Entry point for scan-build command. """ args = parse_args_for_scan_build() # will re-assign the report directory as new output with report_directory( args.output, args.keep_empty, args.output_format) as args.output: # Run against a build command. there are cases, when analyzer run # is not required. But we need to set up everything for the # wrappers, because 'configure' needs to capture the CC/CXX values # for the Makefile. if args.intercept_first: # Run build command with intercept module. exit_code = capture(args) # Run the analyzer against the captured commands. if need_analyzer(args.build): govern_analyzer_runs(args) else: # Run build command and analyzer with compiler wrappers. environment = setup_environment(args) exit_code = run_build(args.build, env=environment) # Cover report generation and bug counting. number_of_bugs = document(args) # Set exit status as it was requested. return number_of_bugs if args.status_bugs else exit_code
def scan_build(): # type: () -> int """ Entry point for scan-build command. """ args = parse_args_for_scan_build() # will re-assign the report directory as new output with report_directory(args.output, args.keep_empty) as args.output: # run against a build command. there are cases, when analyzer run # is not required. but we need to set up everything for the # wrappers, because 'configure' needs to capture the CC/CXX values # for the Makefile. if args.intercept_first: # run build command with intercept module exit_code, compilations = capture(args) if need_analyzer(args.build): # run the analyzer against the captured commands run_analyzer_parallel(compilations, args) else: # run build command and analyzer with compiler wrappers environment = setup_environment(args) exit_code = run_build(args.build, env=environment) # cover report generation and bug counting number_of_bugs = document(args) # set exit status as it was requested return number_of_bugs if args.status_bugs else exit_code
def analyze_build_main(bin_dir, from_build_command): """ Entry point for 'analyze-build' and 'scan-build'. """ parser = create_parser(from_build_command) args = parser.parse_args() validate(parser, args, from_build_command) # setup logging initialize_logging(args.verbose) logging.debug('Parsed arguments: %s', args) with report_directory(args.output, args.keep_empty) as target_dir: if not from_build_command: # run analyzer only and generate cover report run_analyzer(args, target_dir) number_of_bugs = document(args, target_dir, True) return number_of_bugs if args.status_bugs else 0 elif args.intercept_first: # run build command and capture compiler executions exit_code = capture(args, bin_dir) # next step to run the analyzer against the captured commands if need_analyzer(args.build): run_analyzer(args, target_dir) # cover report generation and bug counting number_of_bugs = document(args, target_dir, True) # remove the compilation database when it was not requested if os.path.exists(args.cdb): os.unlink(args.cdb) # set exit status as it was requested return number_of_bugs if args.status_bugs else exit_code else: return exit_code else: # run the build command with compiler wrappers which # execute the analyzer too. (interposition) environment = setup_environment(args, target_dir, bin_dir) logging.debug('run build in environment: %s', environment) exit_code = subprocess.call(args.build, env=environment) logging.debug('build finished with exit code: %d', exit_code) # cover report generation and bug counting number_of_bugs = document(args, target_dir, False) # set exit status as it was requested return number_of_bugs if args.status_bugs else exit_code
def analyze_build(): """ Entry point for analyze-build command. """ args = parse_args_for_analyze_build() with report_directory(args.output, args.keep_empty) as target_dir: # Run the analyzer against a compilation db. run_analyzer(args, target_dir) # Cover report generation and bug counting. number_of_bugs = document(args, target_dir, True) # Set exit status as it was requested. return number_of_bugs if args.status_bugs else 0
def analyze_build(): """ Entry point for analyze-build command. """ args = parse_args_for_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. govern_analyzer_runs(args) # Cover report generation and bug counting. number_of_bugs = document(args) # Set exit status as it was requested. return number_of_bugs if args.status_bugs else 0
def analyze_build(): """ Entry point for analyze-build command. """ args = parse_args_for_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. run_analyzer_parallel(args) # Cover report generation and bug counting. number_of_bugs = document(args) # Set exit status as it was requested. return number_of_bugs if args.status_bugs else 0
def analyze_build(): """ Entry point for analyze-build command. """ args = analyze() # 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) run_analyzer_parallel(compilations, args) # cover report generation and bug counting number_of_bugs = document(args) # set exit status as it was requested return number_of_bugs if args.status_bugs else 0
def scan_build(): """ Entry point for scan-build command. """ args = parse_args_for_scan_build() with report_directory(args.output, args.keep_empty) as target_dir: # Run against a build command. there are cases, when analyzer run # is not required. But we need to set up everything for the # wrappers, because 'configure' needs to capture the CC/CXX values # for the Makefile. if args.intercept_first: # Run build command with intercept module. exit_code = capture(args) # Run the analyzer against the captured commands. if need_analyzer(args.build): run_analyzer(args, target_dir) else: # Run build command and analyzer with compiler wrappers. environment = setup_environment(args, target_dir) exit_code = run_build(args.build, env=environment) # Cover report generation and bug counting. number_of_bugs = document(args, target_dir, False) # Set exit status as it was requested. return number_of_bugs if args.status_bugs else exit_code
def main(bin_dir): """ Entry point for 'analyze-build'. """ try: args = parse_and_validate_arguments() # setup logging initialize_logging(args) logging.debug('Parsed arguments: %s', args) # run the build with ReportDirectory(args.output, args.keep_empty) as target_dir: # run the build command environment = setup_environment(args, target_dir.name, bin_dir) logging.debug('run build in environment: %s', environment) exit_code = subprocess.call(args.build, env=environment) logging.debug('build finished with exit code: %d', exit_code) # cover report generation and bug counting number_of_bugs = document(args, target_dir.name, False) # set exit status as it was requested return number_of_bugs if args.status_bugs else exit_code except KeyboardInterrupt: return 1 except Exception: logging.exception("Something unexpected had happened.") return 127