From f2282a8277145a3b2d38a57c70147ab7c370fba2 Mon Sep 17 00:00:00 2001 From: Jeremy Dubreil Date: Wed, 19 Sep 2018 08:10:45 -0700 Subject: [PATCH] [infer][buck] use a unique name for the Infer Javac wrapper Reviewed By: ngorogiannis Differential Revision: D9924731 fbshipit-source-id: 6346bfd71 --- infer/lib/python/inferlib/bucklib.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/infer/lib/python/inferlib/bucklib.py b/infer/lib/python/inferlib/bucklib.py index 4889b63f7..f9e1940fb 100644 --- a/infer/lib/python/inferlib/bucklib.py +++ b/infer/lib/python/inferlib/bucklib.py @@ -33,6 +33,7 @@ INFER_JSON_REPORT = os.path.join(config.BUCK_INFER_OUT, INFER_JSON_COSTS_REPORT = os.path.join(config.BUCK_INFER_OUT, config.JSON_COSTS_REPORT_FILENAME) +INFER_SCRIPT_NAME = 'infer_wrapper.py' INFER_SCRIPT = """\ #!/usr/bin/env {python_executable} import subprocess @@ -65,22 +66,21 @@ def prepare_build(args): raise e # Create a script to be called by buck - infer_script = None - with tempfile.NamedTemporaryFile(delete=False, - prefix='infer_', - suffix='.py', - dir='.') as infer_script: - logging.info('Creating %s' % infer_script.name) - infer_script.file.write( + infer_script_path = os.path.join(os.getcwd(), INFER_SCRIPT_NAME) + if os.path.exists(infer_script_path): + raise Exception('{} already exists. Exiting'.format(infer_script_path)) + with open(infer_script_path, 'w') as infer_script: + logging.info('Creating %s' % infer_script_path) + infer_script.write( utils.encode(INFER_SCRIPT.format( python_executable=sys.executable, infer_command=infer_command))) - st = os.stat(infer_script.name) - os.chmod(infer_script.name, st.st_mode | stat.S_IEXEC) + st = os.stat(infer_script_path) + os.chmod(infer_script_path, st.st_mode | stat.S_IEXEC) - temp_files += [infer_script.name] - return temp_files, infer_script.name + temp_files += [infer_script_path] + return temp_files, infer_script_path def get_normalized_targets(buck_args):