let run ?(output=ocamlbuild_output()) command =
let outputs = Ed_outputs.outputs () in
let output' =
try outputs#output_by_name output#name
with Not_found ->
outputs#add_output (output :> Ed_outputs.output);
outputs#output_by_name output#name
in
outputs#show output#name;
let on_end code =
output'#set_label (Printf.sprintf "%s (ret %d)" output#name code);
analyze_ocaml_compilation
(fun pb ->
let error = match pb.pb_kind with
`Error s -> Some s
| `Warning (c, s) ->
if warning_is_error c then
Some s
else
None
in
match error with
None -> true
| Some msg ->
goto_error pb.pb_file pb.pb_line pb.pb_start pb.pb_stop msg;
false
)
output#contents
in
output#run ~reset: true command on_end