Directly handle javac -classpath option in build command

Summary: Parse javac build commands and add classpath entries to specs_library.

Reviewed By: jeremydubreil

Differential Revision: D4162889

fbshipit-source-id: 48a4d38
master
Josh Berdine 8 years ago committed by Facebook Github Bot
parent a9253d8996
commit fb34f30350

@ -269,16 +269,6 @@ class AnalyzerWithFrontendWrapper(analyze.AnalyzerWrapper):
if self.args.analyzer == config.ANALYZER_CAPTURE:
return os.EX_OK
if self.args.buck:
if self.javac.args.classpath is not None:
infer_args = utils.read_env()['INFER_ARGS']
# 'INFER_ARGS' must be CommandLineOption.args_env_var
for path in self.javac.args.classpath.split(os.pathsep):
if os.path.isfile(path):
infer_args += '^--specs-library^' + os.path.abspath(path)
# '^' must be CommandLineOption.env_var_sep
os.environ['INFER_ARGS'] = utils.encode(infer_args)
self.analyze_and_report()
self._close()
self.timing['total'] = utils.elapsed_time(start_time)

@ -1246,13 +1246,23 @@ let rest =
results_dir := classes_out_infer
)
) in
let classpath_spec =
Arg.String (fun classpath ->
if !buck then (
let paths = String.split classpath ~on:':' in
let files = List.filter paths ~f:(fun path -> Sys.is_file path = `Yes) in
CLOpt.extend_env_args (List.concat_map files ~f:(fun file -> ["--specs-library"; file])) ;
specs_library := List.rev_append files !specs_library
)
) in
CLOpt.mk_subcommand
~exes:CLOpt.[Toplevel]
"Stop argument processing, use remaining arguments as a build command"
(fun build_exe ->
match Filename.basename build_exe with
| "java" | "javac" -> [
("-classes_out", classes_out_spec, ""); ("-d", classes_out_spec, "")
("-classes_out", classes_out_spec, ""); ("-d", classes_out_spec, "");
("-classpath", classpath_spec, ""); ("-cp", classpath_spec, "")
]
| _ -> []
)

Loading…
Cancel
Save