Remove deprecated script BuckAnalyze

Summary:
public
The script `BuckAnalyze` has been deprecated for a while already. Time to remove it.

Reviewed By: sblackshear

Differential Revision: D2844414

fb-gh-sync-id: b5e1195
master
jrm 9 years ago committed by facebook-github-bot-1
parent 1544819b40
commit ea5490989e

@ -20,5 +20,3 @@ The rest of the commands in infer/bin/ are not meant to be called directly, but
*InferAnalyze* : Binary containing the backend of Infer that performs the analysis. *InferAnalyze* : Binary containing the backend of Infer that performs the analysis.
*InferPrint* : Binary that prints reports about the analysis such as the specs of methods and a list of bugs found. *InferPrint* : Binary that prints reports about the analysis such as the specs of methods and a list of bugs found.
*BuckAnalyze* : Command for running the analysis of Java projects compiled with Buck.

@ -6,6 +6,5 @@ bin: [
"?infer/bin/InferClang" "?infer/bin/InferClang"
"infer/bin/InferAnalyze" "infer/bin/InferAnalyze"
"infer/bin/InferPrint" "infer/bin/InferPrint"
"infer/bin/BuckAnalyze"
] ]

@ -118,7 +118,7 @@ def prepare_build(args):
return temp_files, infer_script.name return temp_files, infer_script.name
def get_normalized_targets(targets): def get_normalized_targets(targets, verbose):
""" Use buck to convert a list of input targets/aliases """ Use buck to convert a list of input targets/aliases
into a set of the (transitive) target deps for all inputs""" into a set of the (transitive) target deps for all inputs"""
@ -133,7 +133,7 @@ def get_normalized_targets(targets):
targets = filter( targets = filter(
lambda line: len(line) > 0, lambda line: len(line) > 0,
subprocess.check_output(buck_cmd).decode().strip().split('\n')) subprocess.check_output(buck_cmd).decode().strip().split('\n'))
if len(targets) > 0 and args.verbose: if len(targets) > 0 and verbose:
logging.debug('Targets to analyze:') logging.debug('Targets to analyze:')
for target in targets: for target in targets:
logging.debug(target) logging.debug(target)
@ -420,67 +420,78 @@ def cleanup(temp_files):
logging.error('Could not remove %s' % file) logging.error('Could not remove %s' % file)
if __name__ == '__main__': parser = argparse.ArgumentParser()
parser = argparse.ArgumentParser(parents=[analyze.base_parser]) parser.add_argument('--build-report', metavar='PATH', type=str)
parser.add_argument('--verbose', action='store_true', parser.add_argument('--deep', action='store_true')
help='Print buck compilation steps') parser.add_argument('--keep-going', action='store_true')
parser.add_argument('--no-cache', action='store_true', parser.add_argument('--load-limit', '-L')
help='Do not use buck distributed cache') parser.add_argument('--no-cache', action='store_true')
parser.add_argument('--print-harness', action='store_true', parser.add_argument('--profile', action='store_true')
help='Print generated harness code (Android only)') parser.add_argument('--shallow', action='store_true')
parser.add_argument('targets', nargs='*', metavar='target', parser.add_argument('--num-threads', '-j', metavar='N')
help='Build targets to analyze') parser.add_argument('--verbose', '-v', metavar='N', type=int)
args = parser.parse_args() parser.add_argument('targets', nargs='*', metavar='target',
help='Build targets to analyze')
utils.configure_logging(args)
timer = utils.Timer(logging.info)
temp_files = []
try: class UnsuportedBuckCommand(Exception):
start_time = time.time() pass
logging.info('Starting the analysis')
subprocess.check_call(
[utils.get_cmd_in_bin_dir('InferAnalyze'), '-version']) def parse_buck_command(args):
build_keyword = 'build'
if not os.path.isdir(args.infer_out): if build_keyword in args and len(args[args.index(build_keyword):]) > 1:
os.mkdir(args.infer_out) next_index = args.index(build_keyword) + 1
buck_args = parser.parse_args(args[next_index:])
timer.start('Preparing build...') return buck_args
temp_files2, infer_script = prepare_build(args) else:
temp_files += temp_files2 raise UnsuportedBuckCommand(args)
timer.stop('Build prepared')
# TODO(t3786463) Start buckd. class Wrapper:
timer.start('Computing library targets') def __init__(self, infer_args, buck_cmd):
normalized_targets = get_normalized_targets(args.targets) self.timer = utils.Timer(logging.info)
timer.stop('%d targets computed', len(normalized_targets)) self.infer_args = infer_args
self.buck_args = parse_buck_command(buck_cmd)
if len(normalized_targets) == 0: self.timer.start('Computing library targets')
logging.info('Nothing to analyze') self.targets = get_normalized_targets(
else: self.buck_args.targets,
timer.start('Running buck...') self.infer_args.verbose)
buck_cmd = [ self.timer.stop('%d targets computed', len(self.targets))
'buck', 'build', '--config', 'tools.javac=' + infer_script]
if args.no_cache: def run(self):
buck_cmd += ['--no-cache'] temp_files = []
if args.verbose: try:
buck_cmd += ['-v', '2'] start_time = time.time()
compile_cmd = buck_cmd + normalized_targets logging.info('Starting the analysis')
subprocess.check_call(compile_cmd)
timer.stop('Buck finished') if not os.path.isdir(self.infer_args.infer_out):
os.mkdir(self.infer_args.infer_out)
timer.start('Collecting results...')
collect_results(args, start_time) self.timer.start('Preparing build...')
timer.stop('Done') temp_files2, infer_script = prepare_build(self.infer_args)
temp_files += temp_files2
except KeyboardInterrupt as e: self.timer.stop('Build prepared')
timer.stop('Exiting')
sys.exit(0) if len(self.targets) == 0:
except Exception as e: logging.info('Nothing to analyze')
timer.stop('Failed') else:
logging.error('Caught %s: %s' % (e.__class__.__name__, str(e))) self.timer.start('Running buck...')
logging.error(traceback.format_exc()) buck_cmd = ['buck', 'build']
sys.exit(1) if self.buck_args.verbose is not None:
finally: buck_cmd += ['--verbose', str(self.buck_args.verbose)]
cleanup(temp_files) buck_cmd += ['--config', 'tools.javac=' + infer_script]
buck_cmd += self.targets
subprocess.check_call(buck_cmd)
self.timer.stop('Buck finished')
self.timer.start('Collecting results...')
collect_results(self.infer_args, start_time)
self.timer.stop('Done')
return os.EX_OK
except KeyboardInterrupt as e:
self.timer.stop('Exiting')
sys.exit(0)
finally:
cleanup(temp_files)

