diff --git a/bin/main.ml b/bin/main.ml index 1fa26e2d..c1d02266 100644 --- a/bin/main.ml +++ b/bin/main.ml @@ -195,11 +195,11 @@ let all = ] let () = + Ansi_color.setup_err_formatter_colors (); try match Term.eval_choice (build_targets ~name:"jbuilder") all ~catch:false with | `Error _ -> exit 1 | _ -> exit 0 with exn -> - Ansi_color.setup_err_formatter_colors (); Format.eprintf "%a@?" (Main.report_error ?map_fname:None) exn; exit 1 diff --git a/src/ansi_color.ml b/src/ansi_color.ml index ec8a0e00..64bce73d 100644 --- a/src/ansi_color.ml +++ b/src/ansi_color.ml @@ -152,6 +152,9 @@ let setup_err_formatter_colors () = | "loc" -> [Bold] | "error" -> [Bold; Foreground Red] | "warning" -> [Bold; Foreground Magenta] + | "kwd" -> [Bold; Foreground Blue] + | "id" -> [Bold; Foreground Yellow] + | "prompt" -> [Bold; Foreground Green] | _ -> [])) } end diff --git a/src/ansi_color.mli b/src/ansi_color.mli index 14d5d8dd..35024f30 100644 --- a/src/ansi_color.mli +++ b/src/ansi_color.mli @@ -6,6 +6,5 @@ val setup_env_for_ocaml_colors : unit Lazy.t (** Strip colors in [not (Lazy.force stderr_supports_colors)] *) val strip_colors_for_stderr : string -> string -(** Enable the interpretation of ["loc"], ["error"] and ["warning"] tags for - [Format.err_formatter] *) +(** Enable the interpretation of color tags for [Format.err_formatter] *) val setup_err_formatter_colors : unit -> unit diff --git a/src/future.ml b/src/future.ml index 4a8d185b..b7732fe8 100644 --- a/src/future.ml +++ b/src/future.ml @@ -235,13 +235,6 @@ module Scheduler = struct 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) = Hashtbl.remove running job.pid; let output = @@ -271,13 +264,15 @@ module Scheduler = struct Printf.eprintf "Output[%d]:\n%s%!" job.id output; Ivar.fill job.job.ivar () | WEXITED n -> - Printf.eprintf "\nCommand [%d] exited with code %d:\n$ %s\n%s%!" + Format.eprintf "\n@{Command@} [@{%d@}] exited with code %d:\n\ + @{$@} %s\n%s%!" job.id n (Ansi_color.strip_colors_for_stderr job.command_line) (Ansi_color.strip_colors_for_stderr output); die "" | WSIGNALED n -> - Printf.eprintf "\nCommand [%d] got signal %d:\n$ %s\n%s%!" + Printf.eprintf "\n@{Command@} [@{%d@}] got signal %d:\n\ + @{$@} %s\n%s%!" job.id n (Ansi_color.strip_colors_for_stderr job.command_line) (Ansi_color.strip_colors_for_stderr output); @@ -325,7 +320,7 @@ module Scheduler = struct let id = gen_id () in let command_line = command_line job in if !Clflags.debug_run then - Printf.eprintf "Running[%d]: %s\n%!" id + Format.eprintf "@{Running@}[@{%d@}]: %s@." id (Ansi_color.strip_colors_for_stderr command_line); Option.iter job.dir ~f:(fun dir -> Sys.chdir dir); let argv = Array.of_list (job.prog :: job.args) in diff --git a/src/main.ml b/src/main.ml index abc3e694..58335652 100644 --- a/src/main.ml +++ b/src/main.ml @@ -56,10 +56,10 @@ let report_error ?(map_fname=fun x->x) ppf exn ~backtrace = | Fatal_error msg -> Format.fprintf ppf "%s\n" (String.capitalize msg) | Findlib.Package_not_found pkg -> - Format.fprintf ppf "Findlib package %S not found.\n" pkg + Format.fprintf ppf "@{Findlib package %S not found.@}\n" pkg | Code_error msg -> let bt = Printexc.raw_backtrace_to_string backtrace in - Format.fprintf ppf "Internal error, please report upstream.\n\ + Format.fprintf ppf "@{Internal error, please report upstream.@}\n\ Description: %s\n\ Backtrace:\n\ %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 Format.fprintf ppf "%s\nBacktrace:\n%s" s bt else - Format.fprintf ppf "Error: exception %s\nBacktrace:\n%s" s bt + Format.fprintf ppf "@{Error@}: exception %s\nBacktrace:\n%s" s bt let report_error ?map_fname ppf exn = match exn with