@ -19,6 +19,7 @@ from inferlib import analyze, config, utils
from inferlib.capture import make
from inferlib.capture import make
CAPTURE_PACKAGE = 'capture'
CAPTURE_PACKAGE = 'capture'
TOP_LEVEL_ENVVAR = 'TOP_LEVEL_INFER_INSTANCE_ALREADY_RUNNING'
# token that identifies the end of the options for infer and the beginning
# token that identifies the end of the options for infer and the beginning
# of the compilation command
# of the compilation command
@ -99,6 +100,12 @@ def create_argparser(parents=[]):
def main():
def main():
toplevel_envvar_value = os.environ.get(TOP_LEVEL_ENVVAR, None)
is_toplevel_instance = False
if toplevel_envvar_value is None:
os.environ[TOP_LEVEL_ENVVAR] = '1'
is_toplevel_instance = True
to_parse, cmd = split_args_to_parse()
to_parse, cmd = split_args_to_parse()
# get the module name (if any), then load it
# get the module name (if any), then load it
capture_module_name = os.path.basename(cmd[0]) if len(cmd) > 0 else None
capture_module_name = os.path.basename(cmd[0]) if len(cmd) > 0 else None
@ -179,6 +186,18 @@ def main():
analysis.analyze_and_report()
analysis.analyze_and_report()
analysis.save_stats()
analysis.save_stats()
if is_toplevel_instance is True:
buck_out_for_stats_aggregator = None
if (mod_name == 'buck' and
os.path.isfile(
os.path.join(args.infer_out,
config.INFER_BUCK_DEPS_FILENAME))):
buck_out_for_stats_aggregator = 'buck-out'
logging.info('Aggregating stats')
output = utils.run_infer_stats_aggregator(
args.infer_out, buck_out_for_stats_aggregator)
logging.info(output)
if args.fail_on_bug:
if args.fail_on_bug:
bugs_filename = os.path.join(args.infer_out,
bugs_filename = os.path.join(args.infer_out,
config.JSON_REPORT_FILENAME)
config.JSON_REPORT_FILENAME)