From 6daedaef1347e0c24b307fed8c9302fd3ab3e338 Mon Sep 17 00:00:00 2001 From: martinoluca Date: Wed, 23 Dec 2015 02:57:18 -0800 Subject: [PATCH] Pass javac wrapper through command-line argument Reviewed By: jeremydubreil Differential Revision: D2783771 fb-gh-sync-id: 274b647 --- infer/lib/python/BuckAnalyze | 31 ++++++------------------------- 1 file changed, 6 insertions(+), 25 deletions(-) diff --git a/infer/lib/python/BuckAnalyze b/infer/lib/python/BuckAnalyze index d2e9ba129..db4f2373b 100755 --- a/infer/lib/python/BuckAnalyze +++ b/infer/lib/python/BuckAnalyze @@ -35,8 +35,6 @@ from inferlib import analyze, config, issues, utils ANALYSIS_SUMMARY_OUTPUT = 'analysis_summary.txt' -BUCK_CONFIG = '.buckconfig.local' -BUCK_CONFIG_BACKUP = '.buckconfig.local.backup_generated_by_infer' DEFAULT_BUCK_OUT = os.path.join(os.getcwd(), 'buck-out') DEFAULT_BUCK_OUT_GEN = os.path.join(DEFAULT_BUCK_OUT, 'gen') @@ -119,23 +117,8 @@ def prepare_build(args): st = os.stat(infer_script.name) os.chmod(infer_script.name, st.st_mode | stat.S_IEXEC) - # Backup and patch local buck config - patched_config = '' - if os.path.isfile(BUCK_CONFIG): - logging.info('Backing up %s to %s', BUCK_CONFIG, BUCK_CONFIG_BACKUP) - shutil.move(BUCK_CONFIG, BUCK_CONFIG_BACKUP) - with open(BUCK_CONFIG_BACKUP) as buckconfig: - patched_config = '\n'.join(buckconfig) - - javac_section = '[tools]\n{0}javac = {1}'.format( - ' ' * 4, - infer_script.name) - patched_config += javac_section - with open(BUCK_CONFIG, 'w') as buckconfig: - buckconfig.write(patched_config) - temp_files += [infer_script.name] - return temp_files + return temp_files, infer_script.name def get_normalized_targets(targets): @@ -429,7 +412,7 @@ def collect_results(args, start_time): def cleanup(temp_files): """Removes the generated .buckconfig.local and the temporary infer script. """ - for file in [BUCK_CONFIG] + temp_files: + for file in temp_files: try: logging.info('Removing %s' % file) if os.path.isdir(file): @@ -439,10 +422,6 @@ def cleanup(temp_files): except IOError: logging.error('Could not remove %s' % file) - if os.path.isfile(BUCK_CONFIG_BACKUP): - logging.info('Restoring %s', BUCK_CONFIG) - shutil.move(BUCK_CONFIG_BACKUP, BUCK_CONFIG) - if __name__ == '__main__': parser = argparse.ArgumentParser(parents=[analyze.base_parser]) @@ -470,7 +449,8 @@ if __name__ == '__main__': os.mkdir(args.infer_out) timer.start('Preparing build...') - temp_files += prepare_build(args) + temp_files2, infer_script = prepare_build(args) + temp_files += temp_files2 timer.stop('Build prepared') # TODO(t3786463) Start buckd. @@ -483,7 +463,8 @@ if __name__ == '__main__': logging.info('Nothing to analyze') else: timer.start('Running buck...') - buck_cmd = ['buck', 'build'] + buck_cmd = [ + 'buck', 'build', '--config', 'tools.javac=' + infer_script] if args.no_cache: buck_cmd += ['--no-cache'] if args.verbose: