fixing some of the issues with passing classpath in a file

Reviewed By: jvillard

Differential Revision: D3604046

fbshipit-source-id: d6d97f6
master
Sam Blackshear 9 years ago committed by Facebook Github Bot 3
parent 3233666b11
commit 0a747b8eb2

@ -71,6 +71,17 @@ def create_infer_command(args, javac_arguments):
) )
# return True if string is empty or an escaped variant of empty
def _is_empty_classpath(string):
stripped = string.strip("'").strip('"')
if stripped == '':
return True
elif stripped == string:
return False
else:
return _is_empty_classpath(stripped)
class AnnotationProcessorNotFound(Exception): class AnnotationProcessorNotFound(Exception):
def __init__(self, path): def __init__(self, path):
@ -131,13 +142,18 @@ class CompilerCall(object):
prefix, suffix = prefix_suffix prefix, suffix = prefix_suffix
with tempfile.NamedTemporaryFile( with tempfile.NamedTemporaryFile(
dir=self.args.infer_out, dir=self.args.infer_out,
prefix=args_file_name + '_',
suffix='_cp', suffix='_cp',
delete=False) as args_file_cp: delete=False) as args_file_cp:
args_file_name_cp = args_file_cp.name cp_line, _, after_cp = suffix.partition('\n')
# avoid errors the happen when we get -classpath '"',
# -classpath '', or similar from the args file
if _is_empty_classpath(cp_line):
cp_line = '\n'
else:
cp_line = ':%s\n' % cp_line
args_file_cp.write( args_file_cp.write(
prefix + '-classpath\n' + classpath + ':' + suffix) prefix + '-classpath\n' + classpath + cp_line + after_cp)
at_arg_cp = '@' + args_file_name_cp at_arg_cp = '@' + args_file_cp.name
self.remaining_args = [ self.remaining_args = [
at_arg_cp if arg == at_arg else arg at_arg_cp if arg == at_arg else arg
for arg in self.remaining_args] for arg in self.remaining_args]

Loading…
Cancel
Save