diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2021-05-24 10:50:28 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2021-05-28 10:10:44 +0200 |
commit | 726aaab07a785b904dd1265bffa603bdd2a7665b (patch) | |
tree | ec28756d501ef3411b02a10a24dde76535e6581c /libbuild2/scope.hxx | |
parent | e1f472e471533330db05a42d5bcd4e99b211da0c (diff) |
Tie loose ends in target type/pattern-specific matching
Diffstat (limited to 'libbuild2/scope.hxx')
-rw-r--r-- | libbuild2/scope.hxx | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/libbuild2/scope.hxx b/libbuild2/scope.hxx index 5a853d9..3529495 100644 --- a/libbuild2/scope.hxx +++ b/libbuild2/scope.hxx @@ -132,17 +132,25 @@ namespace build2 lookup_type lookup (const variable& var, const target_key& tk) const { - //@@ TODO: dir name - return lookup (var, tk.type, tk.name).first; + return lookup (var, &tk).first; + } + + lookup_type + lookup (const variable& var, + const target_key& tk, + const target_key& gk) const + { + return lookup (var, &tk, &gk).first; } // Note for dir{} and fsdir{} target name is the directory leaf (without - // the trailing slash). + // the trailing slash). Also, if extension is to be matched (for this + // target type), then it should be included in the name. // lookup_type lookup (const variable& var, const target_type& tt, const string& tn) const { - return lookup (var, &tt, &tn).first; + return lookup (var, target_key {&tt, nullptr, nullptr, &tn, nullopt}); } lookup_type @@ -150,15 +158,20 @@ namespace build2 const target_type& tt, const string& tn, const target_type& gt, const string& gn) const { - return lookup (var, &tt, &tn, >, &gn).first; + return lookup (var, + target_key {&tt, nullptr, nullptr, &tn, nullopt}, + target_key {>, nullptr, nullptr, &gn, nullopt}); } + // Note that target keys may be incomplete (only type and name must be + // present plus dir for dir{} and fsdir{} targets if name is empty). + // pair<lookup_type, size_t> lookup (const variable& var, - const target_type* tt = nullptr, const string* tn = nullptr, - const target_type* gt = nullptr, const string* gn = nullptr) const + const target_key* tk = nullptr, + const target_key* gk = nullptr) const { - auto p (lookup_original (var, tt, tn, gt, gn)); + auto p (lookup_original (var, tk, gk)); return var.overrides == nullptr ? p : lookup_override (var, move (p)); } @@ -166,11 +179,10 @@ namespace build2 // can be used to skip a number of initial lookups. // pair<lookup_type, size_t> - lookup_original ( - const variable&, - const target_type* tt = nullptr, const string* tn = nullptr, - const target_type* gt = nullptr, const string* gn = nullptr, - size_t start_depth = 1) const; + lookup_original (const variable&, + const target_key* tk = nullptr, + const target_key* gk = nullptr, + size_t start_depth = 1) const; pair<lookup_type, size_t> lookup_override (const variable& var, |