interpreter: Do not get variable on failed subproject

Fixes: #7620
pull/7625/head
Xavier Claessens 4 years ago committed by Xavier Claessens
parent abc3b8e9cb
commit 6ca423e1fc
  1. 13
      mesonbuild/interpreter.py

@ -2792,6 +2792,12 @@ external dependencies (including libraries) must go to "dependencies".''')
self.subprojects[dirname] = sub self.subprojects[dirname] = sub
return 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): def do_subproject(self, dirname: str, method: str, kwargs):
disabled, required, feature = extract_required_kwarg(kwargs, self.subproject) disabled, required, feature = extract_required_kwarg(kwargs, self.subproject)
if disabled: if disabled:
@ -3518,7 +3524,7 @@ external dependencies (including libraries) must go to "dependencies".''')
return DependencyHolder(NotFoundDependency(self.environment), self.subproject) return DependencyHolder(NotFoundDependency(self.environment), self.subproject)
def verify_fallback_consistency(self, dirname, varname, cached_dep): 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(): if not cached_dep or not varname or not subi or not cached_dep.found():
return return
dep = subi.get_variable_method([varname], {}) 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. # even if the dependency is not required.
provider = self.environment.wrap_resolver.find_dep_provider(name) provider = self.environment.wrap_resolver.find_dep_provider(name)
dirname = mesonlib.listify(provider)[0] 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 kwargs['fallback'] = provider
has_fallback = True has_fallback = True
@ -3680,8 +3686,7 @@ external dependencies (including libraries) must go to "dependencies".''')
# a higher level project, try to use it first. # a higher level project, try to use it first.
if has_fallback: if has_fallback:
dirname, varname = self.get_subproject_infos(kwargs) dirname, varname = self.get_subproject_infos(kwargs)
sub = self.subprojects.get(dirname) if self.get_subproject(dirname):
if sub and sub.found():
return self.get_subproject_dep(name, display_name, dirname, varname, kwargs) return self.get_subproject_dep(name, display_name, dirname, varname, kwargs)
wrap_mode = self.coredata.get_builtin_option('wrap_mode') wrap_mode = self.coredata.get_builtin_option('wrap_mode')

Loading…
Cancel
Save