diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2016-04-19 09:24:38 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2016-04-19 15:25:50 +0200 |
commit | fc18a6dc1fcb02b505f07914e484cebbaf268698 (patch) | |
tree | 2cb9b04c5924dfd46e7d934912b41c3efd894a93 /build2/file.cxx | |
parent | ae20570f2ad55b2fa8e71cf450457cb9c4b21b1b (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/file.cxx')
-rw-r--r-- | build2/file.cxx | 69 |
1 files changed, 30 insertions, 39 deletions
diff --git a/build2/file.cxx b/build2/file.cxx index 4b0795c..f5ce91c 100644 --- a/build2/file.cxx +++ b/build2/file.cxx @@ -131,8 +131,8 @@ namespace build2 scope& create_root (const dir_path& out_root, const dir_path& src_root) { - auto i (scopes.insert (out_root, nullptr, true, true)); - scope& rs (*i->second); + auto i (scopes.insert (out_root, true)); + scope& rs (i->second); // Set out_path. src_path is set in setup_root() below. // @@ -199,14 +199,16 @@ namespace build2 void setup_root (scope& s) { + // The caller must have made sure src_root is set on this scope. + // value& v (s.assign ("src_root")); assert (v); + const dir_path& d (cast<dir_path> (v)); - // Register and set src_path. - // if (s.src_path_ == nullptr) - s.src_path_ = &scopes.insert ( - cast<dir_path> (v), &s, false, true)->first; + s.src_path_ = &d; + else + assert (s.src_path_ == &d); } scope& @@ -214,46 +216,35 @@ namespace build2 const dir_path& out_base, const dir_path& src_base) { - scope& s (*i->second); + scope& s (i->second); - // Set src/out_path. The key (i->first) can be either out_base - // or src_base. + // Set src/out_base variables. // - if (s.out_path_ == nullptr) - { - s.out_path_ = - i->first == out_base - ? &i->first - : &scopes.insert (out_base, &s, true, false)->first; - } + value& ov (s.assign ("out_base")); - if (s.src_path_ == nullptr) - { - s.src_path_ = - i->first == src_base - ? &i->first - : &scopes.insert (src_base, &s, false, false)->first; - } + if (!ov) + ov = out_base; + else + assert (cast<dir_path> (ov) == out_base); - // Set src/out_base variables. - // - { - value& v (s.assign ("out_base")); + value& sv (s.assign ("src_base")); - if (!v) - v = out_base; - else - assert (cast<dir_path> (v) == out_base); - } + if (!sv) + sv = src_base; + else + assert (cast<dir_path> (sv) == src_base); - { - value& v (s.assign ("src_base")); + // Set src/out_path. The key (i->first) is out_base. + // + if (s.out_path_ == nullptr) + s.out_path_ = &i->first; + else + assert (*s.out_path_ == out_base); - if (!v) - v = src_base; - else - assert (cast<dir_path> (v) == src_base); - } + if (s.src_path_ == nullptr) + s.src_path_ = &cast<dir_path> (sv); + else + assert (*s.src_path_ == src_base); return s; } |