From 6ca423e1fc8078aa1e138d94b10386dd9536af23 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Thu, 20 Aug 2020 14:05:40 -0400 Subject: [PATCH] interpreter: Do not get variable on failed subproject Fixes: #7620 --- mesonbuild/interpreter.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 3a61c6674..2924172e3 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -2792,6 +2792,12 @@ external dependencies (including libraries) must go to "dependencies".''') self.subprojects[dirname] = sub return sub + def get_subproject(self, dirname): + sub = self.subprojects.get(dirname) + if sub and sub.found(): + return sub + return None + def do_subproject(self, dirname: str, method: str, kwargs): disabled, required, feature = extract_required_kwarg(kwargs, self.subproject) if disabled: @@ -3518,7 +3524,7 @@ external dependencies (including libraries) must go to "dependencies".''') return DependencyHolder(NotFoundDependency(self.environment), self.subproject) def verify_fallback_consistency(self, dirname, varname, cached_dep): - subi = self.subprojects.get(dirname) + subi = self.get_subproject(dirname) if not cached_dep or not varname or not subi or not cached_dep.found(): return dep = subi.get_variable_method([varname], {}) @@ -3650,7 +3656,7 @@ external dependencies (including libraries) must go to "dependencies".''') # even if the dependency is not required. provider = self.environment.wrap_resolver.find_dep_provider(name) dirname = mesonlib.listify(provider)[0] - if provider and (required or dirname in self.subprojects): + if provider and (required or self.get_subproject(dirname)): kwargs['fallback'] = provider has_fallback = True @@ -3680,8 +3686,7 @@ external dependencies (including libraries) must go to "dependencies".''') # a higher level project, try to use it first. if has_fallback: dirname, varname = self.get_subproject_infos(kwargs) - sub = self.subprojects.get(dirname) - if sub and sub.found(): + if self.get_subproject(dirname): return self.get_subproject_dep(name, display_name, dirname, varname, kwargs) wrap_mode = self.coredata.get_builtin_option('wrap_mode')