[driver] Declare a clean command for xcodebuild with xcpretty

Reviewed By: jberdine

Differential Revision: D4802338

fbshipit-source-id: 1c57c5c
master
Dulma Churchill 8 years ago committed by Facebook Github Bot
parent 15ede90c44
commit 142fe31fae

@ -78,7 +78,7 @@ type driver_mode =
| Javac of Javac.compiler * string * string list | Javac of Javac.compiler * string * string list
| Maven of string * string list | Maven of string * string list
| PythonCapture of build_system * string list | PythonCapture of build_system * string list
| XcodeXcpretty | XcodeXcpretty of string * string list
[@@deriving compare] [@@deriving compare]
let equal_driver_mode = [%compare.equal : driver_mode] 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 F.fprintf fmt " Error reading file '%s':@\n %a@." fname Exn.pp exn in
match driver_mode with match driver_mode with
| Analyze | BuckGenrule _ | BuckCompilationDB | ClangCompilationDB _ | PythonCapture (_,_) | Analyze | BuckGenrule _ | BuckCompilationDB | ClangCompilationDB _ | PythonCapture (_,_)
| XcodeXcpretty -> | XcodeXcpretty _ ->
(* these are pretty boring, do not log anything *) (* these are pretty boring, do not log anything *)
() ()
| Javac (_, prog, args) -> | Javac (_, prog, args) ->
@ -121,6 +121,8 @@ let clean_compilation_command driver_mode =
match driver_mode with match driver_mode with
| Clang (_, prog, _) -> | Clang (_, prog, _) ->
Some (prog ^ " clean") Some (prog ^ " clean")
| XcodeXcpretty (prog, args) ->
Some (String.concat ~sep:" " (List.append (prog::args) ["clean"]))
| _ -> None | _ -> None
let remove_results_dir () = let remove_results_dir () =
@ -308,10 +310,11 @@ let capture = function
| _ -> | _ ->
() ()
) )
| XcodeXcpretty -> | XcodeXcpretty (prog, args) ->
L.stdout "Capturing using xcpretty...@\n"; L.stdout "Capturing using xcodebuild and 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 ~prog ~args in
capture_with_compilation_database json_cdb capture_with_compilation_database json_cdb
let run_parallel_analysis () = let run_parallel_analysis () =
@ -462,7 +465,7 @@ let driver_mode_of_build_cmd build_cmd =
| BMvn -> | BMvn ->
Maven (prog, args) Maven (prog, args)
| BXcode when Config.xcpretty -> | BXcode when Config.xcpretty ->
XcodeXcpretty XcodeXcpretty (prog, args)
| BAnt | BBuck | BGradle | BNdk | BXcode as build_system -> | BAnt | BBuck | BGradle | BNdk | BXcode as build_system ->
PythonCapture (build_system, build_cmd) PythonCapture (build_system, build_cmd)

@ -115,15 +115,11 @@ let get_compilation_database_files_buck () =
Process.print_error_and_exit "Incorrect buck command: %s. Please use buck build <targets>" cmd Process.print_error_and_exit "Incorrect buck command: %s. Please use buck build <targets>" cmd
(** Compute the compilation database files. *) (** Compute the compilation database files. *)
let get_compilation_database_files_xcodebuild () = let get_compilation_database_files_xcodebuild ~prog ~args =
let prog_args = List.rev Config.rest in
let temp_dir = Config.results_dir ^/ "clang" in let temp_dir = Config.results_dir ^/ "clang" in
Utils.create_dir temp_dir; Utils.create_dir temp_dir;
let tmp_file = Filename.temp_file ~in_dir:temp_dir "cdb" ".json" in let tmp_file = Filename.temp_file ~in_dir:temp_dir "cdb" ".json" in
let xcodebuild_prog, xcodebuild_args = let xcodebuild_prog, xcodebuild_args = prog, prog::args in
match prog_args with
| prog :: _ -> (prog, prog_args)
| [] -> failwith("Build command cannot be empty") in
let xcpretty_prog = "xcpretty" in let xcpretty_prog = "xcpretty" in
let xcpretty_args = let xcpretty_args =
[xcpretty_prog; "--report"; "json-compilation-database"; "--output"; tmp_file] in [xcpretty_prog; "--report"; "json-compilation-database"; "--output"; tmp_file] in

@ -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 (** Get the compilation database files that contain the compilation given by the
xcodebuild command, using xcpretty. *) 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

Loading…
Cancel
Save