From fc18a6dc1fcb02b505f07914e484cebbaf268698 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 19 Apr 2016 09:24:38 +0200 Subject: 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. --- build2/file.cxx | 69 +++++++++++++++++++++++++-------------------------------- 1 file changed, 30 insertions(+), 39 deletions(-) (limited to 'build2/file.cxx') 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 (v)); - // Register and set src_path. - // if (s.src_path_ == nullptr) - s.src_path_ = &scopes.insert ( - cast (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 (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 (v) == out_base); - } + if (!sv) + sv = src_base; + else + assert (cast (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 (v) == src_base); - } + if (s.src_path_ == nullptr) + s.src_path_ = &cast (sv); + else + assert (*s.src_path_ == src_base); return s; } -- cgit v1.1