aboutsummaryrefslogtreecommitdiff
path: root/build2/cxx/link.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-04-19 09:24:38 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-04-19 15:25:50 +0200
commitfc18a6dc1fcb02b505f07914e484cebbaf268698 (patch)
tree2cb9b04c5924dfd46e7d934912b41c3efd894a93 /build2/cxx/link.cxx
parentae20570f2ad55b2fa8e71cf450457cb9c4b21b1b (diff)
Redesign src/out scoping
We no longer enter paths from the src tree into scope map. Instead, targets from the src tree now include their out tree directory (in essence their "configuration"). This is then used to find a target's scope. See the comment in class target for details. The result of this change is that we can now again build multiple configurations (out trees) for same project at once.
Diffstat (limited to 'build2/cxx/link.cxx')
-rw-r--r--build2/cxx/link.cxx28
1 files changed, 17 insertions, 11 deletions
diff --git a/build2/cxx/link.cxx b/build2/cxx/link.cxx
index e4154ab..555c094 100644
--- a/build2/cxx/link.cxx
+++ b/build2/cxx/link.cxx
@@ -304,7 +304,10 @@ namespace build2
// Enter the target. Note that because the search paths are
// normalized, the result is automatically normalized as well.
//
- a = &targets.insert<liba> (d, p.name, ae, trace);
+ // Note that this target is outside any project which we treat
+ // as out trees.
+ //
+ a = &targets.insert<liba> (d, dir_path (), p.name, ae, trace);
if (a->path ().empty ())
a->path (move (f));
@@ -322,7 +325,7 @@ namespace build2
if ((mt = file_mtime (f)) != timestamp_nonexistent)
{
- s = &targets.insert<libso> (d, p.name, se, trace);
+ s = &targets.insert<libso> (d, dir_path (), p.name, se, trace);
if (s->path ().empty ())
s->path (move (f));
@@ -345,7 +348,7 @@ namespace build2
{
// Enter the target group.
//
- lib& l (targets.insert<lib> (*pd, p.name, p.ext, trace));
+ lib& l (targets.insert<lib> (*pd, dir_path (), p.name, p.ext, trace));
// It should automatically link-up to the members we have found.
//
@@ -597,12 +600,12 @@ namespace build2
? obj::static_type
: (so ? objso::static_type : obja::static_type));
- // Come up with the obj*{} target. The c(xx){} prerequisite
- // directory can be relative (to the scope) or absolute. If it is
- // relative, then use it as is. If it is absolute, then translate
- // it to the corresponding directory under out_root. While the
- // c(xx){} directory is most likely under src_root, it is also
- // possible it is under out_root (e.g., generated source).
+ // Come up with the obj*{} target. The c(xx){} prerequisite directory
+ // can be relative (to the scope) or absolute. If it is relative, then
+ // use it as is. If absolute, then translate it to the corresponding
+ // directory under out_root. While the c(xx){} directory is most
+ // likely under src_root, it is also possible it is under out_root
+ // (e.g., generated source).
//
dir_path d;
{
@@ -621,7 +624,10 @@ namespace build2
}
}
- target& ot (search (o_type, d, *cp.tk.name, nullptr, cp.scope));
+ // obj*{} is always in the out tree.
+ //
+ target& ot (
+ search (o_type, d, dir_path (), *cp.tk.name, nullptr, cp.scope));
// If we are cleaning, check that this target is in the same or
// a subdirectory of our project root.
@@ -646,7 +652,7 @@ namespace build2
if (pt == nullptr)
pt = &search (so ? objso::static_type : obja::static_type,
- o.dir, o.name, o.ext, nullptr);
+ o.dir, o.out, o.name, o.ext, nullptr);
}
else
pt = &ot;