aboutsummaryrefslogtreecommitdiff
path: root/libbuild2
diff options
context:
space:
mode:
Diffstat (limited to 'libbuild2')
-rw-r--r--libbuild2/diagnostics.cxx6
-rw-r--r--libbuild2/diagnostics.hxx8
-rw-r--r--libbuild2/module.cxx15
-rw-r--r--libbuild2/utility.hxx6
4 files changed, 31 insertions, 4 deletions
diff --git a/libbuild2/diagnostics.cxx b/libbuild2/diagnostics.cxx
index 71f3d48..f1b8f74 100644
--- a/libbuild2/diagnostics.cxx
+++ b/libbuild2/diagnostics.cxx
@@ -21,6 +21,7 @@ namespace build2
// set from options.
//
uint16_t verb = 0;
+ bool silent = true;
optional<bool> diag_progress_option;
@@ -30,9 +31,12 @@ namespace build2
bool stderr_term = false;
void
- init_diag (uint16_t v, optional<bool> p, bool nl, bool nc, bool st)
+ init_diag (uint16_t v, bool s, optional<bool> p, bool nl, bool nc, bool st)
{
+ assert (!s || v == 0);
+
verb = v;
+ silent = s;
diag_progress_option = p;
diag_no_line = nl;
diag_no_column = nc;
diff --git a/libbuild2/diagnostics.hxx b/libbuild2/diagnostics.hxx
index 5d69132..26f602a 100644
--- a/libbuild2/diagnostics.hxx
+++ b/libbuild2/diagnostics.hxx
@@ -49,7 +49,7 @@ namespace build2
print_process (args.data (), n != 0 ? n : args.size ());
}
- // Program verbosity level (-v/--verbose).
+ // Program verbosity level (-v/--verbose plus --silent).
//
// 0 - disabled
// 1 - high-level information messages
@@ -59,13 +59,17 @@ namespace build2
// 5 - information helpful to the developer
// 6 - even more detailed information
//
+ // If silent is true, then the level must be 0 (silent is level 0 that
+ // cannot be relaxed in certain contexts).
+ //
// While uint8 is more than enough, use uint16 for the ease of printing.
//
// Forward-declarated in <libbuild2/utility.hxx>.
//
+ // const uint16_t verb_never = 7;
// extern uint16_t verb;
- // const uint16_t verb_never = 7;
+ // extern bool silent;
template <typename F> inline void l1 (const F& f) {if (verb >= 1) f ();}
template <typename F> inline void l2 (const F& f) {if (verb >= 2) f ();}
diff --git a/libbuild2/module.cxx b/libbuild2/module.cxx
index b73ddb3..50c6d53 100644
--- a/libbuild2/module.cxx
+++ b/libbuild2/module.cxx
@@ -262,6 +262,21 @@ namespace build2
? scheduler::tune_guard (ctx.sched, 0)
: scheduler::tune_guard ());
+ // Remap verbosity level 0 to 1 unless we were requested to be
+ // silent. Failed that, we may have long periods of seemingly
+ // nothing happening while we quietly update the module, which
+ // may look like things have hung up.
+ //
+ // @@ CTX: modifying global verbosity level won't work if we have
+ // multiple top-level contexts running in parallel.
+ //
+ auto verbg = make_guard (
+ [z = !silent && verb == 0 ? (verb = 1, true) : false] ()
+ {
+ if (z)
+ verb = 0;
+ });
+
// Note that for now we suppress progress since it would clash with
// the progress of what we are already doing (maybe in the future we
// can do save/restore but then we would need some sort of
diff --git a/libbuild2/utility.hxx b/libbuild2/utility.hxx
index 536898e..1d5c7bb 100644
--- a/libbuild2/utility.hxx
+++ b/libbuild2/utility.hxx
@@ -97,15 +97,19 @@ namespace build2
// Initialize the diagnostics state. Should be called once early in main().
// Default values are for unit tests.
//
+ // If silent is true, verbosity should be 0.
+ //
LIBBUILD2_SYMEXPORT void
init_diag (uint16_t verbosity,
+ bool silent = false,
optional<bool> progress = nullopt,
bool no_lines = false,
bool no_columns = false,
bool stderr_term = false);
- LIBBUILD2_SYMEXPORT extern uint16_t verb;
const uint16_t verb_never = 7;
+ LIBBUILD2_SYMEXPORT extern uint16_t verb;
+ LIBBUILD2_SYMEXPORT extern bool silent;
// --[no-]progress
//