aboutsummaryrefslogtreecommitdiff
path: root/build/dump.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-04-29 13:17:30 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-04-29 13:17:30 +0200
commit6dbf3bbd2efa963859156826a25fc639c6c52ce5 (patch)
tree20cfd40a9b9649578a88b5eff7415a56eb14001d /build/dump.cxx
parentc087efe145a75087acd646abe3258dad4aef4e2a (diff)
Add support for setting target-specific variables from buildfiles
Diffstat (limited to 'build/dump.cxx')
-rw-r--r--build/dump.cxx76
1 files changed, 49 insertions, 27 deletions
diff --git a/build/dump.cxx b/build/dump.cxx
index 3f3bd93..df7d782 100644
--- a/build/dump.cxx
+++ b/build/dump.cxx
@@ -18,10 +18,38 @@ using namespace std;
namespace build
{
+ static bool
+ dump_variables (ostream& os, string& ind, const variable_map& vars)
+ {
+ bool r (false);
+
+ for (const auto& e: vars)
+ {
+ const variable& var (e.first);
+ const value_ptr& val (e.second);
+
+ os << endl
+ << ind << var.name << " = ";
+
+ if (val == nullptr)
+ os << "[null]";
+ else
+ {
+ //@@ TODO: assuming it is a list.
+ //
+ os << dynamic_cast<list_value&> (*val);
+ }
+
+ r = true;
+ }
+
+ return r;
+ }
+
static void
- dump_target (ostream& os, action a, const target& t)
+ dump_target (ostream& os, string& ind, action a, const target& t)
{
- os << t;
+ os << ind << t;
if (t.group != nullptr)
os << "->" << *t.group;
@@ -55,14 +83,27 @@ namespace build
first = false;
}
}
+
+ // Print target-specific variables.
+ //
+ if (!t.vars.empty ())
+ {
+ os << endl
+ << ind << '{';
+ ind += " ";
+ dump_variables (os, ind, t.vars);
+ ind.resize (ind.size () - 2);
+ os << endl
+ << ind << '}';
+ }
}
static void
dump_scope (ostream& os,
+ string& ind,
action a,
scope& p,
scope_map::iterator& i,
- string& ind,
set<const target*>& rts)
{
// We don't want the extra notations (e.g., ~/) provided by
@@ -81,25 +122,7 @@ namespace build
// Variables.
//
- for (const auto& e: p.vars)
- {
- const variable& var (e.first);
- const value_ptr& val (e.second);
-
- os << endl
- << ind << var.name << " = ";
-
- if (val == nullptr)
- os << "[null]";
- else
- {
- //@@ TODO: assuming it is a list.
- //
- os << dynamic_cast<list_value&> (*val);
- }
-
- vb = true;
- }
+ vb = dump_variables (os, ind, p.vars);
// Nested scopes of which we are a parent.
//
@@ -116,7 +139,7 @@ namespace build
os << endl;
scope& s (i->second);
- dump_scope (os, a, s, ++i, ind, rts);
+ dump_scope (os, ind, a, s, ++i, rts);
sb = true;
}
@@ -161,9 +184,8 @@ namespace build
vb = sb = false;
}
- os << endl
- << ind;
- dump_target (os, a, t);
+ os << endl;
+ dump_target (os, ind, a, t);
}
ind.resize (ind.size () - 2);
@@ -184,7 +206,7 @@ namespace build
set<const target*> rts;
ostream& os (*diag_stream);
- dump_scope (os, a, g, ++i, ind, rts);
+ dump_scope (os, ind, a, g, ++i, rts);
os << endl;
}
}