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/scope | |
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/scope')
-rw-r--r-- | build2/scope | 62 |
1 files changed, 16 insertions, 46 deletions
diff --git a/build2/scope b/build2/scope index c1dcb91..ad9c3a0 100644 --- a/build2/scope +++ b/build2/scope @@ -27,16 +27,14 @@ namespace build2 public: // Absolute and normalized. // - const dir_path& - out_path () const {return *out_path_;} + const dir_path& out_path () const {return *out_path_;} + const dir_path& src_path () const {return *src_path_;} - const dir_path& - src_path () const {return *src_path_;} - - // These are pointers to the keys in scope_map. + // The first is a pointer to the key in scope_map. The second is a pointer + // to the src_root/base variable value, if any (i.e., it can be NULL). // - const dir_path* out_path_ {nullptr}; - const dir_path* src_path_ {nullptr}; + const dir_path* out_path_ = nullptr; + const dir_path* src_path_ = nullptr; bool root () const {return root_ == this;} @@ -230,22 +228,6 @@ namespace build2 public: loaded_module_map modules; // Only on root scope. - public: - bool - empty () const - { - return - vars.empty () && - target_vars.empty () && - prerequisites.empty () && - meta_operations.empty () && - operations.empty () && - buildfiles.empty () && - target_types.empty () && - rules.empty () && - modules.empty (); - } - private: friend class scope_map; friend class temp_scope; @@ -284,27 +266,26 @@ namespace build2 } }; - class scope_map + // Note that the scope map is only for paths from the out tree. + // + using scope_map_base = butl::dir_path_map<scope>; + + class scope_map: public scope_map_base { public: - using map_type = butl::dir_path_map<scope*>; - using iterator = map_type::iterator; - using const_iterator = map_type::const_iterator; - - // Note that we assume the first insertion into the map is that - // of the global scope. If the passed scope pointer is not NULL, - // then insert this scope instead of a new one. + // Note that we assume the first insertion into the map is always the + // global scope. // iterator - insert (const dir_path&, scope*, bool parent, bool root); + insert (const dir_path&, bool root); // Find the most qualified scope that encompasses this path. // scope& - find (const dir_path&) const; + find (const dir_path&); scope& - find (const path& p) const + find (const path& p) { // Natural thing to do here would be to call find (p.directory ()). // However, there could be a situation where the passed path is a @@ -313,17 +294,6 @@ namespace build2 // return find (dir_path (p.string ())); } - - const_iterator begin () const {return map_.begin ();} - const_iterator end () const {return map_.end ();} - - void - clear (); - - ~scope_map () {clear ();} - - private: - map_type map_; }; extern scope_map scopes; |