diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2015-08-31 13:45:57 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2015-08-31 13:45:57 +0200 |
commit | 5974cab56148a18628bfb423189e016ade2d40f9 (patch) | |
tree | 472a7966d0e1c5725f0736c73812cbdeaab827dc /build/dump.cxx | |
parent | 2a9d673f298b623db061ee85d397563d644c8268 (diff) |
Rework scoping logic
Now the src directory is entered into the scope map and points to
the same scope as out. This means that targets that are in src,
not out (e.g., source files) will "see" rules, variables, etc.
This becomes important when we try, for example, to install a
source file (say, a header) from src: we need the rule as well
as the install.* variables.
Diffstat (limited to 'build/dump.cxx')
-rw-r--r-- | build/dump.cxx | 72 |
1 files changed, 29 insertions, 43 deletions
diff --git a/build/dump.cxx b/build/dump.cxx index f3b8c4b..7f4502e 100644 --- a/build/dump.cxx +++ b/build/dump.cxx @@ -4,7 +4,6 @@ #include <build/dump> -#include <set> #include <string> #include <cassert> @@ -142,19 +141,21 @@ namespace build dump_scope (ostream& os, string& ind, action a, - scope& p, - scope_map::iterator& i, - set<const target*>& rts) + scope_map::const_iterator& i) { + scope& p (*i->second); + const dir_path& d (i->first); + ++i; + // We don't want the extra notations (e.g., ~/) provided by // diag_relative() since we want the path to be relative to - // the global scope. + // the outer scope. // - os << ind << relative (p.path ()) << ":" << endl + os << ind << relative (d) << ":" << endl << ind << '{'; const dir_path* orb (relative_base); - relative_base = &p.path (); + relative_base = &d; ind += " "; @@ -179,10 +180,25 @@ namespace build vb = true; } - // Nested scopes of which we are a parent. + // Nested scopes of which we are an immediate parent. // - for (auto e (scopes.end ()); i != e && i->second.parent_scope () == &p; ) + for (auto e (scopes.end ()); i != e && i->second->parent_scope () == &p;) { + // See what kind of scope entry this is. It can be: + // + // 1. Out-of-project scope. + // 2. In-project out entry. + // 3. In-project src entry. + // + // We want to print #2 and #3 as a single, unified scope. + // + scope& s (*i->second); + if (s.src_path_ != s.out_path_ && s.src_path_ == &i->first) + { + ++i; + continue; + } + if (vb) { os << endl; @@ -193,9 +209,7 @@ namespace build os << endl; // Extra newline between scope blocks. os << endl; - scope& s (i->second); - dump_scope (os, ind, a, s, ++i, rts); - + dump_scope (os, ind, a, i); sb = true; } @@ -204,33 +218,8 @@ namespace build for (const auto& pt: targets) { const target& t (*pt); - const scope* ts (&t.base_scope ()); - - bool f (false); - if (ts == &p) - { - // If this is the global scope, check that this target hasn't - // been handled by the src logic below. - // - f = (ts != global_scope || rts.find (&t) == rts.end ()); - } - // If this target is in the global scope and we have a corresponding - // src directory (i.e., we are a scope inside a project), check - // whether this target is in our src. - // - else if (ts == global_scope && p.src_path_ != nullptr) - { - if (t.dir.sub (p.src_path ())) - { - // Check that it hasn't already been handled by a more qualified - // scope. - // - f = rts.insert (&t).second; - } - } - - if (!f) + if (&p != &t.base_scope ()) continue; if (vb || sb) @@ -254,14 +243,11 @@ namespace build dump (action a) { auto i (scopes.begin ()); - scope& g (i->second); // Global scope. - assert (&g == global_scope); + assert (i->second == global_scope); string ind; - set<const target*> rts; - ostream& os (*diag_stream); - dump_scope (os, ind, a, g, ++i, rts); + dump_scope (os, ind, a, i); os << endl; } } |