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/target-key | |
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/target-key')
-rw-r--r-- | build2/target-key | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/build2/target-key b/build2/target-key index bf88007..2c0d0f2 100644 --- a/build2/target-key +++ b/build2/target-key @@ -22,7 +22,8 @@ namespace build2 { public: const target_type* const type; - const dir_path* const dir; + const dir_path* const dir; // Can be relative if part of prerequisite_key. + const dir_path* const out; // Can be relative if part of prerequisite_key. const string* const name; const string* const& ext; @@ -32,17 +33,18 @@ namespace build2 const target_type* xt (x.type); const target_type* yt (y.type); - //@@ TODO: use compare() to compare once. + int t, n, d, o; // Unspecified and specified extension are assumed equal. The // extension strings are from the pool, so we can just compare // pointers. // return - (xt < yt) || - (xt == yt && *x.name < *y.name) || - (xt == yt && *x.name == *y.name && *x.dir < *y.dir) || - (xt == yt && *x.name == *y.name && *x.dir == *y.dir && + ((t = xt < yt ? -1 : xt > yt ? 1 : 0) < 0) || + (t == 0 && (n = x.name->compare (*y.name)) < 0) || + (t == 0 && n == 0 && (d = x.dir->compare (*y.dir)) < 0) || + (t == 0 && n == 0 && d == 0 && (o = x.out->compare (*y.out)) < 0) || + (t == 0 && n == 0 && d == 0 && o == 0 && x.ext != nullptr && y.ext != nullptr && *x.ext < *y.ext); } }; |