aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build/algorithm.cxx6
-rw-r--r--build/b.cxx36
-rw-r--r--build/bin/module.cxx2
-rw-r--r--build/buildfile2
-rw-r--r--build/cli/module.cxx8
-rw-r--r--build/cli/rule.cxx12
-rw-r--r--build/config/module.cxx2
-rw-r--r--build/config/operation.cxx16
-rw-r--r--build/context.cxx21
-rw-r--r--build/context.txx18
-rw-r--r--build/cxx/compile.cxx24
-rw-r--r--build/cxx/link.cxx8
-rw-r--r--build/cxx/module.cxx8
-rw-r--r--build/diagnostics20
-rw-r--r--build/diagnostics.cxx2
-rw-r--r--build/dist/module.cxx2
-rw-r--r--build/dist/operation.cxx18
-rw-r--r--build/file.cxx20
-rw-r--r--build/install/module.cxx2
-rw-r--r--build/install/rule.cxx8
-rw-r--r--build/operation.cxx8
-rw-r--r--build/options12
-rw-r--r--build/options.cli15
-rw-r--r--build/options.cxx66
-rw-r--r--build/options.ixx12
-rw-r--r--build/parser.cxx14
-rw-r--r--build/prerequisite.cxx2
-rw-r--r--build/rule.cxx6
-rw-r--r--build/search.cxx12
-rw-r--r--build/target.cxx2
-rw-r--r--build/test/module.cxx2
-rw-r--r--build/test/rule.cxx4
32 files changed, 234 insertions, 156 deletions
diff --git a/build/algorithm.cxx b/build/algorithm.cxx
index 9a2f9fb..fb6c72a 100644
--- a/build/algorithm.cxx
+++ b/build/algorithm.cxx
@@ -234,8 +234,8 @@ namespace build
diag_record dr;
dr << fail << "no rule to " << diag_do (a, t);
- if (verb < 3)
- dr << info << "re-run with --verbose 3 for more information";
+ if (verb < 4)
+ dr << info << "re-run with --verbose 4 for more information";
return r;
}
@@ -333,7 +333,7 @@ namespace build
if (!d.sub (out_root) || d == out_root)
return;
- level5 ([&]{trace << "for " << t;});
+ level6 ([&]{trace << "for " << t;});
fsdir& dt (search<fsdir> (d, string (), nullptr, &s));
match (a, dt);
diff --git a/build/b.cxx b/build/b.cxx
index 2264c62..bbfc635 100644
--- a/build/b.cxx
+++ b/build/b.cxx
@@ -84,9 +84,11 @@ main (int argc, char* argv[])
return 0;
}
- // Trace verbosity.
+ // Diagnostics verbosity.
//
- verb = ops.verbose () > 0 ? ops.verbose () : (ops.v () ? 1 : 0);
+ verb = ops.verbose_specified ()
+ ? ops.verbose ()
+ : ops.v () ? 2 : ops.q () ? 0 : 1;
// Initialize time conversion data that is used by localtime_r().
//
@@ -121,7 +123,7 @@ main (int argc, char* argv[])
home = dir_path (pw->pw_dir);
}
- if (verb >= 4)
+ if (verb >= 5)
{
trace << "work dir: " << work;
trace << "home dir: " << home;
@@ -198,7 +200,7 @@ main (int argc, char* argv[])
}
}
- level4 ([&]{trace << "buildspec: " << bspec;});
+ level5 ([&]{trace << "buildspec: " << bspec;});
if (bspec.empty ())
bspec.push_back (metaopspec ()); // Default meta-operation.
@@ -244,7 +246,7 @@ main (int argc, char* argv[])
if (mif->meta_operation_post != nullptr)
mif->meta_operation_post ();
- level4 ([&]{trace << "end meta-operation batch " << mif->name
+ level5 ([&]{trace << "end meta-operation batch " << mif->name
<< ", id " << static_cast<uint16_t> (mid);});
mid = 0;
@@ -532,7 +534,7 @@ main (int argc, char* argv[])
if (mif->meta_operation_post != nullptr)
mif->meta_operation_post ();
- level4 ([&]{trace << "end meta-operation batch "
+ level5 ([&]{trace << "end meta-operation batch "
<< mif->name << ", id "
<< static_cast<uint16_t> (mid);});
@@ -598,7 +600,7 @@ main (int argc, char* argv[])
fail (l) << "target " << tn << " does not support meta-"
<< "operation " << meta_operation_table[m];
- level4 ([&]{trace << "start meta-operation batch " << mif->name
+ level5 ([&]{trace << "start meta-operation batch " << mif->name
<< ", id " << static_cast<uint16_t> (mid);});
if (mif->meta_operation_pre != nullptr)
@@ -644,7 +646,7 @@ main (int argc, char* argv[])
oif = lookup (o);
- level4 ([&]{trace << "start operation batch " << oif->name
+ level5 ([&]{trace << "start operation batch " << oif->name
<< ", id " << static_cast<uint16_t> (o);});
// Allow the meta-operation to translate the operation.
@@ -657,7 +659,7 @@ main (int argc, char* argv[])
if (o != oid)
{
oif = lookup (oid);
- level4 ([&]{trace << "operation translated to " << oif->name
+ level5 ([&]{trace << "operation translated to " << oif->name
<< ", id " << static_cast<uint16_t> (oid);});
}
@@ -705,7 +707,7 @@ main (int argc, char* argv[])
}
}
- if (verb >= 4)
+ if (verb >= 5)
{
trace << "target " << tn << ':';
trace << " out_base: " << out_base;
@@ -757,7 +759,7 @@ main (int argc, char* argv[])
if (pre_oid != 0)
{
- level4 ([&]{trace << "start pre-operation batch " << pre_oif->name
+ level5 ([&]{trace << "start pre-operation batch " << pre_oif->name
<< ", id " << static_cast<uint16_t> (pre_oid);});
if (mif->operation_pre != nullptr)
@@ -776,7 +778,7 @@ main (int argc, char* argv[])
if (mif->operation_post != nullptr)
mif->operation_post (pre_oid);
- level4 ([&]{trace << "end pre-operation batch " << pre_oif->name
+ level5 ([&]{trace << "end pre-operation batch " << pre_oif->name
<< ", id " << static_cast<uint16_t> (pre_oid);});
}
@@ -788,11 +790,11 @@ main (int argc, char* argv[])
action a (mid, oid, 0);
mif->match (a, tgs);
- mif->execute (a, tgs, false);
+ mif->execute (a, tgs, verb == 0);
if (post_oid != 0)
{
- level4 ([&]{trace << "start post-operation batch " << post_oif->name
+ level5 ([&]{trace << "start post-operation batch " << post_oif->name
<< ", id " << static_cast<uint16_t> (post_oid);});
if (mif->operation_pre != nullptr)
@@ -811,21 +813,21 @@ main (int argc, char* argv[])
if (mif->operation_post != nullptr)
mif->operation_post (post_oid);
- level4 ([&]{trace << "end post-operation batch " << post_oif->name
+ level5 ([&]{trace << "end post-operation batch " << post_oif->name
<< ", id " << static_cast<uint16_t> (post_oid);});
}
if (mif->operation_post != nullptr)
mif->operation_post (oid);
- level4 ([&]{trace << "end operation batch " << oif->name
+ level5 ([&]{trace << "end operation batch " << oif->name
<< ", id " << static_cast<uint16_t> (oid);});
}
if (mif->meta_operation_post != nullptr)
mif->meta_operation_post ();
- level4 ([&]{trace << "end meta-operation batch " << mif->name
+ level5 ([&]{trace << "end meta-operation batch " << mif->name
<< ", id " << static_cast<uint16_t> (mid);});
}
}
diff --git a/build/bin/module.cxx b/build/bin/module.cxx
index ba10181..25700c6 100644
--- a/build/bin/module.cxx
+++ b/build/bin/module.cxx
@@ -37,7 +37,7 @@ namespace build
bool first)
{
tracer trace ("bin::init");
- level4 ([&]{trace << "for " << b.out_path ();});
+ level5 ([&]{trace << "for " << b.out_path ();});
// Register target types.
//
diff --git a/build/buildfile b/build/buildfile
index a9fcc49..f4320d4 100644
--- a/build/buildfile
+++ b/build/buildfile
@@ -19,4 +19,4 @@ exe{b}: cxx{b algorithm name operation spec scope variable target \
#@@ TODO
#
-# cli --cli-namespace cl --include-with-brackets --include-prefix build --guard-prefix BUILD --hxx-suffix "" options.cli
+# cli --generate-specifier --cli-namespace cl --include-with-brackets --include-prefix build --guard-prefix BUILD --hxx-suffix "" options.cli
diff --git a/build/cli/module.cxx b/build/cli/module.cxx
index f8d1522..240aaa7 100644
--- a/build/cli/module.cxx
+++ b/build/cli/module.cxx
@@ -36,7 +36,7 @@ namespace build
bool first)
{
tracer trace ("cli::init");
- level4 ([&]{trace << "for " << base.out_path ();});
+ level5 ([&]{trace << "for " << base.out_path ();});
// Make sure the cxx module has been loaded since we need its
// targets types (?xx{}). Note that we don't try to load it
@@ -104,9 +104,9 @@ namespace build
const string& cli (as<string> (p.first));
const char* args[] = {cli.c_str (), "--version", nullptr};
- if (verb)
+ if (verb >= 2)
print_process (args);
- else
+ else if (verb)
text << "test " << cli;
string ver;
@@ -141,7 +141,7 @@ namespace build
throw failed ();
}
- if (verb)
+ if (verb >= 2)
text << cli << " " << ver;
}
}
diff --git a/build/cli/rule.cxx b/build/cli/rule.cxx
index 8b0ba85..ef3b1dc 100644
--- a/build/cli/rule.cxx
+++ b/build/cli/rule.cxx
@@ -46,7 +46,7 @@ namespace build
//
if (t.name != p.name ())
{
- level3 ([&]{trace << ".cli file stem '" << p.name () << "' "
+ level4 ([&]{trace << ".cli file stem '" << p.name () << "' "
<< "doesn't match target " << t;});
return r;
}
@@ -58,7 +58,7 @@ namespace build
if (!r)
{
- level3 ([&]{trace << "no .cli source file for target " << t;});
+ level4 ([&]{trace << "no .cli source file for target " << t;});
return r;
}
@@ -117,7 +117,7 @@ namespace build
g->prerequisites.emplace_back (p.as_prerequisite (trace));
}
else
- level3 ([&]{trace << ".cli file stem '" << p.name () << "' "
+ level4 ([&]{trace << ".cli file stem '" << p.name () << "' "
<< "doesn't match target " << t;});
break;
}
@@ -135,7 +135,7 @@ namespace build
//
if (t.is_a<cxx::ixx> () && g->i == nullptr)
{
- level3 ([&]{trace << "generation of inline file " << t
+ level4 ([&]{trace << "generation of inline file " << t
<< " is disabled with --suppress-inline";});
g = nullptr;
}
@@ -245,9 +245,9 @@ namespace build
args.push_back (rels.string ().c_str ());
args.push_back (nullptr);
- if (verb)
+ if (verb >= 2)
print_process (args);
- else
+ else if (verb)
text << "cli " << *s;
try
diff --git a/build/config/module.cxx b/build/config/module.cxx
index 74bcec4..bb787a0 100644
--- a/build/config/module.cxx
+++ b/build/config/module.cxx
@@ -43,7 +43,7 @@ namespace build
}
const dir_path& out_root (r.out_path ());
- level4 ([&]{trace << "for " << out_root;});
+ level5 ([&]{trace << "for " << out_root;});
// Register meta-operations.
//
diff --git a/build/config/operation.cxx b/build/config/operation.cxx
index 424fd46..9d7c9b3 100644
--- a/build/config/operation.cxx
+++ b/build/config/operation.cxx
@@ -40,7 +40,8 @@ namespace build
{
path f (out_root / src_root_file);
- text << (verb ? "config::save_src_root " : "save ") << f;
+ if (verb)
+ text << (verb >= 2 ? "config::save_src_root " : "save ") << f;
try
{
@@ -68,7 +69,8 @@ namespace build
const dir_path& out_root (root.out_path ());
path f (out_root / config_file);
- text << (verb ? "config::save_config " : "save ") << f;
+ if (verb)
+ text << (verb >= 2 ? "config::save_config " : "save ") << f;
try
{
@@ -151,7 +153,7 @@ namespace build
//
if (a.operation () == default_id)
{
- level4 ([&]{trace << "completely configuring " << out_root;});
+ level5 ([&]{trace << "completely configuring " << out_root;});
// Save src-root.build unless out_root is the same as src.
//
@@ -263,7 +265,7 @@ namespace build
const location&)
{
tracer trace ("disfigure_load");
- level5 ([&]{trace << "skipping " << bf;});
+ level6 ([&]{trace << "skipping " << bf;});
}
static void
@@ -273,7 +275,7 @@ namespace build
action_targets& ts)
{
tracer trace ("disfigure_search");
- level5 ([&]{trace << "collecting " << root.out_path ();});
+ level6 ([&]{trace << "collecting " << root.out_path ();});
ts.push_back (&root);
}
@@ -345,7 +347,7 @@ namespace build
//
if (a.operation () == default_id)
{
- level4 ([&]{trace << "completely disfiguring " << out_root;});
+ level5 ([&]{trace << "completely disfiguring " << out_root;});
m = rmfile (out_root / config_file) || m;
@@ -414,7 +416,7 @@ namespace build
// Reset the dependency state since anything that could have been
// loaded earlier using a previous configuration is now invalid.
//
- level5 ([&]{trace << "resetting dependency state";});
+ level6 ([&]{trace << "resetting dependency state";});
reset ();
}
diff --git a/build/context.cxx b/build/context.cxx
index fa1ea8f..5a801b0 100644
--- a/build/context.cxx
+++ b/build/context.cxx
@@ -126,12 +126,17 @@ namespace build
}
catch (const system_error& e)
{
- text << "mkdir " << d;
+ if (verb)
+ text << "mkdir " << d;
+
fail << "unable to create directory " << d << ": " << e.what ();
}
if (ms == mkdir_status::success)
- text << "mkdir " << d;
+ {
+ if (verb)
+ text << "mkdir " << d;
+ }
return ms;
}
@@ -150,12 +155,17 @@ namespace build
}
catch (const system_error& e)
{
- text << "mkdir -p " << d;
+ if (verb)
+ text << "mkdir -p " << d;
+
fail << "unable to create directory " << d << ": " << e.what ();
}
if (ms == mkdir_status::success)
- text << "mkdir -p " << d;
+ {
+ if (verb)
+ text << "mkdir -p " << d;
+ }
return ms;
}
@@ -171,7 +181,8 @@ namespace build
if (!dir_exists (d))
return rmdir_status::not_exist;
- text << "rmdir -r " << d;
+ if (verb)
+ text << "rmdir -r " << d;
try
{
diff --git a/build/context.txx b/build/context.txx
index eb1568c..a0660f9 100644
--- a/build/context.txx
+++ b/build/context.txx
@@ -27,9 +27,9 @@ namespace build
}
catch (const std::system_error& e)
{
- if (verb)
+ if (verb >= 2)
text << "rm " << f;
- else
+ else if (verb)
text << "rm " << t;
fail << "unable to remove file " << f << ": " << e.what ();
@@ -37,9 +37,9 @@ namespace build
if (rs == rmfile_status::success)
{
- if (verb)
+ if (verb >= 2)
text << "rm " << f;
- else
+ else if (verb)
text << "rm " << t;
}
@@ -66,9 +66,9 @@ namespace build
}
catch (const std::system_error& e)
{
- if (verb)
+ if (verb >= 2)
text << "rmdir " << d;
- else
+ else if (verb)
text << "rmdir " << t;
fail << "unable to remove directory " << d << ": " << e.what ();
@@ -78,16 +78,16 @@ namespace build
{
case rmdir_status::success:
{
- if (verb)
+ if (verb >= 2)
text << "rmdir " << d;
- else
+ else if (verb)
text << "rmdir " << t;
break;
}
case rmdir_status::not_empty:
{
- if (verb)
+ if (verb >= 2)
text << "directory " << d << " is "
<< (w ? "current working directory" : "not empty")
<< ", not removing";
diff --git a/build/cxx/compile.cxx b/build/cxx/compile.cxx
index 9a3e3d7..d986cac 100644
--- a/build/cxx/compile.cxx
+++ b/build/cxx/compile.cxx
@@ -58,7 +58,7 @@ namespace build
return p;
}
- level3 ([&]{trace << "no c++ source file for target " << t;});
+ level4 ([&]{trace << "no c++ source file for target " << t;});
return nullptr;
}
@@ -236,7 +236,7 @@ namespace build
else
continue;
- level5 ([&]{trace << "-I '" << d << "'";});
+ level6 ([&]{trace << "-I '" << d << "'";});
// If we are relative or not inside our project root, then
// ignore.
@@ -268,7 +268,7 @@ namespace build
// be reasonably expected to work according to the order
// of the -I options.
//
- if (verb >= 3)
+ if (verb >= 4)
trace << "overriding dependency prefix '" << p << "'\n"
<< " old mapping to " << j->second << "\n"
<< " new mapping to " << d;
@@ -278,7 +278,7 @@ namespace build
}
else
{
- level5 ([&]{trace << "'" << p << "' = '" << d << "'";});
+ level6 ([&]{trace << "'" << p << "' = '" << d << "'";});
m.emplace (move (p), move (d));
}
}
@@ -418,7 +418,7 @@ namespace build
args.push_back (s.path ().string ().c_str ());
args.push_back (nullptr);
- level5 ([&]{trace << "target: " << t;});
+ level6 ([&]{trace << "target: " << t;});
// Build the prefix map lazily only if we have non-existent files.
// Also reuse it over restarts since it doesn't change.
@@ -461,7 +461,7 @@ namespace build
{
restart = false;
- if (verb >= 2)
+ if (verb >= 3)
print_process (args);
try
@@ -539,9 +539,9 @@ namespace build
if (!f.absolute ())
{
// This is probably as often an error as an auto-generated
- // file, so trace at level 3.
+ // file, so trace at level 4.
//
- level3 ([&]{trace << "non-existent header '" << f << "'";});
+ level4 ([&]{trace << "non-existent header '" << f << "'";});
// If we already did it and build_prefix_map() returned empty,
// then we would have failed below.
@@ -582,7 +582,7 @@ namespace build
f = i->second / f;
}
- level5 ([&]{trace << "injecting " << f;});
+ level6 ([&]{trace << "injecting " << f;});
// Split the name into its directory part, the name part, and
// extension. Here we can assume the name part is a valid
@@ -667,7 +667,7 @@ namespace build
if (ns != os && ns != target_state::unchanged)
{
- level5 ([&]{trace << "updated " << pt << ", restarting";});
+ level6 ([&]{trace << "updated " << pt << ", restarting";});
restart = true;
}
}
@@ -754,9 +754,9 @@ namespace build
args.push_back (nullptr);
- if (verb)
+ if (verb >= 2)
print_process (args);
- else
+ else if (verb)
text << "c++ " << *s;
try
diff --git a/build/cxx/link.cxx b/build/cxx/link.cxx
index 2554930..6742ff2 100644
--- a/build/cxx/link.cxx
+++ b/build/cxx/link.cxx
@@ -113,7 +113,7 @@ namespace build
args.push_back ("-print-search-dirs");
args.push_back (nullptr);
- if (verb >= 5)
+ if (verb >= 3)
print_process (args);
string l;
@@ -399,7 +399,7 @@ namespace build
//
if (seen_c && !seen_cxx && hint < "cxx")
{
- level3 ([&]{trace << "c prerequisite(s) without c++ or hint";});
+ level4 ([&]{trace << "c prerequisite(s) without c++ or hint";});
return nullptr;
}
@@ -807,9 +807,9 @@ namespace build
args.push_back (nullptr);
- if (verb)
+ if (verb >= 2)
print_process (args);
- else
+ else if (verb)
text << "ld " << t;
try
diff --git a/build/cxx/module.cxx b/build/cxx/module.cxx
index 6b7da80..eda3593 100644
--- a/build/cxx/module.cxx
+++ b/build/cxx/module.cxx
@@ -35,7 +35,7 @@ namespace build
bool first)
{
tracer trace ("cxx::init");
- level4 ([&]{trace << "for " << b.out_path ();});
+ level5 ([&]{trace << "for " << b.out_path ();});
// Initialize the bin module. Only do this if it hasn't already
// been loaded so that we don't overwrite user's bin.* settings.
@@ -148,9 +148,9 @@ namespace build
const string& cxx (as<string> (p.first));
const char* args[] = {cxx.c_str (), "-dumpversion", nullptr};
- if (verb)
+ if (verb >= 2)
print_process (args);
- else
+ else if (verb)
text << "test " << cxx;
string ver;
@@ -177,7 +177,7 @@ namespace build
throw failed ();
}
- if (verb)
+ if (verb >= 2)
text << cxx << " " << ver;
}
}
diff --git a/build/diagnostics b/build/diagnostics
index ab4c4a2..6e54f56 100644
--- a/build/diagnostics
+++ b/build/diagnostics
@@ -94,14 +94,15 @@ namespace build
print_process (args.data (), args.size ());
}
- // Trace verbosity level.
+ // Verbosity level.
//
- // 0 - tracing disabled.
- // 1 - command lines to update explicit targets (e.g., .o)
- // 2 - command lines to update implicit targets (e.g., .d)
- // 3 - things didn't work out (e.g., rule did not match)
- // 4 - additional information
- // 5 - more additional information
+ // 0 - disabled
+ // 1 - high-level information messages
+ // 2 - essential underlying commands that are being executed
+ // 3 - all underlying commands that are being executed
+ // 4 - information helpful to the user (e.g., why a rule did not match)
+ // 5 - information helpful to the developer
+ // 6 - even more detailed information
//
// While uint8 is more than enough, use uint16 for the ease of printing.
//
@@ -112,6 +113,7 @@ namespace build
template <typename F> inline void level3 (const F& f) {if (verb >= 3) f ();}
template <typename F> inline void level4 (const F& f) {if (verb >= 4) f ();}
template <typename F> inline void level5 (const F& f) {if (verb >= 5) f ();}
+ template <typename F> inline void level6 (const F& f) {if (verb >= 6) f ();}
// Diagnostic facility, base infrastructure (potentially reusable).
//
@@ -315,7 +317,7 @@ namespace build
// Here is the absolute/relative path rationale: we want it absolute
// in the error/warning/info streams to give the user the complete
// picture. But in the text stream (e.g., command lines), we print
- // relative unless verbosity is greater than 0.
+ // relative unless verbosity is greater than 1.
//
struct basic_mark_base
{
@@ -364,7 +366,7 @@ namespace build
simple_prologue
operator() () const
{
- return simple_prologue (type_, name_, verb == 0);
+ return simple_prologue (type_, name_, verb <= 1);
}
};
typedef diag_mark<text_mark_base> text_mark;
diff --git a/build/diagnostics.cxx b/build/diagnostics.cxx
index 2f9525b..075dbab 100644
--- a/build/diagnostics.cxx
+++ b/build/diagnostics.cxx
@@ -203,7 +203,7 @@ namespace build
} while (*p != nullptr);
}
- // Trace verbosity level.
+ // Diagnostics verbosity level.
//
uint16_t verb;
diff --git a/build/dist/module.cxx b/build/dist/module.cxx
index 48c1fd0..0b60fa8 100644
--- a/build/dist/module.cxx
+++ b/build/dist/module.cxx
@@ -41,7 +41,7 @@ namespace build
}
const dir_path& out_root (r.out_path ());
- level4 ([&]{trace << "for " << out_root;});
+ level5 ([&]{trace << "for " << out_root;});
// Register meta-operation.
//
diff --git a/build/dist/operation.cxx b/build/dist/operation.cxx
index c4d022b..3928759 100644
--- a/build/dist/operation.cxx
+++ b/build/dist/operation.cxx
@@ -132,7 +132,7 @@ namespace build
action a (dist_id, id);
- if (verb >= 5)
+ if (verb >= 6)
dump (a);
for (void* v: ts)
@@ -142,12 +142,12 @@ namespace build
if (rs != t.base_scope ().root_scope ())
fail << "out of project target " << t;
- level4 ([&]{trace << diag_doing (a, t);});
+ level5 ([&]{trace << diag_doing (a, t);});
match (a, t);
}
- if (verb >= 5)
+ if (verb >= 6)
dump (a);
}
@@ -283,9 +283,9 @@ namespace build
args.push_back (reld.string ().c_str ());
args.push_back (nullptr);
- if (verb)
+ if (verb >= 2)
print_process (args);
- else
+ else if (verb)
text << "dist -d " << d;
try
@@ -337,9 +337,9 @@ namespace build
args.push_back (reld.string ().c_str ());
args.push_back (nullptr);
- if (verb)
+ if (verb >= 2)
print_process (args);
- else
+ else if (verb)
text << "dist " << t;
try
@@ -380,9 +380,9 @@ namespace build
else
args = {"tar", "-a", "-cf", a.c_str (), pkg.c_str (), nullptr};
- if (verb)
+ if (verb >= 2)
print_process (args);
- else
+ else if (verb)
text << args[0] << " " << ap;
try
diff --git a/build/file.cxx b/build/file.cxx
index 435746c..f8f62f9 100644
--- a/build/file.cxx
+++ b/build/file.cxx
@@ -83,7 +83,7 @@ namespace build
if (!ifs.is_open ())
fail << "unable to open " << bf;
- level4 ([&]{trace << "sourcing " << bf;});
+ level5 ([&]{trace << "sourcing " << bf;});
ifs.exceptions (ifstream::failbit | ifstream::badbit);
parser p;
@@ -105,7 +105,7 @@ namespace build
if (!once.buildfiles.insert (bf).second)
{
- level4 ([&]{trace << "skipping already sourced " << bf;});
+ level5 ([&]{trace << "skipping already sourced " << bf;});
return;
}
@@ -327,7 +327,7 @@ namespace build
{
src_root_v = extract_variable (f, "src_root");
src_root = &as<dir_path> (src_root_v);
- level4 ([&]{trace << "extracted src_root " << *src_root << " for "
+ level5 ([&]{trace << "extracted src_root " << *src_root << " for "
<< out_root;});
}
}
@@ -338,7 +338,7 @@ namespace build
name = move (as<string> (v));
}
- level4 ([&]{trace << "extracted project name " << name << " for "
+ level5 ([&]{trace << "extracted project name " << name << " for "
<< *src_root;});
return name;
}
@@ -372,7 +372,7 @@ namespace build
// Calculate relative subdirectory for this subproject.
//
dir_path dir (sd.leaf (root));
- level4 ([&]{trace << "subproject " << sd << " as " << dir;});
+ level5 ([&]{trace << "subproject " << sd << " as " << dir;});
// Load its name. Note that here we don't use fallback src_root
// since this function is used to scan both out_root and src_root.
@@ -395,7 +395,7 @@ namespace build
info << "first alternative: " << dir1 <<
info << "second alternative: " << dir;
- level5 ([&]{trace << "skipping duplicate";});
+ level6 ([&]{trace << "skipping duplicate";});
}
}
}
@@ -472,7 +472,7 @@ namespace build
{
// Otherwise, use the outer root as our amalgamation.
//
- level4 ([&]{trace << out_root << " amalgamated as " << rd;});
+ level5 ([&]{trace << out_root << " amalgamated as " << rd;});
v = move (rd);
}
}
@@ -488,7 +488,7 @@ namespace build
if (!ad.empty ())
{
dir_path rd (ad.relative (out_root));
- level4 ([&]{trace << out_root << " amalgamated as " << rd;});
+ level5 ([&]{trace << out_root << " amalgamated as " << rd;});
v = move (rd);
}
}
@@ -795,7 +795,7 @@ namespace build
// a stab at it.
//
target.proj = &project;
- level4 ([&]{trace << "postponing " << target;});
+ level5 ([&]{trace << "postponing " << target;});
return names {move (target)};
}
}
@@ -872,7 +872,7 @@ namespace build
if (!ifs.is_open ())
fail (loc) << "unable to open " << es;
- level4 ([&]{trace << "importing " << es;});
+ level5 ([&]{trace << "importing " << es;});
ifs.exceptions (ifstream::failbit | ifstream::badbit);
parser p;
diff --git a/build/install/module.cxx b/build/install/module.cxx
index 454ff3e..b117e98 100644
--- a/build/install/module.cxx
+++ b/build/install/module.cxx
@@ -110,7 +110,7 @@ namespace build
}
const dir_path& out_root (r.out_path ());
- level4 ([&]{trace << "for " << out_root;});
+ level5 ([&]{trace << "for " << out_root;});
// Register the install operation.
//
diff --git a/build/install/rule.cxx b/build/install/rule.cxx
index b1627be..64df3eb 100644
--- a/build/install/rule.cxx
+++ b/build/install/rule.cxx
@@ -178,9 +178,9 @@ namespace build
args.push_back (reld.string ().c_str ());
args.push_back (nullptr);
- if (verb)
+ if (verb >= 2)
print_process (args);
- else
+ else if (verb)
text << "install " << d;
try
@@ -220,9 +220,9 @@ namespace build
args.push_back (reld.string ().c_str ());
args.push_back (nullptr);
- if (verb)
+ if (verb >= 2)
print_process (args);
- else
+ else if (verb)
text << "install " << t;
try
diff --git a/build/operation.cxx b/build/operation.cxx
index 9cc8025..b92479b 100644
--- a/build/operation.cxx
+++ b/build/operation.cxx
@@ -93,17 +93,17 @@ namespace build
{
tracer trace ("match");
- if (verb >= 5)
+ if (verb >= 6)
dump (a);
for (void* vt: ts)
{
target& t (*static_cast<target*> (vt));
- level4 ([&]{trace << "matching " << t;});
+ level5 ([&]{trace << "matching " << t;});
match (a, t);
}
- if (verb >= 5)
+ if (verb >= 6)
dump (a);
}
@@ -122,7 +122,7 @@ namespace build
{
target& t (*static_cast<target*> (v));
- level4 ([&]{trace << diag_doing (a, t);});
+ level5 ([&]{trace << diag_doing (a, t);});
switch (execute (a, t))
{
diff --git a/build/options b/build/options
index c0b9930..a2fea2c 100644
--- a/build/options
+++ b/build/options
@@ -208,6 +208,8 @@ namespace cl
class options
{
public:
+ options ();
+
options (int& argc,
char** argv,
bool erase = false,
@@ -240,8 +242,6 @@ class options
::cl::unknown_mode option = ::cl::unknown_mode::fail,
::cl::unknown_mode argument = ::cl::unknown_mode::stop);
- options ();
-
// Option accessors.
//
const bool&
@@ -253,9 +253,15 @@ class options
const bool&
v () const;
+ const bool&
+ q () const;
+
const std::uint16_t&
verbose () const;
+ bool
+ verbose_specified () const;
+
// Print usage information.
//
static void
@@ -277,7 +283,9 @@ class options
bool help_;
bool version_;
bool v_;
+ bool q_;
std::uint16_t verbose_;
+ bool verbose_specified_;
};
#include <build/options.ixx>
diff --git a/build/options.cli b/build/options.cli
index 67eeba2..9bd1dcd 100644
--- a/build/options.cli
+++ b/build/options.cli
@@ -12,13 +12,20 @@ class options
bool -v
{
"Print actual commands being executed. This is equivalent to
- \cb{--verbose 1}."
+ \cb{--verbose 2}."
};
- std::uint16_t --verbose = 0
+ bool -q
+ {
+ "Run quietly, only printing error messages. This is equivalent
+ to \cb{--verbose 0}."
+ };
+
+ std::uint16_t --verbose = 1
{
"<level>",
- "Set the diagnostics verbosity to a level between 0 (disabled) and
- 5 (lots of information). @@ Need to document further."
+ "Set the diagnostics verbosity to <level> between 0 (disabled) and
+ 6 (lots of information). The default is 1. @@ Need to document
+ further."
};
};
diff --git a/build/options.cxx b/build/options.cxx
index 3c1e194..b5c2754 100644
--- a/build/options.cxx
+++ b/build/options.cxx
@@ -172,7 +172,7 @@ namespace cl
struct parser
{
static void
- parse (X& x, scanner& s)
+ parse (X& x, bool& xs, scanner& s)
{
std::string o (s.next ());
@@ -185,6 +185,8 @@ namespace cl
}
else
throw missing_value (o);
+
+ xs = true;
}
};
@@ -203,7 +205,7 @@ namespace cl
struct parser<std::string>
{
static void
- parse (std::string& x, scanner& s)
+ parse (std::string& x, bool& xs, scanner& s)
{
const char* o (s.next ());
@@ -211,6 +213,8 @@ namespace cl
x = s.next ();
else
throw missing_value (o);
+
+ xs = true;
}
};
@@ -218,11 +222,13 @@ namespace cl
struct parser<std::vector<X> >
{
static void
- parse (std::vector<X>& c, scanner& s)
+ parse (std::vector<X>& c, bool& xs, scanner& s)
{
X x;
- parser<X>::parse (x, s);
+ bool dummy;
+ parser<X>::parse (x, dummy, s);
c.push_back (x);
+ xs = true;
}
};
@@ -230,11 +236,13 @@ namespace cl
struct parser<std::set<X> >
{
static void
- parse (std::set<X>& c, scanner& s)
+ parse (std::set<X>& c, bool& xs, scanner& s)
{
X x;
- parser<X>::parse (x, s);
+ bool dummy;
+ parser<X>::parse (x, dummy, s);
c.insert (x);
+ xs = true;
}
};
@@ -242,7 +250,7 @@ namespace cl
struct parser<std::map<K, V> >
{
static void
- parse (std::map<K, V>& m, scanner& s)
+ parse (std::map<K, V>& m, bool& xs, scanner& s)
{
std::string o (s.next ());
@@ -293,6 +301,8 @@ namespace cl
}
else
throw missing_value (o);
+
+ xs = true;
}
};
@@ -302,6 +312,13 @@ namespace cl
{
parser<T>::parse (x.*M, s);
}
+
+ template <typename X, typename T, T X::*M, bool X::*S>
+ void
+ thunk (X& x, scanner& s)
+ {
+ parser<T>::parse (x.*M, x.*S, s);
+ }
}
#include <map>
@@ -315,7 +332,9 @@ options ()
: help_ (),
version_ (),
v_ (),
- verbose_ (0)
+ q_ (),
+ verbose_ (1),
+ verbose_specified_ (false)
{
}
@@ -328,7 +347,9 @@ options (int& argc,
: help_ (),
version_ (),
v_ (),
- verbose_ (0)
+ q_ (),
+ verbose_ (1),
+ verbose_specified_ (false)
{
::cl::argv_scanner s (argc, argv, erase);
_parse (s, opt, arg);
@@ -344,7 +365,9 @@ options (int start,
: help_ (),
version_ (),
v_ (),
- verbose_ (0)
+ q_ (),
+ verbose_ (1),
+ verbose_specified_ (false)
{
::cl::argv_scanner s (start, argc, argv, erase);
_parse (s, opt, arg);
@@ -360,7 +383,9 @@ options (int& argc,
: help_ (),
version_ (),
v_ (),
- verbose_ (0)
+ q_ (),
+ verbose_ (1),
+ verbose_specified_ (false)
{
::cl::argv_scanner s (argc, argv, erase);
_parse (s, opt, arg);
@@ -378,7 +403,9 @@ options (int start,
: help_ (),
version_ (),
v_ (),
- verbose_ (0)
+ q_ (),
+ verbose_ (1),
+ verbose_specified_ (false)
{
::cl::argv_scanner s (start, argc, argv, erase);
_parse (s, opt, arg);
@@ -392,7 +419,9 @@ options (::cl::scanner& s,
: help_ (),
version_ (),
v_ (),
- verbose_ (0)
+ q_ (),
+ verbose_ (1),
+ verbose_specified_ (false)
{
_parse (s, opt, arg);
}
@@ -406,8 +435,10 @@ print_usage (::std::ostream& os)
os << "-v Print actual commands being executed." << ::std::endl;
- os << "--verbose <level> Set the diagnostics verbosity to a level between 0 (disabled)" << ::std::endl
- << " and 5 (lots of information)." << ::std::endl;
+ os << "-q Run quietly, only printing error messages." << ::std::endl;
+
+ os << "--verbose <level> Set the diagnostics verbosity to <level> between 0 (disabled)" << ::std::endl
+ << " and 6 (lots of information)." << ::std::endl;
}
typedef
@@ -426,8 +457,11 @@ struct _cli_options_map_init
&::cl::thunk< options, bool, &options::version_ >;
_cli_options_map_["-v"] =
&::cl::thunk< options, bool, &options::v_ >;
+ _cli_options_map_["-q"] =
+ &::cl::thunk< options, bool, &options::q_ >;
_cli_options_map_["--verbose"] =
- &::cl::thunk< options, std::uint16_t, &options::verbose_ >;
+ &::cl::thunk< options, std::uint16_t, &options::verbose_,
+ &options::verbose_specified_ >;
}
};
diff --git a/build/options.ixx b/build/options.ixx
index 671f9ec..c44d7e5 100644
--- a/build/options.ixx
+++ b/build/options.ixx
@@ -133,12 +133,24 @@ v () const
return this->v_;
}
+inline const bool& options::
+q () const
+{
+ return this->q_;
+}
+
inline const std::uint16_t& options::
verbose () const
{
return this->verbose_;
}
+inline bool options::
+verbose_specified () const
+{
+ return this->verbose_specified_;
+}
+
// Begin epilogue.
//
//
diff --git a/build/parser.cxx b/build/parser.cxx
index 59139ba..6c3e4bc 100644
--- a/build/parser.cxx
+++ b/build/parser.cxx
@@ -442,7 +442,7 @@ namespace build
ifs.exceptions (ifstream::failbit | ifstream::badbit);
- level4 ([&]{trace (t) << "entering " << p;});
+ level5 ([&]{trace (t) << "entering " << p;});
enter_buildfile (p);
@@ -462,7 +462,7 @@ namespace build
if (tt != type::eos)
fail (t) << "unexpected " << t;
- level4 ([&]{trace (t) << "leaving " << p;});
+ level5 ([&]{trace (t) << "leaving " << p;});
lexer_ = ol;
path_ = op;
@@ -554,7 +554,7 @@ namespace build
if (!root_->buildfiles.insert (p).second) // Note: may be "new" root.
{
- level4 ([&]{trace (l) << "skipping already included " << p;});
+ level5 ([&]{trace (l) << "skipping already included " << p;});
scope_ = ocs;
root_ = ors;
continue;
@@ -567,7 +567,7 @@ namespace build
ifs.exceptions (ifstream::failbit | ifstream::badbit);
- level4 ([&]{trace (t) << "entering " << p;});
+ level5 ([&]{trace (t) << "entering " << p;});
enter_buildfile (p);
@@ -592,7 +592,7 @@ namespace build
process_default_target (t);
- level4 ([&]{trace (t) << "leaving " << p;});
+ level5 ([&]{trace (t) << "leaving " << p;});
default_target_ = odt;
lexer_ = ol;
@@ -1478,7 +1478,7 @@ namespace build
//
if (rs != root_)
{
- level4 ([&]{trace << "switching to root scope " << rs->out_path ();});
+ level5 ([&]{trace << "switching to root scope " << rs->out_path ();});
root_ = rs;
}
@@ -1510,7 +1510,7 @@ namespace build
target& dt (*default_target_);
- level4 ([&]{trace (t) << "creating current directory alias for " << dt;});
+ level5 ([&]{trace (t) << "creating current directory alias for " << dt;});
target& ct (
targets.insert (
diff --git a/build/prerequisite.cxx b/build/prerequisite.cxx
index 1f9f68b..89ac275 100644
--- a/build/prerequisite.cxx
+++ b/build/prerequisite.cxx
@@ -61,7 +61,7 @@ namespace build
//
if (p.ext != ext)
{
- level4 ([&]{
+ level5 ([&]{
diag_record r (trace);
r << "assuming prerequisite " << p << " is the same as the "
<< "one with ";
diff --git a/build/rule.cxx b/build/rule.cxx
index 0fe5e1a..cce291c 100644
--- a/build/rule.cxx
+++ b/build/rule.cxx
@@ -62,7 +62,7 @@ namespace build
if (ts != timestamp_nonexistent)
return t;
- level3 ([&]{trace << "no existing file for target " << t;});
+ level4 ([&]{trace << "no existing file for target " << t;});
return nullptr;
}
default:
@@ -201,9 +201,9 @@ namespace build
//
if (!dir_exists (d))
{
- if (verb)
+ if (verb >= 2)
text << "mkdir " << d;
- else
+ else if (verb)
text << "mkdir " << t;
try
diff --git a/build/search.cxx b/build/search.cxx
index 32302d6..c06d281 100644
--- a/build/search.cxx
+++ b/build/search.cxx
@@ -49,7 +49,7 @@ namespace build
target& t (**i);
- level4 ([&]{trace << "existing target " << t << " for prerequisite "
+ level5 ([&]{trace << "existing target " << t << " for prerequisite "
<< pk;});
return &t;
@@ -85,7 +85,7 @@ namespace build
// think.
//
//fail << "no default extension for prerequisite " << pk;
- level3 ([&]{trace << "no existing file found for prerequisite "
+ level4 ([&]{trace << "no existing file found for prerequisite "
<< pk;});
return nullptr;
}
@@ -109,7 +109,7 @@ namespace build
if (mt == timestamp_nonexistent)
continue;
- level4 ([&]{trace << "found existing file " << f << " for prerequisite "
+ level5 ([&]{trace << "found existing file " << f << " for prerequisite "
<< pk;});
// Find or insert. Note: using our updated extension.
@@ -120,7 +120,7 @@ namespace build
//
file& t (dynamic_cast<file&> (r.first));
- level4 ([&]{trace << (r.second ? "new" : "existing") << " target "
+ level5 ([&]{trace << (r.second ? "new" : "existing") << " target "
<< t << " for prerequisite " << pk;});
if (t.path ().empty ())
@@ -130,7 +130,7 @@ namespace build
return &t;
}
- level3 ([&]{trace << "no existing file found for prerequisite " << pk;});
+ level4 ([&]{trace << "no existing file found for prerequisite " << pk;});
return nullptr;
}
@@ -164,7 +164,7 @@ namespace build
target& t (r.first);
- level4 ([&]{trace << "new target " << t << " for prerequisite " << pk;});
+ level5 ([&]{trace << "new target " << t << " for prerequisite " << pk;});
return t;
}
diff --git a/build/target.cxx b/build/target.cxx
index 9e0bea7..9b20273 100644
--- a/build/target.cxx
+++ b/build/target.cxx
@@ -219,7 +219,7 @@ namespace build
const string* ext (*k.ext);
if (t.ext != ext)
{
- level4 ([&]{
+ level5 ([&]{
diag_record r (trace);
r << "assuming target " << t << " is the same as the one with ";
if (ext == nullptr)
diff --git a/build/test/module.cxx b/build/test/module.cxx
index b3378ba..deda6e9 100644
--- a/build/test/module.cxx
+++ b/build/test/module.cxx
@@ -40,7 +40,7 @@ namespace build
}
const dir_path& out_root (r.out_path ());
- level4 ([&]{trace << "for " << out_root;});
+ level5 ([&]{trace << "for " << out_root;});
// Register the test operation.
//
diff --git a/build/test/rule.cxx b/build/test/rule.cxx
index 25baaa7..ea268a9 100644
--- a/build/test/rule.cxx
+++ b/build/test/rule.cxx
@@ -416,9 +416,9 @@ namespace build
args.push_back (nullptr); // Second.
- if (verb)
+ if (verb >= 2)
print_process (args);
- else
+ else if (verb)
text << "test " << t;
{