aboutsummaryrefslogtreecommitdiff
path: root/build/cxx/rule.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-04-07 10:47:28 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-04-07 10:47:28 +0200
commit088a60c512aff26eeb026c516d0afe724880cb2b (patch)
tree3fbd798bd6a385875c8db3b2677a94d3abeb23eb /build/cxx/rule.cxx
parent137df0bea6cebabe5278e67e5dad6f3047c762fb (diff)
Provide more convenient access to root scope
Diffstat (limited to 'build/cxx/rule.cxx')
-rw-r--r--build/cxx/rule.cxx56
1 files changed, 30 insertions, 26 deletions
diff --git a/build/cxx/rule.cxx b/build/cxx/rule.cxx
index 8d7f3c3..daa76e0 100644
--- a/build/cxx/rule.cxx
+++ b/build/cxx/rule.cxx
@@ -182,18 +182,19 @@ namespace build
{
tracer trace ("cxx::compile::inject_prerequisites");
- scope& ts (scopes.find (o.path ()));
- const string& cxx (ts["config.cxx"].as<const string&> ());
+ scope& ts (o.base_scope ());
+ scope& rs (*ts.root_scope ()); // Shouldn't have matched if nullptr.
+ const string& cxx (rs["config.cxx"].as<const string&> ());
vector<const char*> args {cxx.c_str ()};
- append_options (args, ts, "config.cxx.poptions");
+ append_options (args, rs, "config.cxx.poptions");
append_options (args, ts, "cxx.poptions");
// @@ Some C++ options (e.g., -std, -m) affect the preprocessor.
// Or maybe they are not C++ options? Common options?
//
- append_options (args, ts, "config.cxx.coptions");
+ append_options (args, rs, "config.cxx.coptions");
string std; // Storage.
append_std (args, ts, std);
@@ -333,18 +334,19 @@ namespace build
// Translate paths to relative (to working directory) ones. This
// results in easier to read diagnostics.
//
- path ro (relative (o.path ()));
- path rs (relative (s->path ()));
+ path relo (relative (o.path ()));
+ path rels (relative (s->path ()));
- scope& ts (scopes.find (o.path ()));
- const string& cxx (ts["config.cxx"].as<const string&> ());
+ scope& ts (o.base_scope ());
+ scope& rs (*ts.root_scope ()); // Shouldn't have matched if nullptr.
+ const string& cxx (rs["config.cxx"].as<const string&> ());
vector<const char*> args {cxx.c_str ()};
- append_options (args, ts, "config.cxx.poptions");
+ append_options (args, rs, "config.cxx.poptions");
append_options (args, ts, "cxx.poptions");
- append_options (args, ts, "config.cxx.coptions");
+ append_options (args, rs, "config.cxx.coptions");
string std; // Storage.
append_std (args, ts, std);
@@ -352,10 +354,10 @@ namespace build
append_options (args, ts, "cxx.coptions");
args.push_back ("-o");
- args.push_back (ro.string ().c_str ());
+ args.push_back (relo.string ().c_str ());
args.push_back ("-c");
- args.push_back (rs.string ().c_str ());
+ args.push_back (rels.string ().c_str ());
args.push_back (nullptr);
@@ -495,13 +497,14 @@ namespace build
if (out_root == nullptr)
{
- // Which scope shall we use to resolve the roots? Unlikely,
+ // Which scope shall we use to resolve the root? Unlikely,
// but possible, the prerequisite is from a different project
// altogether. So we are going to use the target's project.
//
- scope& s (scopes.find (e.dir));
- out_root = &s["out_root"].as<const path&> ();
- src_root = &s["src_root"].as<const path&> ();
+ scope* rs (e.root_scope ());
+ assert (rs != nullptr); // Shouldn't have matched.
+ out_root = &rs->path ();
+ src_root = &rs->src_path ();
}
prerequisite& cp (p);
@@ -645,15 +648,16 @@ namespace build
// Translate paths to relative (to working directory) ones. This
// results in easier to read diagnostics.
//
- path re (relative (e.path ()));
- vector<path> ro;
+ path rele (relative (e.path ()));
+ vector<path> relo;
- scope& ts (scopes.find (e.path ()));
- const string& cxx (ts["config.cxx"].as<const string&> ());
+ scope& ts (e.base_scope ());
+ scope& rs (*ts.root_scope ()); // Shouldn't have matched if nullptr.
+ const string& cxx (rs["config.cxx"].as<const string&> ());
vector<const char*> args {cxx.c_str ()};
- append_options (args, ts, "config.cxx.coptions");
+ append_options (args, rs, "config.cxx.coptions");
string std; // Storage.
append_std (args, ts, std);
@@ -661,21 +665,21 @@ namespace build
append_options (args, ts, "cxx.coptions");
args.push_back ("-o");
- args.push_back (re.string ().c_str ());
+ args.push_back (rele.string ().c_str ());
- append_options (args, ts, "config.cxx.loptions");
+ append_options (args, rs, "config.cxx.loptions");
append_options (args, ts, "cxx.loptions");
for (const prerequisite& p: t.prerequisites)
{
if (const obj* o = dynamic_cast<const obj*> (p.target))
{
- ro.push_back (relative (o->path ()));
- args.push_back (ro.back ().string ().c_str ());
+ relo.push_back (relative (o->path ()));
+ args.push_back (relo.back ().string ().c_str ());
}
}
- append_options (args, ts, "config.cxx.libs");
+ append_options (args, rs, "config.cxx.libs");
append_options (args, ts, "cxx.libs");
args.push_back (nullptr);