From 8e1b566c33f299e49ebf64332d871aba6ea469ed Mon Sep 17 00:00:00 2001 From: David Allsopp Date: Sat, 15 Dec 2018 09:57:50 +0100 Subject: [PATCH] Add --no-print-directory command line argument (#1668) Suppresses the `Entering directory` message, as in GNU make. Signed-off-by: David Allsopp --- CHANGES.md | 3 +++ bin/common.ml | 8 ++++++++ bin/common.mli | 1 + doc/usage.rst | 3 +++ src/clflags.ml | 1 + src/clflags.mli | 3 +++ src/scheduler.ml | 2 +- 7 files changed, 20 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index a583d610766..6e1974b3a2f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -40,6 +40,9 @@ unreleased - Add `--trace-file` option to trace dune internals (#1639, fix #1180, @emillon) +- Add `--no-print-directory` (borrowed from GNU make) to suppress + `Entering directory` messages. (#1668, @dra27) + - Remove `--stats` and track fd usage in `--trace-file` (#1667, @emillon) 1.6.2 (05/12/2018) diff --git a/bin/common.ml b/bin/common.ml index 263fd1302e5..035b92606f3 100644 --- a/bin/common.ml +++ b/bin/common.ml @@ -20,6 +20,7 @@ type t = ; force : bool ; ignore_promoted_rules : bool ; build_dir : string + ; no_print_directory : bool ; (* Original arguments for the external-lib-deps hint *) orig_args : string list ; config : Config.t @@ -46,6 +47,7 @@ let set_common_other c ~targets = Clflags.auto_promote := c.auto_promote; Clflags.force := c.force; Clflags.watch := c.watch; + Clflags.no_print_directory := c.no_print_directory; Clflags.external_lib_deps_hint := List.concat [ ["dune"; "external-lib-deps"; "--missing"] @@ -333,6 +335,11 @@ let term = & info ["trace-file"] ~docs ~docv:"FILE" ~doc:"Output trace data in catapult format (compatible with chrome://tracing)") + and no_print_directory = + Arg.(value + & flag + & info ["no-print-directory"] ~docs + ~doc:"Suppress \"Entering directory\" messages") in let build_dir = Option.value ~default:"_build" build_dir in let root, to_cwd = @@ -384,6 +391,7 @@ let term = ; x ; config ; build_dir + ; no_print_directory ; default_target ; watch ; stats_trace_file diff --git a/bin/common.mli b/bin/common.mli index a874ede3c8b..7995d8cc4f7 100644 --- a/bin/common.mli +++ b/bin/common.mli @@ -16,6 +16,7 @@ type t = ; force : bool ; ignore_promoted_rules : bool ; build_dir : string + ; no_print_directory : bool ; (* Original arguments for the external-lib-deps hint *) orig_args : string list ; config : Config.t diff --git a/doc/usage.rst b/doc/usage.rst index ff0b8945ddd..f7cd8f55e12 100644 --- a/doc/usage.rst +++ b/doc/usage.rst @@ -48,6 +48,9 @@ to setup the configuration of the workspace unless the ``--workspace`` command line option is used. See the section `Workspace configuration`_ for the syntax of this file. +The ``Entering directory`` message can be suppressed with the +``--no-print-directory`` command line option (as in GNU make). + Current directory ----------------- diff --git a/src/clflags.ml b/src/clflags.ml index 9262d9f75fe..7f08f60adf9 100644 --- a/src/clflags.ml +++ b/src/clflags.ml @@ -7,3 +7,4 @@ let diff_command = ref None let auto_promote = ref false let force = ref false let watch = ref false +let no_print_directory = ref false diff --git a/src/clflags.mli b/src/clflags.mli index 8620ca3f3cf..d4ea8352f6f 100644 --- a/src/clflags.mli +++ b/src/clflags.mli @@ -26,3 +26,6 @@ val force : bool ref (** Instead of terminating build after completion, watch for changes *) val watch : bool ref + +(** Do not print "Entering directory" messages *) +val no_print_directory : bool ref diff --git a/src/scheduler.ml b/src/scheduler.ml index 6b61c1ef741..8c1207a4dfc 100644 --- a/src/scheduler.ml +++ b/src/scheduler.ml @@ -642,7 +642,7 @@ let prepare ?(log=Log.no_log) ?(config=Config.default) Signal_watcher.init (); Process_watcher.init (); let cwd = Sys.getcwd () in - if cwd <> initial_cwd then + if cwd <> initial_cwd && not !Clflags.no_print_directory then Printf.eprintf "Entering directory '%s'\n%!" (if Config.inside_dune then let descendant_simple p ~of_ =