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/context.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/context.cxx')
-rw-r--r-- | build2/context.cxx | 29 |
1 files changed, 12 insertions, 17 deletions
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 // <build2/path-map> 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() |