[clang db] add ClangCompilationDB build mode to make sure infer-out is deleted when needed

Summary:
One of the tests was failing without `make clean` because infer-out didn't get
deleted when rerunning the clang db test. This was because infer thinks it's in
`Analyze` mode when capturing clang db files.

Reviewed By: akotulski

Differential Revision: D4397731

fbshipit-source-id: 26f423a
master
Jules Villard 8 years ago committed by Facebook Github Bot
parent a6f54b9cef
commit ffd322aca5

@ -39,7 +39,7 @@ let rec rmtree name =
type build_mode = type build_mode =
| Analyze | Ant | Buck | Gradle | Java | Javac | Make | Mvn | Ndk | Xcode | Analyze | Ant | Buck | ClangCompilationDB | Gradle | Java | Javac | Make | Mvn | Ndk | Xcode
let build_mode_of_string path = let build_mode_of_string path =
match Filename.basename path with match Filename.basename path with
@ -59,6 +59,7 @@ let string_of_build_mode = function
| Analyze -> "analyze" | Analyze -> "analyze"
| Ant -> "ant" | Ant -> "ant"
| Buck -> "buck" | Buck -> "buck"
| ClangCompilationDB -> "clang compilation database"
| Gradle -> "gradle" | Gradle -> "gradle"
| Java -> "java" | Java -> "java"
| Javac -> "javac" | Javac -> "javac"
@ -193,14 +194,15 @@ let capture build_cmd build_mode =
| _, Some path -> | _, Some path ->
L.stdout "Capturing for Buck genrule compatibility...@\n"; L.stdout "Capturing for Buck genrule compatibility...@\n";
JMain.main (lazy (JClasspath.load_from_arguments path)) JMain.main (lazy (JClasspath.load_from_arguments path))
| Analyze, _ when not (List.is_empty !Config.clang_compilation_db_files) ->
capture_with_compilation_database !Config.clang_compilation_db_files
| Analyze, _ -> | Analyze, _ ->
() ()
| 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
capture_with_compilation_database json_cdb capture_with_compilation_database json_cdb
| ClangCompilationDB, _ ->
L.stdout "Capturing using compilation database...@\n";
capture_with_compilation_database !Config.clang_compilation_db_files
| (Java | Javac), _ -> | (Java | Javac), _ ->
let verbose_out_file = run_javac build_mode build_cmd in let verbose_out_file = run_javac build_mode build_cmd in
if Config.analyzer <> Config.Compile then if Config.analyzer <> Config.Compile then
@ -337,7 +339,14 @@ let fail_on_issue_epilogue () =
let () = let () =
let build_cmd = IList.rev Config.rest in let build_cmd = IList.rev Config.rest in
let build_mode = match build_cmd with path :: _ -> build_mode_of_string path | [] -> Analyze in let build_mode = match build_cmd with
| path :: _ ->
build_mode_of_string path
| [] ->
if not (List.is_empty !Config.clang_compilation_db_files) then
ClangCompilationDB
else
Analyze in
if not (build_mode = Analyze || Config.(buck || continue_capture || reactive_mode)) then if not (build_mode = Analyze || Config.(buck || continue_capture || reactive_mode)) then
remove_results_dir () ; remove_results_dir () ;
create_results_dir () ; create_results_dir () ;

Loading…
Cancel
Save