From 726aaab07a785b904dd1265bffa603bdd2a7665b Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 24 May 2021 10:50:28 +0200 Subject: Tie loose ends in target type/pattern-specific matching --- libbuild2/scope.hxx | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) (limited to 'libbuild2/scope.hxx') 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 (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_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_override (const variable& var, -- cgit v1.1