From 142fe31fae691b554a2891f8fb8c550313515faa Mon Sep 17 00:00:00 2001 From: Dulma Churchill Date: Mon, 3 Apr 2017 04:03:51 -0700 Subject: [PATCH] [driver] Declare a clean command for xcodebuild with xcpretty Reviewed By: jberdine Differential Revision: D4802338 fbshipit-source-id: 1c57c5c --- infer/src/backend/infer.ml | 15 +++++++++------ .../src/integration/CaptureCompilationDatabase.ml | 8 ++------ .../integration/CaptureCompilationDatabase.mli | 3 ++- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/infer/src/backend/infer.ml b/infer/src/backend/infer.ml index f98005b8a..26075ad9a 100644 --- a/infer/src/backend/infer.ml +++ b/infer/src/backend/infer.ml @@ -78,7 +78,7 @@ type driver_mode = | Javac of Javac.compiler * string * string list | Maven of string * string list | PythonCapture of build_system * string list - | XcodeXcpretty + | XcodeXcpretty of string * string list [@@deriving compare] let equal_driver_mode = [%compare.equal : driver_mode] @@ -93,7 +93,7 @@ let pp_driver_mode fmt driver_mode = F.fprintf fmt " Error reading file '%s':@\n %a@." fname Exn.pp exn in match driver_mode with | Analyze | BuckGenrule _ | BuckCompilationDB | ClangCompilationDB _ | PythonCapture (_,_) - | XcodeXcpretty -> + | XcodeXcpretty _ -> (* these are pretty boring, do not log anything *) () | Javac (_, prog, args) -> @@ -121,6 +121,8 @@ let clean_compilation_command driver_mode = match driver_mode with | Clang (_, prog, _) -> Some (prog ^ " clean") + | XcodeXcpretty (prog, args) -> + Some (String.concat ~sep:" " (List.append (prog::args) ["clean"])) | _ -> None let remove_results_dir () = @@ -308,10 +310,11 @@ let capture = function | _ -> () ) - | XcodeXcpretty -> - L.stdout "Capturing using xcpretty...@\n"; + | XcodeXcpretty (prog, args) -> + L.stdout "Capturing using xcodebuild and xcpretty...@\n"; check_xcpretty (); - let json_cdb = CaptureCompilationDatabase.get_compilation_database_files_xcodebuild () in + let json_cdb = + CaptureCompilationDatabase.get_compilation_database_files_xcodebuild ~prog ~args in capture_with_compilation_database json_cdb let run_parallel_analysis () = @@ -462,7 +465,7 @@ let driver_mode_of_build_cmd build_cmd = | BMvn -> Maven (prog, args) | BXcode when Config.xcpretty -> - XcodeXcpretty + XcodeXcpretty (prog, args) | BAnt | BBuck | BGradle | BNdk | BXcode as build_system -> PythonCapture (build_system, build_cmd) diff --git a/infer/src/integration/CaptureCompilationDatabase.ml b/infer/src/integration/CaptureCompilationDatabase.ml index 95a0c64f0..5b41cbd71 100644 --- a/infer/src/integration/CaptureCompilationDatabase.ml +++ b/infer/src/integration/CaptureCompilationDatabase.ml @@ -115,15 +115,11 @@ let get_compilation_database_files_buck () = Process.print_error_and_exit "Incorrect buck command: %s. Please use buck build " cmd (** Compute the compilation database files. *) -let get_compilation_database_files_xcodebuild () = - let prog_args = List.rev Config.rest in +let get_compilation_database_files_xcodebuild ~prog ~args = let temp_dir = Config.results_dir ^/ "clang" in Utils.create_dir temp_dir; let tmp_file = Filename.temp_file ~in_dir:temp_dir "cdb" ".json" in - let xcodebuild_prog, xcodebuild_args = - match prog_args with - | prog :: _ -> (prog, prog_args) - | [] -> failwith("Build command cannot be empty") in + let xcodebuild_prog, xcodebuild_args = prog, prog::args in let xcpretty_prog = "xcpretty" in let xcpretty_args = [xcpretty_prog; "--report"; "json-compilation-database"; "--output"; tmp_file] in diff --git a/infer/src/integration/CaptureCompilationDatabase.mli b/infer/src/integration/CaptureCompilationDatabase.mli index 997fe0f57..a6da6be1d 100644 --- a/infer/src/integration/CaptureCompilationDatabase.mli +++ b/infer/src/integration/CaptureCompilationDatabase.mli @@ -23,4 +23,5 @@ val get_compilation_database_files_buck : unit -> [> `Raw of string ] list (** Get the compilation database files that contain the compilation given by the xcodebuild command, using xcpretty. *) -val get_compilation_database_files_xcodebuild : unit -> [> `Escaped of string ] list +val get_compilation_database_files_xcodebuild : prog:string -> args:string list -> + [> `Escaped of string ] list