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/prerequisite | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) (limited to 'build2/prerequisite') diff --git a/build2/prerequisite b/build2/prerequisite index baaaf3f..f316fb5 100644 --- a/build2/prerequisite +++ b/build2/prerequisite @@ -27,8 +27,8 @@ namespace build2 typedef build2::scope scope_type; mutable const string* proj; // Can be NULL, from project_name_pool. - target_key tk; - mutable scope_type* scope; // Can be NULL if tk.dir is absolute. + target_key tk; // .dir and .out can be relative. + mutable scope_type* scope; // Can be NULL if tk.dir is absolute. }; inline bool @@ -51,38 +51,44 @@ namespace build2 typedef build2::target_type target_type_type; typedef build2::scope scope_type; + // Note that unlike targets, for prerequisites an empty out directory + // means undetermined rather than being definitely in the out tree. + // + const string* const proj; // NULL if not project-qualified. + const target_type_type& type; + const dir_path dir; // Normalized absolute or relative (to scope). + const dir_path out; // Empty, normalized absolute, or relative. + const string name; + const string* ext; // NULL if unspecified. + scope_type& scope; + target_type* target; // NULL if not yet resolved. Note that this should + // always be the "primary target", not a member of + // a target group. + + public: prerequisite (const string* p, const target_type_type& t, dir_path d, + dir_path o, string n, const string* e, scope_type& s) : proj (p), type (t), dir (move (d)), + out (move (o)), name (move (n)), ext (e), scope (s), target (nullptr) {} - public: - const string* const proj; // NULL if not project-qualified. - const target_type_type& type; - const dir_path dir; // Normalized absolute or relative (to scope). - const string name; - const string* ext; // NULL if unspecified. - scope_type& scope; - target_type* target; // NULL if not yet resolved. Note that this should - // always be the "primary target", not a member of - // a target group. - // Note that the returned key "tracks" the prerequisite; that is, any // updates to the prerequisite's members will be reflected in the key. // prerequisite_key key () const { - return prerequisite_key {proj, {&type, &dir, &name, ext}, &scope}; + return prerequisite_key {proj, {&type, &dir, &out, &name, ext}, &scope}; } public: @@ -113,6 +119,7 @@ namespace build2 insert (const string* proj, const target_type&, dir_path dir, + dir_path out, string name, const string* ext, scope&, @@ -121,7 +128,7 @@ namespace build2 pair insert (const string* proj, const target_key& tk, scope& s, tracer& t) { - return insert (proj, *tk.type, *tk.dir, *tk.name, tk.ext, s, t); + return insert (proj, *tk.type, *tk.dir, *tk.out, *tk.name, tk.ext, s, t); } }; } -- cgit v1.1