subproject handling: add fix

pull/2581/head
Niklas Claesson 7 years ago
parent d1d2aa2213
commit ba161d42ee
  1. 22
      mesonbuild/interpreter.py

@ -2172,13 +2172,23 @@ to directly access options of other subprojects.''')
# a higher level project, try to use it first.
if 'fallback' in kwargs:
dirname, varname = self.get_subproject_infos(kwargs)
required = kwargs.get('required', True)
wanted = kwargs.get('version', 'undefined')
if not isinstance(required, bool):
raise DependencyException('Keyword "required" must be a boolean.')
if dirname in self.subprojects:
subproject = self.subprojects[dirname]
try:
# Never add fallback deps to self.coredata.deps
return subproject.get_variable_method([varname], {})
except KeyError:
pass
found = self.subprojects[dirname].held_object.project_version
valid_version = wanted == 'undefined' or mesonlib.version_compare(found, wanted)
if required and not valid_version:
m = 'Version {} of {} already loaded, requested incompatible version {}'
raise DependencyException(m.format(found, dirname, wanted))
elif valid_version:
subproject = self.subprojects[dirname]
try:
# Never add fallback deps to self.coredata.deps
return subproject.get_variable_method([varname], {})
except KeyError:
pass
# We need to actually search for this dep
exception = None

Loading…
Cancel
Save