Allow not-required not-found dependencies in subprojects

Closes https://github.com/mesonbuild/meson/issues/1474
pull/1530/head
Nirbheek Chauhan 8 years ago committed by Jussi Pakkanen
parent 905dbd5cd2
commit 98e71e1e65
  1. 10
      mesonbuild/interpreter.py
  2. 4
      test cases/common/95 dep fallback/meson.build

@ -1938,8 +1938,14 @@ class Interpreter(InterpreterBase):
try: try:
dep = self.subprojects[dirname].get_variable_method([varname], {}) dep = self.subprojects[dirname].get_variable_method([varname], {})
except KeyError: except KeyError:
raise InvalidCode('Fallback variable {!r} in the subproject ' if kwargs.get('required', True):
'{!r} does not exist'.format(varname, dirname)) m = 'Fallback variable {!r} in the subproject {!r} does not exist'
raise DependencyException(m.format(varname, dirname))
# If the dependency is not required, don't raise an exception
mlog.log('Also couldn\'t find the dependency', mlog.bold(name),
'in the fallback subproject',
mlog.bold(os.path.join(self.subproject_dir, dirname)))
return None
if not isinstance(dep, DependencyHolder): if not isinstance(dep, DependencyHolder):
raise InvalidCode('Fallback variable {!r} in the subproject {!r} is ' raise InvalidCode('Fallback variable {!r} in the subproject {!r} is '
'not a dependency object.'.format(varname, dirname)) 'not a dependency object.'.format(varname, dirname))

@ -5,7 +5,11 @@ bob = dependency('boblib', fallback : ['boblib', 'bob_dep'], required: false,
if not bob.found() if not bob.found()
error('Bob is actually needed') error('Bob is actually needed')
endif endif
# boblib subproject exists, but sita_dep doesn't exist
sita = dependency('sitalib', fallback : ['boblib', 'sita_dep'], required: false)
# jimmylib subproject doesn't exist
jimmy = dependency('jimmylib', fallback : ['jimmylib', 'jimmy_dep'], required: false) jimmy = dependency('jimmylib', fallback : ['jimmylib', 'jimmy_dep'], required: false)
# dummylib subproject fails to configure
dummy = dependency('dummylib', fallback : ['dummylib', 'dummy_dep'], required: false) dummy = dependency('dummylib', fallback : ['dummylib', 'dummy_dep'], required: false)
gensrc_py = find_program('gensrc.py') gensrc_py = find_program('gensrc.py')

Loading…
Cancel
Save