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/context.cxx | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) (limited to 'build2/context.cxx') diff --git a/build2/context.cxx b/build2/context.cxx index a36b2b6..a27d4ff 100644 --- a/build2/context.cxx +++ b/build2/context.cxx @@ -77,9 +77,9 @@ namespace build2 // for details. // { - auto i (scopes.insert (dir_path ("/"), nullptr, true, false)); - global_scope = i->second; - global_scope->out_path_ = global_scope->src_path_ = &i->first; + auto i (scopes.insert (dir_path ("/"), false)); + global_scope = &i->second; + global_scope->out_path_ = &i->first; } scope& gs (*global_scope); @@ -182,10 +182,7 @@ namespace build2 if (c == '!' || !dir.empty ()) { - scope& s (c == '!' - ? gs - : *scopes.insert (dir, nullptr, true, false)->second); - + scope& s (c == '!' ? gs : scopes.insert (dir, false)->second); auto p (s.vars.assign (*o)); if (!p.second) @@ -412,31 +409,29 @@ namespace build2 dir_path src_out (const dir_path& out, scope& s) { - scope& rs (*s.root_scope ()); - return src_out (out, rs.out_path (), rs.src_path ()); + return src_out (out, s.out_path (), s.src_path ()); } dir_path out_src (const dir_path& src, scope& s) { - scope& rs (*s.root_scope ()); - return out_src (src, rs.out_path (), rs.src_path ()); + return out_src (src, s.out_path (), s.src_path ()); } dir_path src_out (const dir_path& o, - const dir_path& out_root, const dir_path& src_root) + const dir_path& out_base, const dir_path& src_base) { - assert (o.sub (out_root)); - return src_root / o.leaf (out_root); + assert (o.sub (out_base)); + return src_base / o.leaf (out_base); } dir_path out_src (const dir_path& s, - const dir_path& out_root, const dir_path& src_root) + const dir_path& out_base, const dir_path& src_base) { - assert (s.sub (src_root)); - return out_root / s.leaf (src_root); + assert (s.sub (src_base)); + return out_base / s.leaf (src_base); } // relative() -- cgit v1.1