aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2018-03-29 14:02:18 +0200
committerKaren Arutyunov <karen@codesynthesis.com>2018-04-19 19:39:55 +0300
commit4c7b3f9500c668aa99328e419f6d09c722814f97 (patch)
treed651e03898965e956dabbff72b184508d458b271
parent7251109c82b16c30410803ef375fe1012445873d (diff)
Improve pkg-checkout progress diagnostics at verbosity level 1
-rw-r--r--bpkg/bpkg.cxx2
-rw-r--r--bpkg/cfg-create.cxx2
-rw-r--r--bpkg/pkg-checkout.cxx19
-rw-r--r--bpkg/pkg-command.cxx2
-rw-r--r--bpkg/pkg-configure.cxx2
-rw-r--r--bpkg/pkg-disfigure.cxx2
-rw-r--r--bpkg/utility.cxx19
-rw-r--r--bpkg/utility.hxx15
-rw-r--r--tests/pkg-build.test8
-rw-r--r--tests/pkg-checkout.test4
10 files changed, 56 insertions, 19 deletions
diff --git a/bpkg/bpkg.cxx b/bpkg/bpkg.cxx
index ece9046..c82c92d 100644
--- a/bpkg/bpkg.cxx
+++ b/bpkg/bpkg.cxx
@@ -47,6 +47,7 @@
#include <bpkg/rep-remove.hxx>
using namespace std;
+using namespace butl;
using namespace bpkg;
// Get -d|--directory value if the option class O has it and empty path
@@ -139,6 +140,7 @@ try
{
using namespace cli;
+ stderr_term = fdterm (stderr_fd ());
exec_dir = path (argv[0]).directory ();
// This is a little hack to make our baseutils for Windows work when called
diff --git a/bpkg/cfg-create.cxx b/bpkg/cfg-create.cxx
index 9b56cad..b62163e 100644
--- a/bpkg/cfg-create.cxx
+++ b/bpkg/cfg-create.cxx
@@ -77,7 +77,7 @@ namespace bpkg
run_b (o,
c,
"create('" + c.representation () + "'" + mods + ")",
- true,
+ verb_b::quiet,
vars);
// Create .bpkg/ and its subdirectories.
diff --git a/bpkg/pkg-checkout.cxx b/bpkg/pkg-checkout.cxx
index c53e545..faa1099 100644
--- a/bpkg/pkg-checkout.cxx
+++ b/bpkg/pkg-checkout.cxx
@@ -156,18 +156,27 @@ namespace bpkg
// Distribute.
//
- // Note that on failure the package stays in the existing (working) state.
+ // Note that on failure the package stays in the existing (working)
+ // state.
//
// At first it may seem we have a problem: an existing package with the
// same name will cause a conflict since we now have multiple package
- // locations for the same package name. We are luck, however: subprojects
- // are only loaded if used and since we don't support dependency cycles,
- // the existing project should never be loaded by any of our dependencies.
+ // locations for the same package name. We are lucky, however:
+ // subprojects are only loaded if used and since we don't support
+ // dependency cycles, the existing project should never be loaded by any
+ // of our dependencies.
//
+
+ // At verbosity level 1 we want our (nicer) progress header but the
+ // build system's actual progress.
+ //
+ if (verb == 1)
+ text << "distributing " << n << '/' << v;
+
run_b (o,
c,
bspec,
- false /* quiet */,
+ verb_b::progress,
strings ({"config.dist.root=" + c.representation ()}));
mc = sha256 (o, d / manifest_file);
diff --git a/bpkg/pkg-command.cxx b/bpkg/pkg-command.cxx
index a4260a8..4475ea7 100644
--- a/bpkg/pkg-command.cxx
+++ b/bpkg/pkg-command.cxx
@@ -39,7 +39,7 @@ namespace bpkg
{
bspec += ')';
l4 ([&]{trace << "buildspec: " << bspec;});
- run_b (o, c, bspec, false, vars, cvars);
+ run_b (o, c, bspec, verb_b::normal, vars, cvars);
bspec.clear ();
}
};
diff --git a/bpkg/pkg-configure.cxx b/bpkg/pkg-configure.cxx
index a7e1a17..7aa4183 100644
--- a/bpkg/pkg-configure.cxx
+++ b/bpkg/pkg-configure.cxx
@@ -162,7 +162,7 @@ namespace bpkg
//
try
{
- run_b (o, c, bspec, true, vars); // Run quiet.
+ run_b (o, c, bspec, verb_b::quiet, vars);
}
catch (const failed&)
{
diff --git a/bpkg/pkg-disfigure.cxx b/bpkg/pkg-disfigure.cxx
index 0e1f8a6..4a0bd72 100644
--- a/bpkg/pkg-disfigure.cxx
+++ b/bpkg/pkg-disfigure.cxx
@@ -126,7 +126,7 @@ namespace bpkg
if (clean && p->external ())
rm_r (out_root);
else
- run_b (o, c, bspec, true); // Run quiet.
+ run_b (o, c, bspec, verb_b::quiet);
}
// Make sure the out directory is gone unless it is the same as src,
diff --git a/bpkg/utility.cxx b/bpkg/utility.cxx
index 652cd46..f48d96d 100644
--- a/bpkg/utility.cxx
+++ b/bpkg/utility.cxx
@@ -82,6 +82,8 @@ namespace bpkg
}
}
+ bool stderr_term;
+
bool
yn_prompt (const char* prompt, char def)
{
@@ -323,7 +325,7 @@ namespace bpkg
run_b (const common_options& co,
const dir_path& c,
const string& bspec,
- bool quiet,
+ verb_b v,
const strings& pvars,
const strings& cvars)
{
@@ -334,11 +336,22 @@ namespace bpkg
// as us.
//
string vl;
- if (verb <= (quiet ? 1 : 0))
+
+ if (verb == 0)
args.push_back ("-q");
+ else if (verb == 1)
+ {
+ if (v != verb_b::normal)
+ {
+ args.push_back ("-q");
+
+ if (v == verb_b::progress && stderr_term)
+ args.push_back ("--progress");
+ }
+ }
else if (verb == 2)
args.push_back ("-v");
- else if (verb > 2)
+ else
{
vl = to_string (verb);
args.push_back ("--verbose");
diff --git a/bpkg/utility.hxx b/bpkg/utility.hxx
index 5c370ef..c347bda 100644
--- a/bpkg/utility.hxx
+++ b/bpkg/utility.hxx
@@ -79,6 +79,10 @@ namespace bpkg
void
clean_tmp (bool ignore_errors);
+ // Progress.
+ //
+ extern bool stderr_term; // True if stderr is a terminal.
+
// Y/N prompt. The def argument, if specified, should be either 'y'
// or 'n'. It is used as the default answer, in case the user just
// hits enter. Issue diagnostics and throw failed if no answer could
@@ -157,11 +161,20 @@ namespace bpkg
const char*
name_b (const common_options&);
+ // Verbosity level 1 mapping.
+ //
+ enum class verb_b
+ {
+ quiet, // Run quiet.
+ progress, // Run quiet but (potentially) with progress.
+ normal // Run normally (at verbosity 1).
+ };
+
void
run_b (const common_options&,
const dir_path& configuration,
const string& buildspec,
- bool quiet = false,
+ verb_b = verb_b::normal,
const strings& pvars = strings (),
const strings& cvars = strings ());
}
diff --git a/tests/pkg-build.test b/tests/pkg-build.test
index 4b0c57b..8b114cd 100644
--- a/tests/pkg-build.test
+++ b/tests/pkg-build.test
@@ -1859,10 +1859,10 @@ else
$rep_fetch &cfg/.bpkg/repos/*/***;
$* libmbar 2>>~%EOE%;
- %dist style-basic-.+%
+ %distributing style-basic/.+%
%checked out style-basic/.+%
%configured style-basic/.+%
- dist libmbar-1.0.0
+ distributing libmbar/1.0.0
checked out libmbar/1.0.0
configured libmbar/1.0.0
%info: .+dir\{libmbar-.+\} is up to date%
@@ -1889,10 +1889,10 @@ else
$rep_fetch &cfg/.bpkg/repos/*/***;
$* libbaz 2>>~%EOE%;
- %dist style-basic-.+%
+ %distributing style-basic/.+%
%checked out style-basic/.+%
%configured style-basic/.+%
- dist libbaz-1.0.0
+ distributing libbaz/1.0.0
checked out libbaz/1.0.0
configured libbaz/1.0.0
%info: .+dir\{libbaz-.+\} is up to date%
diff --git a/tests/pkg-checkout.test b/tests/pkg-checkout.test
index 46f8841..81aeba1 100644
--- a/tests/pkg-checkout.test
+++ b/tests/pkg-checkout.test
@@ -60,14 +60,14 @@ else
$pkg_status style-basic | sed -n -e 's/style-basic available \[.+\] ([^ ]+)/\1/p' | set v;
$* "style-basic/$v" 2>>"EOE";
- dist style-basic-$v
+ distributing style-basic/$v
checked out style-basic/$v
EOE
$pkg_configure style-basic;
$* libmbar/1.0.0 2>>EOE;
- dist libmbar-1.0.0
+ distributing libmbar/1.0.0
checked out libmbar/1.0.0
EOE