From 743c73012dfc9d7be7c7612a56a8431c7070a799 Mon Sep 17 00:00:00 2001 From: Jeremy Dubreil Date: Wed, 29 Jul 2015 09:07:47 -0700 Subject: [PATCH] [infer][java] avoid converting javac command lines from bash to python as some buck options are incorectly parsed otherwise Summary: Buck is creating javac compilation commands with arguments of the form: -Opt={"list": ["pif", "paf", "pouf"]} While converting command lines from bash to python, these option gets split into ['-Opt={"list":', '["pif",', '"paf",', '"pouf"]}'] instead of: ['-Opt={"list": ["pif", "paf", "pouf"]}'] which create the compilation to fail when running Infer even though the original files are compiling correctly. --- infer/bin/BuckAnalyze | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/infer/bin/BuckAnalyze b/infer/bin/BuckAnalyze index 7da11f182..4bbb0f6f4 100755 --- a/infer/bin/BuckAnalyze +++ b/infer/bin/BuckAnalyze @@ -45,8 +45,12 @@ INFER_REPORT = os.path.join(utils.BUCK_INFER_OUT, utils.CSV_REPORT_FILENAME) INFER_STATS = os.path.join(utils.BUCK_INFER_OUT, utils.STATS_FILENAME) INFER_SCRIPT = """\ -#!/bin/sh -{0} {1} -- javac $@ +#!/usr/bin/env {0} +import subprocess +import sys + +cmd = ['{0}'] + {1} + ['--', 'javac'] + sys.argv[1:] +subprocess.check_call(cmd) """ LOCAL_CONFIG = """\ @@ -82,8 +86,7 @@ def prepare_build(args): temp_files = [infer_cache_dir] try: - infer = utils.get_cmd_in_bin_dir('infer') + ' ' +\ - ' '.join(infer_options) + infer = [utils.get_cmd_in_bin_dir('infer')] + infer_options except subprocess.CalledProcessError as e: logging.error('Could not find infer') raise e @@ -100,7 +103,7 @@ def prepare_build(args): infer_script = None with tempfile.NamedTemporaryFile(delete=False, prefix='infer_', - suffix='.sh', + suffix='.py', dir='.') as infer_script: logging.info('Creating %s' % infer_script.name) infer_script.file.write(