A bit more colors
This commit is contained in:
parent
03f788a0fa
commit
a3cd58de5d
|
@ -195,11 +195,11 @@ let all =
|
||||||
]
|
]
|
||||||
|
|
||||||
let () =
|
let () =
|
||||||
|
Ansi_color.setup_err_formatter_colors ();
|
||||||
try
|
try
|
||||||
match Term.eval_choice (build_targets ~name:"jbuilder") all ~catch:false with
|
match Term.eval_choice (build_targets ~name:"jbuilder") all ~catch:false with
|
||||||
| `Error _ -> exit 1
|
| `Error _ -> exit 1
|
||||||
| _ -> exit 0
|
| _ -> exit 0
|
||||||
with exn ->
|
with exn ->
|
||||||
Ansi_color.setup_err_formatter_colors ();
|
|
||||||
Format.eprintf "%a@?" (Main.report_error ?map_fname:None) exn;
|
Format.eprintf "%a@?" (Main.report_error ?map_fname:None) exn;
|
||||||
exit 1
|
exit 1
|
||||||
|
|
|
@ -152,6 +152,9 @@ let setup_err_formatter_colors () =
|
||||||
| "loc" -> [Bold]
|
| "loc" -> [Bold]
|
||||||
| "error" -> [Bold; Foreground Red]
|
| "error" -> [Bold; Foreground Red]
|
||||||
| "warning" -> [Bold; Foreground Magenta]
|
| "warning" -> [Bold; Foreground Magenta]
|
||||||
|
| "kwd" -> [Bold; Foreground Blue]
|
||||||
|
| "id" -> [Bold; Foreground Yellow]
|
||||||
|
| "prompt" -> [Bold; Foreground Green]
|
||||||
| _ -> []))
|
| _ -> []))
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,6 +6,5 @@ val setup_env_for_ocaml_colors : unit Lazy.t
|
||||||
(** Strip colors in [not (Lazy.force stderr_supports_colors)] *)
|
(** Strip colors in [not (Lazy.force stderr_supports_colors)] *)
|
||||||
val strip_colors_for_stderr : string -> string
|
val strip_colors_for_stderr : string -> string
|
||||||
|
|
||||||
(** Enable the interpretation of ["loc"], ["error"] and ["warning"] tags for
|
(** Enable the interpretation of color tags for [Format.err_formatter] *)
|
||||||
[Format.err_formatter] *)
|
|
||||||
val setup_err_formatter_colors : unit -> unit
|
val setup_err_formatter_colors : unit -> unit
|
||||||
|
|
|
@ -235,13 +235,6 @@ module Scheduler = struct
|
||||||
|
|
||||||
let running = Hashtbl.create 128
|
let running = Hashtbl.create 128
|
||||||
|
|
||||||
let handle_process_status job (status : Unix.process_status) =
|
|
||||||
match status with
|
|
||||||
| WEXITED 0 -> ()
|
|
||||||
| WEXITED n -> die "Command [%d] exited with code %d" job.id n
|
|
||||||
| WSIGNALED n -> die "Command [%d] got killed by signal %d" job.id n
|
|
||||||
| WSTOPPED _ -> assert false
|
|
||||||
|
|
||||||
let process_done ?(exiting=false) job (status : Unix.process_status) =
|
let process_done ?(exiting=false) job (status : Unix.process_status) =
|
||||||
Hashtbl.remove running job.pid;
|
Hashtbl.remove running job.pid;
|
||||||
let output =
|
let output =
|
||||||
|
@ -271,13 +264,15 @@ module Scheduler = struct
|
||||||
Printf.eprintf "Output[%d]:\n%s%!" job.id output;
|
Printf.eprintf "Output[%d]:\n%s%!" job.id output;
|
||||||
Ivar.fill job.job.ivar ()
|
Ivar.fill job.job.ivar ()
|
||||||
| WEXITED n ->
|
| WEXITED n ->
|
||||||
Printf.eprintf "\nCommand [%d] exited with code %d:\n$ %s\n%s%!"
|
Format.eprintf "\n@{<kwd>Command@} [@{<id>%d@}] exited with code %d:\n\
|
||||||
|
@{<prompt>$@} %s\n%s%!"
|
||||||
job.id n
|
job.id n
|
||||||
(Ansi_color.strip_colors_for_stderr job.command_line)
|
(Ansi_color.strip_colors_for_stderr job.command_line)
|
||||||
(Ansi_color.strip_colors_for_stderr output);
|
(Ansi_color.strip_colors_for_stderr output);
|
||||||
die ""
|
die ""
|
||||||
| WSIGNALED n ->
|
| WSIGNALED n ->
|
||||||
Printf.eprintf "\nCommand [%d] got signal %d:\n$ %s\n%s%!"
|
Printf.eprintf "\n@{<kwd>Command@} [@{<id>%d@}] got signal %d:\n\
|
||||||
|
@{<prompt>$@} %s\n%s%!"
|
||||||
job.id n
|
job.id n
|
||||||
(Ansi_color.strip_colors_for_stderr job.command_line)
|
(Ansi_color.strip_colors_for_stderr job.command_line)
|
||||||
(Ansi_color.strip_colors_for_stderr output);
|
(Ansi_color.strip_colors_for_stderr output);
|
||||||
|
@ -325,7 +320,7 @@ module Scheduler = struct
|
||||||
let id = gen_id () in
|
let id = gen_id () in
|
||||||
let command_line = command_line job in
|
let command_line = command_line job in
|
||||||
if !Clflags.debug_run then
|
if !Clflags.debug_run then
|
||||||
Printf.eprintf "Running[%d]: %s\n%!" id
|
Format.eprintf "@{<kwd>Running@}[@{<id>%d@}]: %s@." id
|
||||||
(Ansi_color.strip_colors_for_stderr command_line);
|
(Ansi_color.strip_colors_for_stderr command_line);
|
||||||
Option.iter job.dir ~f:(fun dir -> Sys.chdir dir);
|
Option.iter job.dir ~f:(fun dir -> Sys.chdir dir);
|
||||||
let argv = Array.of_list (job.prog :: job.args) in
|
let argv = Array.of_list (job.prog :: job.args) in
|
||||||
|
|
|
@ -56,10 +56,10 @@ let report_error ?(map_fname=fun x->x) ppf exn ~backtrace =
|
||||||
| Fatal_error msg ->
|
| Fatal_error msg ->
|
||||||
Format.fprintf ppf "%s\n" (String.capitalize msg)
|
Format.fprintf ppf "%s\n" (String.capitalize msg)
|
||||||
| Findlib.Package_not_found pkg ->
|
| Findlib.Package_not_found pkg ->
|
||||||
Format.fprintf ppf "Findlib package %S not found.\n" pkg
|
Format.fprintf ppf "@{<error>Findlib package %S not found.@}\n" pkg
|
||||||
| Code_error msg ->
|
| Code_error msg ->
|
||||||
let bt = Printexc.raw_backtrace_to_string backtrace in
|
let bt = Printexc.raw_backtrace_to_string backtrace in
|
||||||
Format.fprintf ppf "Internal error, please report upstream.\n\
|
Format.fprintf ppf "@{<error>Internal error, please report upstream.@}\n\
|
||||||
Description: %s\n\
|
Description: %s\n\
|
||||||
Backtrace:\n\
|
Backtrace:\n\
|
||||||
%s" msg bt
|
%s" msg bt
|
||||||
|
@ -69,7 +69,7 @@ let report_error ?(map_fname=fun x->x) ppf exn ~backtrace =
|
||||||
if String.is_prefix s ~prefix:"File \"" then
|
if String.is_prefix s ~prefix:"File \"" then
|
||||||
Format.fprintf ppf "%s\nBacktrace:\n%s" s bt
|
Format.fprintf ppf "%s\nBacktrace:\n%s" s bt
|
||||||
else
|
else
|
||||||
Format.fprintf ppf "Error: exception %s\nBacktrace:\n%s" s bt
|
Format.fprintf ppf "@{<error>Error@}: exception %s\nBacktrace:\n%s" s bt
|
||||||
|
|
||||||
let report_error ?map_fname ppf exn =
|
let report_error ?map_fname ppf exn =
|
||||||
match exn with
|
match exn with
|
||||||
|
|
Loading…
Reference in New Issue