aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2017-08-05 20:50:30 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2017-08-06 13:19:00 +0300
commit1511d2d85e1a2142461af1b4cce4e47350fec7d0 (patch)
tree72ebd1fdd89b76bdd8108270913485633934da51
parent4ea8b31ec37dc1c11f1c80e558361951253f1c58 (diff)
Print progress to terminal by default
-rw-r--r--build2/b-options.cxx12
-rw-r--r--build2/b-options.hxx4
-rw-r--r--build2/b-options.ixx6
-rw-r--r--build2/b.cli10
-rw-r--r--build2/b.cxx7
-rw-r--r--build2/operation.cxx5
-rw-r--r--build2/utility.cxx1
-rw-r--r--build2/utility.hxx2
8 files changed, 40 insertions, 7 deletions
diff --git a/build2/b-options.cxx b/build2/b-options.cxx
index a2fa26a..5041cf3 100644
--- a/build2/b-options.cxx
+++ b/build2/b-options.cxx
@@ -572,6 +572,7 @@ namespace build2
: v_ (),
V_ (),
progress_ (),
+ no_progress_ (),
quiet_ (),
verbose_ (1),
verbose_specified_ (false),
@@ -677,9 +678,12 @@ namespace build2
<< " equivalent to \033[1m--verbose 3\033[0m." << ::std::endl;
os << std::endl
- << "\033[1m--progress\033[0m|\033[1m-p\033[0m Display build progress. Only usable when printing to a" << ::std::endl
- << " terminal but can be combined with various verbosity" << ::std::endl
- << " levels." << ::std::endl;
+ << "\033[1m--progress\033[0m|\033[1m-p\033[0m Display build progress. If printing to a terminal the" << ::std::endl
+ << " progress is displayed by default for low verbosity levels." << ::std::endl
+ << " Use \033[1m--no-progress\033[0m to suppress." << ::std::endl;
+
+ os << std::endl
+ << "\033[1m--no-progress\033[0m Don't display build progress." << ::std::endl;
os << std::endl
<< "\033[1m--quiet\033[0m|\033[1m-q\033[0m Run quietly, only printing error messages. This is" << ::std::endl
@@ -806,6 +810,8 @@ namespace build2
&::build2::cl::thunk< options, bool, &options::progress_ >;
_cli_options_map_["-p"] =
&::build2::cl::thunk< options, bool, &options::progress_ >;
+ _cli_options_map_["--no-progress"] =
+ &::build2::cl::thunk< options, bool, &options::no_progress_ >;
_cli_options_map_["--quiet"] =
&::build2::cl::thunk< options, bool, &options::quiet_ >;
_cli_options_map_["-q"] =
diff --git a/build2/b-options.hxx b/build2/b-options.hxx
index 6ae3cd9..535e70c 100644
--- a/build2/b-options.hxx
+++ b/build2/b-options.hxx
@@ -405,6 +405,9 @@ namespace build2
progress () const;
const bool&
+ no_progress () const;
+
+ const bool&
quiet () const;
const uint16_t&
@@ -501,6 +504,7 @@ namespace build2
bool v_;
bool V_;
bool progress_;
+ bool no_progress_;
bool quiet_;
uint16_t verbose_;
bool verbose_specified_;
diff --git a/build2/b-options.ixx b/build2/b-options.ixx
index af32a3d..1c99dc3 100644
--- a/build2/b-options.ixx
+++ b/build2/b-options.ixx
@@ -235,6 +235,12 @@ namespace build2
}
inline const bool& options::
+ no_progress () const
+ {
+ return this->no_progress_;
+ }
+
+ inline const bool& options::
quiet () const
{
return this->quiet_;
diff --git a/build2/b.cli b/build2/b.cli
index 0426844..46cf80a 100644
--- a/build2/b.cli
+++ b/build2/b.cli
@@ -335,8 +335,14 @@ namespace build2
bool --progress|-p
{
- "Display build progress. Only usable when printing to a terminal but
- can be combined with various verbosity levels."
+ "Display build progress. If printing to a terminal the progress is
+ displayed by default for low verbosity levels. Use \cb{--no-progress}
+ to suppress."
+ }
+
+ bool --no-progress
+ {
+ "Don't display build progress."
}
bool --quiet|-q
diff --git a/build2/b.cxx b/build2/b.cxx
index 1098da9..ef8b97b 100644
--- a/build2/b.cxx
+++ b/build2/b.cxx
@@ -14,6 +14,7 @@
#include <iostream> // cout
#include <libbutl/pager.hxx>
+#include <libbutl/fdstream.hxx> // stderr_fd(), fdterm()
#include <build2/types.hxx>
#include <build2/utility.hxx>
@@ -238,8 +239,14 @@ main (int argc, char* argv[])
fail << e;
}
+ // Validate options.
+ //
+ if (ops.progress () && ops.no_progress ())
+ fail << "inconsistent progress display options";
+
// Global initializations.
//
+ stderr_term = fdterm (stderr_fd ());
init (argv[0],
ops.verbose_specified ()
? ops.verbose ()
diff --git a/build2/operation.cxx b/build2/operation.cxx
index 60555b1..ca8382c 100644
--- a/build2/operation.cxx
+++ b/build2/operation.cxx
@@ -105,7 +105,8 @@ namespace build2
//
scheduler::monitor_guard mg;
string what;
- if (ops.progress ())
+ if (ops.progress () ||
+ (stderr_term && verb >= 1 && verb <= 2 && !ops.no_progress ()))
{
size_t init (target_count.load (memory_order_relaxed));
size_t incr (init > 100 ? 10 : 1);
@@ -251,7 +252,7 @@ namespace build2
//
scheduler::monitor_guard mg;
string what;
- if (ops.progress ())
+ if (ops.progress () || (stderr_term && verb == 1 && !ops.no_progress ()))
{
size_t init (target_count.load (memory_order_relaxed));
size_t incr (init / 100); // 1%.
diff --git a/build2/utility.cxx b/build2/utility.cxx
index f2d9155..b0325fb 100644
--- a/build2/utility.cxx
+++ b/build2/utility.cxx
@@ -110,6 +110,7 @@ namespace build2
options ops;
process_path argv0;
+ bool stderr_term;
const standard_version build_version (BUILD2_VERSION_STR);
diff --git a/build2/utility.hxx b/build2/utility.hxx
index bb0eb8e..f6f9fe9 100644
--- a/build2/utility.hxx
+++ b/build2/utility.hxx
@@ -96,6 +96,8 @@ namespace build2
next_word (const string&, size_t n, size_t& b, size_t& e,
char d1 = ' ', char d2 = '\0');
+ extern bool stderr_term; // True if stderr is a terminal.
+
// Command line options.
//
extern options ops;