summaryrefslogtreecommitdiff
path: root/driver
diff options
context:
space:
mode:
authorGabriel Scherer <gabriel.scherer@gmail.com>2015-08-15 15:57:51 +0000
committerGabriel Scherer <gabriel.scherer@gmail.com>2015-08-15 15:57:51 +0000
commitcb3bb152ab337b895a645c05c0b15d715e78e90b (patch)
tree842dee58e41054db3aef4e9bc019a67b53492e01 /driver
parent5893536b14c5801700892f85c6948a0fa2bb812a (diff)
downloadocaml-cb3bb152ab337b895a645c05c0b15d715e78e90b.tar.gz
add option handling for colors in compiler, OCAMLPARAM and ocamlbuild
(Simon Cruanes and Gabriel Scherer) Use one of -color auto -color always -color never git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@16348 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'driver')
-rw-r--r--driver/compenv.ml11
-rw-r--r--driver/main.ml5
-rw-r--r--driver/main_args.ml17
-rw-r--r--driver/main_args.mli1
-rw-r--r--driver/optmain.ml5
5 files changed, 39 insertions, 0 deletions
diff --git a/driver/compenv.ml b/driver/compenv.ml
index 6f3567e882..32d5f7e91c 100644
--- a/driver/compenv.ml
+++ b/driver/compenv.ml
@@ -212,6 +212,17 @@ let read_OCAMLPARAM ppf position =
"non-integer parameter for \"inline\""))
end
+ (* color output *)
+ | "color" ->
+ begin match parse_color_setting v with
+ | None ->
+ Location.print_warning Location.none ppf
+ (Warnings.Bad_env_variable ("OCAMLPARAM",
+ "bad value for \"color\", \
+ (expected \"auto\", \"always\" or \"never\")"))
+ | Some setting -> color := setting
+ end
+
| "intf-suffix" -> Config.interface_suffix := v
| "I" -> begin
diff --git a/driver/main.ml b/driver/main.ml
index 9835284989..e765d2eedd 100644
--- a/driver/main.ml
+++ b/driver/main.ml
@@ -128,6 +128,11 @@ module Options = Main_args.Make_bytecomp_options (struct
let _w = (Warnings.parse_options false)
let _warn_error = (Warnings.parse_options true)
let _warn_help = Warnings.help_warnings
+ let _color option =
+ begin match Clflags.parse_color_setting option with
+ | None -> ()
+ | Some setting -> Clflags.color := setting
+ end
let _where = print_standard_library
let _verbose = set verbose
let _nopervasives = set nopervasives
diff --git a/driver/main_args.ml b/driver/main_args.ml
index 7bf4c4945b..b44941f9f7 100644
--- a/driver/main_args.ml
+++ b/driver/main_args.ml
@@ -368,6 +368,19 @@ let mk_warn_help f =
"-warn-help", Arg.Unit f, " Show description of warning numbers"
;;
+let mk_color f =
+ "-color", Arg.Symbol (["auto"; "always"; "never"], f),
+ Printf.sprintf
+ " Enable or disable colors in compiler messages\n\
+ \ The following settings are supported:\n\
+ \ auto use heuristics to enable colors only if supported\n\
+ \ always enable colors\n\
+ \ never disable colors\n\
+ \ The default setting is 'auto', and the current heuristic\n\
+ \ checks that the TERM environment variable exists and is\n\
+ \ not empty or \"dumb\", and that isatty(stderr) holds."
+;;
+
let mk_where f =
"-where", Arg.Unit f, " Print location of standard library and exit"
;;
@@ -551,6 +564,8 @@ module type Compiler_options = sig
val _v : unit -> unit
val _verbose : unit -> unit
val _where : unit -> unit
+ val _color : string -> unit
+
val _nopervasives : unit -> unit
end
;;
@@ -659,6 +674,7 @@ struct
mk_cc F._cc;
mk_cclib F._cclib;
mk_ccopt F._ccopt;
+ mk_color F._color;
mk_compat_32 F._compat_32;
mk_config F._config;
mk_custom F._custom;
@@ -783,6 +799,7 @@ struct
mk_cc F._cc;
mk_cclib F._cclib;
mk_ccopt F._ccopt;
+ mk_color F._color;
mk_compact F._compact;
mk_config F._config;
mk_dtypes F._annot;
diff --git a/driver/main_args.mli b/driver/main_args.mli
index ddee921d4b..04f0c6d713 100644
--- a/driver/main_args.mli
+++ b/driver/main_args.mli
@@ -80,6 +80,7 @@ module type Compiler_options = sig
val _v : unit -> unit
val _verbose : unit -> unit
val _where : unit -> unit
+ val _color : string -> unit
val _nopervasives : unit -> unit
end
diff --git a/driver/optmain.ml b/driver/optmain.ml
index 84c27b7866..bef8d86b4f 100644
--- a/driver/optmain.ml
+++ b/driver/optmain.ml
@@ -129,6 +129,11 @@ module Options = Main_args.Make_optcomp_options (struct
let _w s = Warnings.parse_options false s
let _warn_error s = Warnings.parse_options true s
let _warn_help = Warnings.help_warnings
+ let _color option =
+ begin match Clflags.parse_color_setting option with
+ | None -> ()
+ | Some setting -> Clflags.color := setting
+ end
let _where () = print_standard_library ()
let _nopervasives = set nopervasives