[reactive capture] Pass compilation db files to InferAnalyze, use absolute fnames

Summary: Make backend know filenames of compilation database. It will allow it to compile extra files when needed

Reviewed By: cristianoc

Differential Revision: D4231521

fbshipit-source-id: c462448
master
Andrzej Kotulski 8 years ago committed by Facebook Github Bot
parent afd29e71de
commit a8b0871660

@ -50,11 +50,15 @@ let cluster_should_be_analyzed cluster =
let pp_prolog fmt clusters =
F.fprintf fmt "INFERANALYZE= %s -results_dir '%s'\n@."
let compilation_dbs_cmd =
IList.map (F.sprintf "--clang-compilation-db-files %s") !Config.clang_compilation_db_files
|> String.concat " " in
F.fprintf fmt "INFERANALYZE= %s -results_dir '%s' %s \n@."
(Config.bin_dir // (CLOpt.exe_name Analyze))
(Escape.escape_map
(fun c -> if c = '#' then Some "\\#" else None)
Config.results_dir);
Config.results_dir)
compilation_dbs_cmd;
F.fprintf fmt "CLUSTERS=";
IList.iteri

@ -146,6 +146,10 @@ let check_xcpretty () =
--no-xcpretty.@.@.";
Unix.exit_immediately 1
let capture_with_compilation_database db_files =
Config.clang_compilation_db_files := IList.map filename_to_absolute db_files;
let compilation_database = CompilationDatabase.from_json_files db_files in
CaptureCompilationDatabase.capture_files_in_database compilation_database
let capture build_cmd = function
| Analyze ->
@ -153,11 +157,12 @@ let capture build_cmd = function
| Buck when Config.use_compilation_database <> None ->
L.stdout "Capturing using Buck's compilation database...@\n";
let json_cdb = CaptureCompilationDatabase.get_compilation_database_files_buck () in
CaptureCompilationDatabase.capture_files_in_database json_cdb
capture_with_compilation_database json_cdb
| ClangCompilationDatabase -> (
L.stdout "Capturing using a compilation database file...@\n";
match Config.rest with
| arg :: _ -> CaptureCompilationDatabase.capture_files_in_database [arg]
| arg :: _ ->
capture_with_compilation_database [arg]
| _ ->
failwith
"Error parsing arguments. Please, pass the compilation database json file as in \
@ -168,7 +173,7 @@ let capture build_cmd = function
L.stdout "Capturing using xcpretty...@\n";
check_xcpretty ();
let json_cdb = CaptureCompilationDatabase.get_compilation_database_files_xcodebuild () in
CaptureCompilationDatabase.capture_files_in_database json_cdb
capture_with_compilation_database json_cdb
| build_mode ->
L.stdout "Capturing in %s mode...@." (string_of_build_mode build_mode);
let in_buck_mode = build_mode = Buck in

@ -687,6 +687,10 @@ and clang_biniou_file =
CLOpt.mk_path_opt ~long:"clang-biniou-file" ~exes:CLOpt.[Clang] ~meta:"file"
"Specify a file containing the AST of the program, in biniou format"
and clang_compilation_db_files =
CLOpt.mk_path_list ~long:"clang-compilation-db-files"
"Files that contain compilation commands"
and clang_frontend_action =
CLOpt.mk_symbol_opt ~long:"clang-frontend-action"
~exes:CLOpt.[Clang]

@ -312,6 +312,8 @@ val run_with_abs_val_equal_zero : ('a -> 'b) -> 'a -> 'b
val allow_leak : bool ref
val clang_compilation_db_files : string list ref
(** Command Line Interface Documentation *)
val print_usage_exit : unit -> 'a

@ -174,6 +174,5 @@ let get_compilation_database_files_xcodebuild () =
exit 1
let capture_files_in_database db_json_files =
let compilation_database = CompilationDatabase.from_json_files db_json_files in
let capture_files_in_database compilation_database =
run_compilation_database compilation_database (should_capture_file_from_index ())

@ -10,7 +10,7 @@
(** capture_files_in_database file runs the capture of the files for which
we have compilation commands in the database. If the option changed-files-index
is passed, we only capture the files there *)
val capture_files_in_database : string list -> unit
val capture_files_in_database : CompilationDatabase.t -> unit
(** Get the compilation database files that contain the compilation given by the
buck command. It will be the compilation of the passed targets only or also

Loading…
Cancel
Save