[infer][java] add support for Buck compilation commands with no source files

Summary: Buck is allowing compiler commands with no source files and skipping them when using the in-memory complier mode. However, those commands are not skipped when using an external compiler. Simulating this behavior at the level of Infer.

Reviewed By: mbouaziz, ngorogiannis

Differential Revision: D9795043

fbshipit-source-id: e80cfa453
master
Andrey Epin 6 years ago committed by Facebook Github Bot
parent d48e22be8b
commit 77744eda97

@ -83,8 +83,25 @@ let compile compiler build_prog build_args =
verbose_out_file
let no_source_file args =
let not_source_file arg =
let stripped_arg = String.strip ~drop:(fun char -> Char.equal char '\"') arg in
not (String.is_suffix ~suffix:".java" stripped_arg)
in
List.for_all args ~f:(fun arg ->
(* expand arg files *)
match String.chop_prefix ~prefix:"@" arg with
| None ->
not_source_file arg
| Some arg_file ->
List.for_all ~f:not_source_file (In_channel.read_lines arg_file) )
let capture compiler ~prog ~args =
match (compiler, Config.capture_blacklist) with
(* Simulates Buck support for compilation commands with no source file *)
| _ when Config.buck_cache_mode && no_source_file args ->
()
| Javac, Some blacklist
when let re = Str.regexp blacklist in
List.exists ~f:(fun arg -> Str.string_match re arg 0) args ->

Loading…
Cancel
Save