From 74212589a797ca75e55f92a522e198915c0dbaf6 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 1 Dec 2015 15:37:04 +0200 Subject: Use 'extension' variable to resolve extension for file{} We now also check target type/pattern-specific variables. So the new usage is: cli{*}: extension = cli --- build/scope.cxx | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'build/scope.cxx') diff --git a/build/scope.cxx b/build/scope.cxx index d407ce0..305950b 100644 --- a/build/scope.cxx +++ b/build/scope.cxx @@ -15,6 +15,8 @@ namespace build lookup scope:: operator[] (const variable& var) const { + using result = build::lookup; + const value* r (nullptr); const scope* s (this); @@ -24,7 +26,27 @@ namespace build break; } - return lookup (r, &s->vars); + return result (r, &s->vars); + } + + lookup scope:: + lookup (const target_type& tt, const string& name, const variable& var) const + { + using result = build::lookup; + + for (const scope* s (this); s != nullptr; s = s->parent_scope ()) + { + if (!s->target_vars.empty ()) + { + if (auto l = s->target_vars.lookup (tt, name, var)) + return l; + } + + if (auto r = s->vars.find (var)) + return result (r, &s->vars); + } + + return result (); } value& scope:: -- cgit v1.1