diff --git a/infer/src/base/Utils.ml b/infer/src/base/Utils.ml index 3b0eb03eb..41db5ffa8 100644 --- a/infer/src/base/Utils.ml +++ b/infer/src/base/Utils.ml @@ -260,27 +260,6 @@ let with_process_in command read = do_finally_swallow_timeout ~f ~finally -let with_process_lines ~(debug : ('a, F.formatter, unit) format -> 'a) ~cmd ~tmp_prefix ~f = - let shell_cmd = List.map ~f:Escape.escape_shell cmd |> String.concat ~sep:" " in - let verbose_err_file = Filename.temp_file tmp_prefix ".err" in - let shell_cmd_redirected = Printf.sprintf "%s 2>'%s'" shell_cmd verbose_err_file in - debug "Trying to execute: %s@\n%!" shell_cmd_redirected ; - let input_lines chan = In_channel.input_lines ~fix_win_eol:true chan in - let res = with_process_in shell_cmd_redirected input_lines in - let verbose_errlog = with_file_in verbose_err_file ~f:In_channel.input_all in - if not (String.equal verbose_errlog "") then - debug "@\nlog:@\n<<<<<<@\n%s@\n>>>>>>@\n%!" verbose_errlog ; - match res with - | lines, Ok () -> - f lines - | lines, (Error _ as err) -> - let output = String.concat ~sep:"\n" lines in - L.(die ExternalError) - "*** Failed to execute: %s@\n*** Command: %s@\n*** Output:@\n%s@." - (Unix.Exit_or_signal.to_string_hum err) - shell_cmd output - - let is_dir_kind (kind : Unix.file_kind) = match kind with S_DIR -> true | _ -> false (** Recursively create a directory if it does not exist already. *) diff --git a/infer/src/base/Utils.mli b/infer/src/base/Utils.mli index 3e4528dd5..7f05b77fb 100644 --- a/infer/src/base/Utils.mli +++ b/infer/src/base/Utils.mli @@ -84,15 +84,6 @@ val with_channel_in : f:(string -> unit) -> In_channel.t -> unit val with_process_in : string -> (In_channel.t -> 'a) -> 'a * Unix.Exit_or_signal.t -val with_process_lines : - debug:((string -> unit, Format.formatter, unit) format -> string -> unit) - -> cmd:string list - -> tmp_prefix:string - -> f:(string list -> 'res) - -> 'res -(** Runs the command [cmd] and calls [f] on the output lines. Uses [debug] to print debug - information, and [tmp_prefix] as a prefix for temporary files. *) - val create_dir : string -> unit (** recursively create a directory if it does not exist already *) diff --git a/infer/src/integration/CaptureCompilationDatabase.ml b/infer/src/integration/CaptureCompilationDatabase.ml index c98727269..618fbfef7 100644 --- a/infer/src/integration/CaptureCompilationDatabase.ml +++ b/infer/src/integration/CaptureCompilationDatabase.ml @@ -86,7 +86,7 @@ let get_compilation_database_files_buck db_deps ~prog ~args = in Logging.(debug Linters Quiet) "Processed buck command is: 'buck %a'@\n" (Pp.seq F.pp_print_string) build_args ; - Process.create_process_and_wait ~prog ~args:build_args ; + Buck.wrap_buck_call ~label:"compdb_build" (prog :: build_args) |> ignore ; let buck_targets_shell = prog :: "targets" :: List.rev_append @@ -115,9 +115,7 @@ let get_compilation_database_files_buck db_deps ~prog ~args = in List.fold ~f:scan_output ~init:[] lines in - Utils.with_process_lines - ~debug:L.(debug Capture Quiet) - ~cmd:buck_targets_shell ~tmp_prefix:"buck_targets_" ~f:on_target_lines + Buck.wrap_buck_call ~label:"compdb_targets" buck_targets_shell |> on_target_lines | _ -> Process.print_error_and_exit "Incorrect buck command: %s %a. Please use buck build " prog (Pp.seq F.pp_print_string) args