|
|
@ -32,22 +32,28 @@ let sentinel_exists sentinel_opt =
|
|
|
|
Option.value_map ~default:false sentinel_opt ~f:file_exists
|
|
|
|
Option.value_map ~default:false sentinel_opt ~f:file_exists
|
|
|
|
|
|
|
|
|
|
|
|
let invoke_cmd ~fail_sentinel cmd =
|
|
|
|
let invoke_cmd ~fail_sentinel cmd =
|
|
|
|
|
|
|
|
let create_sentinel_if_needed () =
|
|
|
|
|
|
|
|
let create_empty_file fname = Utils.with_file_out ~f:(fun _ -> ()) fname in
|
|
|
|
|
|
|
|
Option.iter fail_sentinel ~f:create_empty_file
|
|
|
|
|
|
|
|
in
|
|
|
|
if sentinel_exists fail_sentinel then L.progress "E%!"
|
|
|
|
if sentinel_exists fail_sentinel then L.progress "E%!"
|
|
|
|
else (
|
|
|
|
else
|
|
|
|
Unix.chdir cmd.cwd ;
|
|
|
|
try
|
|
|
|
let pid =
|
|
|
|
let pid =
|
|
|
|
Unix.fork_exec ~prog:cmd.prog ~argv:[cmd.prog; ("@" ^ cmd.args); "-fsyntax-only"]
|
|
|
|
let prog = cmd.prog in
|
|
|
|
~use_path:false ()
|
|
|
|
let argv = [prog; ("@" ^ cmd.args); "-fsyntax-only"] in
|
|
|
|
in
|
|
|
|
Spawn.(spawn ~cwd:(Path cmd.cwd) ~prog ~argv ())
|
|
|
|
let create_sentinel_if_needed () =
|
|
|
|
in
|
|
|
|
let create_empty_file fname = Utils.with_file_out ~f:(fun _ -> ()) fname in
|
|
|
|
match Unix.waitpid (Pid.of_int pid) with
|
|
|
|
Option.iter fail_sentinel ~f:create_empty_file
|
|
|
|
| Ok ()
|
|
|
|
in
|
|
|
|
-> L.progress ".%!"
|
|
|
|
match Unix.waitpid pid with
|
|
|
|
| Error _
|
|
|
|
| Ok ()
|
|
|
|
-> L.progress "!%!" ; create_sentinel_if_needed ()
|
|
|
|
-> L.progress ".%!"
|
|
|
|
with exn ->
|
|
|
|
| Error _
|
|
|
|
let trace = Printexc.get_backtrace () in
|
|
|
|
-> L.progress "!%!" ; create_sentinel_if_needed () )
|
|
|
|
L.external_error "@\nException caught:@\n%a.@\n%s@\n" Exn.pp exn trace ;
|
|
|
|
|
|
|
|
L.progress "X%!" ;
|
|
|
|
|
|
|
|
create_sentinel_if_needed ()
|
|
|
|
|
|
|
|
|
|
|
|
let run_compilation_database compilation_database should_capture_file =
|
|
|
|
let run_compilation_database compilation_database should_capture_file =
|
|
|
|
let compilation_data =
|
|
|
|
let compilation_data =
|
|
|
|