[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
| 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)

@ -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
(** 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

@ -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

Loading…
Cancel
Save