[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 9 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 = 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)) (Config.bin_dir // (CLOpt.exe_name Analyze))
(Escape.escape_map (Escape.escape_map
(fun c -> if c = '#' then Some "\\#" else None) (fun c -> if c = '#' then Some "\\#" else None)
Config.results_dir); Config.results_dir)
compilation_dbs_cmd;
F.fprintf fmt "CLUSTERS="; F.fprintf fmt "CLUSTERS=";
IList.iteri IList.iteri

@ -146,6 +146,10 @@ let check_xcpretty () =
--no-xcpretty.@.@."; --no-xcpretty.@.@.";
Unix.exit_immediately 1 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 let capture build_cmd = function
| Analyze -> | Analyze ->
@ -153,11 +157,12 @@ let capture build_cmd = function
| Buck when Config.use_compilation_database <> None -> | Buck when Config.use_compilation_database <> None ->
L.stdout "Capturing using Buck's compilation database...@\n"; L.stdout "Capturing using Buck's compilation database...@\n";
let json_cdb = CaptureCompilationDatabase.get_compilation_database_files_buck () in let json_cdb = CaptureCompilationDatabase.get_compilation_database_files_buck () in
CaptureCompilationDatabase.capture_files_in_database json_cdb capture_with_compilation_database json_cdb
| ClangCompilationDatabase -> ( | ClangCompilationDatabase -> (
L.stdout "Capturing using a compilation database file...@\n"; L.stdout "Capturing using a compilation database file...@\n";
match Config.rest with match Config.rest with
| arg :: _ -> CaptureCompilationDatabase.capture_files_in_database [arg] | arg :: _ ->
capture_with_compilation_database [arg]
| _ -> | _ ->
failwith failwith
"Error parsing arguments. Please, pass the compilation database json file as in \ "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"; L.stdout "Capturing using xcpretty...@\n";
check_xcpretty (); check_xcpretty ();
let json_cdb = CaptureCompilationDatabase.get_compilation_database_files_xcodebuild () in 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 -> | build_mode ->
L.stdout "Capturing in %s mode...@." (string_of_build_mode build_mode); L.stdout "Capturing in %s mode...@." (string_of_build_mode build_mode);
let in_buck_mode = build_mode = Buck in 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" 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" "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 = and clang_frontend_action =
CLOpt.mk_symbol_opt ~long:"clang-frontend-action" CLOpt.mk_symbol_opt ~long:"clang-frontend-action"
~exes:CLOpt.[Clang] ~exes:CLOpt.[Clang]

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

@ -174,6 +174,5 @@ let get_compilation_database_files_xcodebuild () =
exit 1 exit 1
let capture_files_in_database db_json_files = let capture_files_in_database compilation_database =
let compilation_database = CompilationDatabase.from_json_files db_json_files in
run_compilation_database compilation_database (should_capture_file_from_index ()) 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 (** 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 we have compilation commands in the database. If the option changed-files-index
is passed, we only capture the files there *) 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 (** 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 buck command. It will be the compilation of the passed targets only or also

Loading…
Cancel
Save