[infer][buck] use a unique name for the Infer Javac wrapper

Reviewed By: ngorogiannis

Differential Revision: D9924731

fbshipit-source-id: 6346bfd71
master
Jeremy Dubreil 6 years ago committed by Facebook Github Bot
parent 88bdf7a797
commit f2282a8277

@ -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, INFER_JSON_COSTS_REPORT = os.path.join(config.BUCK_INFER_OUT,
config.JSON_COSTS_REPORT_FILENAME) config.JSON_COSTS_REPORT_FILENAME)
INFER_SCRIPT_NAME = 'infer_wrapper.py'
INFER_SCRIPT = """\ INFER_SCRIPT = """\
#!/usr/bin/env {python_executable} #!/usr/bin/env {python_executable}
import subprocess import subprocess
@ -65,22 +66,21 @@ def prepare_build(args):
raise e raise e
# Create a script to be called by buck # Create a script to be called by buck
infer_script = None infer_script_path = os.path.join(os.getcwd(), INFER_SCRIPT_NAME)
with tempfile.NamedTemporaryFile(delete=False, if os.path.exists(infer_script_path):
prefix='infer_', raise Exception('{} already exists. Exiting'.format(infer_script_path))
suffix='.py', with open(infer_script_path, 'w') as infer_script:
dir='.') as infer_script: logging.info('Creating %s' % infer_script_path)
logging.info('Creating %s' % infer_script.name) infer_script.write(
infer_script.file.write(
utils.encode(INFER_SCRIPT.format( utils.encode(INFER_SCRIPT.format(
python_executable=sys.executable, python_executable=sys.executable,
infer_command=infer_command))) infer_command=infer_command)))
st = os.stat(infer_script.name) st = os.stat(infer_script_path)
os.chmod(infer_script.name, st.st_mode | stat.S_IEXEC) os.chmod(infer_script_path, st.st_mode | stat.S_IEXEC)
temp_files += [infer_script.name] temp_files += [infer_script_path]
return temp_files, infer_script.name return temp_files, infer_script_path
def get_normalized_targets(buck_args): def get_normalized_targets(buck_args):

Loading…
Cancel
Save