aboutsummaryrefslogtreecommitdiff
path: root/build/target.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/target.cxx
parent137df0bea6cebabe5278e67e5dad6f3047c762fb (diff)
Provide more convenient access to root scope
Diffstat (limited to 'build/target.cxx')
-rw-r--r--build/target.cxx31
1 files changed, 23 insertions, 8 deletions
diff --git a/build/target.cxx b/build/target.cxx
index dc85402..4f49206 100644
--- a/build/target.cxx
+++ b/build/target.cxx
@@ -37,6 +37,20 @@ namespace build
// target
//
+ scope& target::
+ base_scope () const
+ {
+ return scopes.find (dir);
+ }
+
+ scope* target::
+ root_scope () const
+ {
+ // This is tricky to cache so we do the lookup for now.
+ //
+ return scopes.find (dir).root_scope ();
+ }
+
ostream&
operator<< (ostream& os, const target& t)
{
@@ -97,16 +111,17 @@ namespace build
tracer& trace)
{
iterator i (find (target_key {&tt, &dir, &name, &ext}, trace));
+ bool r (i == end ());
- if (i != end ())
- return pair<target&, bool> (**i, false);
-
- unique_ptr<target> t (tt.factory (move (dir), move (name), ext));
- i = map_.emplace (
- make_pair (target_key {&tt, &t->dir, &t->name, &t->ext},
- move (t))).first;
+ if (r)
+ {
+ unique_ptr<target> pt (tt.factory (move (dir), move (name), ext));
+ i = map_.emplace (
+ make_pair (target_key {&tt, &pt->dir, &pt->name, &pt->ext},
+ move (pt))).first;
+ }
- return pair<target&, bool> (**i, true);
+ return pair<target&, bool> (**i, r);
}
ostream&