@ -13,7 +13,7 @@ import subprocess
import traceback import traceback
import util import util
from inferlib import config, issues, utils from inferlib import config, issues, utils, bucklib
MODULE_NAME = __name__ MODULE_NAME = __name__
MODULE_DESCRIPTION = '''Run analysis of code built with a command like: MODULE_DESCRIPTION = '''Run analysis of code built with a command like:
@ -153,22 +153,5 @@ class BuckAnalyzer:
def capture_without_flavors(self): def capture_without_flavors(self):
# BuckAnalyze is a special case, and we run the analysis from here # BuckAnalyze is a special case, and we run the analysis from here
capture_cmd = [utils.get_cmd_in_bin_dir('BuckAnalyze')] buck_wrapper = bucklib.Wrapper(self.args, self.cmd)
if self.args.infer_out is not None: return buck_wrapper.run()
capture_cmd += ['--out', self.args.infer_out]
if self.args.debug:
capture_cmd.append('-g')
if self.args.debug_exceptions:
capture_cmd.append('--debug-exceptions')
if self.args.no_filtering:
capture_cmd.append('--no-filtering')
if self.args.verbose:
capture_cmd.append('--verbose')
if self.args.no_cache:
capture_cmd.append('--no-cache')
if self.args.print_harness:
capture_cmd.append('--print-harness')
capture_cmd += self.cmd[2:] # TODO: make extraction of targets smarter
capture_cmd += ['--analyzer', self.args.analyzer]
subprocess.check_call(capture_cmd)
return os.EX_OK

Loading…
Cancel
Save