aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/file.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2020-03-27 10:39:52 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2020-03-27 10:40:58 +0200
commit2cc2772263d17a9b2755990d53e992a94d37e29d (patch)
tree1ad8e98e564485ae87ebae9a6e3546798eeda7b4 /libbuild2/file.cxx
parentee128a8d4c3d5739b31fbb9e935b319176837cc8 (diff)
Implement project configuration reporting, similar to build system modules
Diffstat (limited to 'libbuild2/file.cxx')
-rw-r--r--libbuild2/file.cxx68
1 files changed, 68 insertions, 0 deletions
diff --git a/libbuild2/file.cxx b/libbuild2/file.cxx
index 613f095..405e1f0 100644
--- a/libbuild2/file.cxx
+++ b/libbuild2/file.cxx
@@ -3,6 +3,8 @@
#include <libbuild2/file.hxx>
+#include <iomanip> // left, setw()
+
#include <libbuild2/scope.hxx>
#include <libbuild2/target.hxx>
#include <libbuild2/context.hxx>
@@ -1297,6 +1299,72 @@ namespace build2
if (he) {source_hooks (p, root, hd, true /* pre */); p.reset ();}
if (fe) {source_once (p, root, root, f, root);}
if (he) {p.reset (); source_hooks (p, root, hd, false /* pre */);}
+
+ // Print the project configuration report, similar to how we do it in
+ // build system modules.
+ //
+ if (!p.config_report.empty () && verb >= (p.config_report_new ? 2 : 3))
+ {
+ const project_name& proj (named_project (root)); // Must be there.
+
+ // @@ TODO/MAYBE:
+ //
+ // - Should we be printing NULL values?
+ //
+
+ // Use the special `config` module name (which doesn't have its own
+ // report) for project configuration.
+ //
+ diag_record dr (text);
+ dr << "config " << proj << '@' << root;
+
+ // Printing the whole variable name would add too much noise with all
+ // the repetitive config.<project>. So we are only going to print the
+ // part after <project> (see parser::parse_config() for details).
+ //
+ string stem ('.' + proj.variable () + '.');
+
+ names storage;
+ for (const pair<lookup, string>& lf: p.config_report)
+ {
+ lookup l (lf.first);
+ const string& f (lf.second);
+
+ // If the report variable has been overriden, now is the time to
+ // lookup its value.
+ //
+ string n;
+ if (l.value == nullptr)
+ {
+ n = l.var->name; // Use the name as is.
+ l = root[*l.var];
+ }
+ else
+ {
+ size_t p (l.var->name.find (stem)); // Must be there.
+ n = string (l.var->name, p + stem.size ());
+ }
+
+ dr << "\n ";
+
+ if (const value& v = *l)
+ {
+ storage.clear ();
+ auto ns (reverse (v, storage));
+
+ if (f == "multiline")
+ {
+ dr << n;
+ for (auto& n: ns)
+ dr << "\n " << n;
+ }
+ else
+ dr << left << setw (10) << n << ' ' << ns;
+ }
+ else
+ dr << left << setw (10) << n << " [null]";
+ }
+ }
}
scope&