Fix handling of dependency('', fallback: ['subproject', 'dep'])

Also extend a test case to cover this.
pull/3818/head
Jon Turney 7 years ago committed by Nirbheek Chauhan
parent af546b52ca
commit 9efdcfbb8d
  1. 16
      mesonbuild/interpreter.py
  2. 2
      test cases/common/171 not-found dependency/meson.build
  3. 3
      test cases/common/171 not-found dependency/subprojects/trivial/meson.build
  4. 3
      test cases/common/171 not-found dependency/subprojects/trivial/trivial.c

@ -2811,10 +2811,9 @@ external dependencies (including libraries) must go to "dependencies".''')
mlog.log('Dependency', mlog.bold(name), 'skipped: feature', mlog.bold(feature), 'disabled')
return DependencyHolder(NotFoundDependency(self.environment))
if name == '':
if required:
raise InvalidArguments('Dependency is both required and not-found')
return DependencyHolder(NotFoundDependency(self.environment))
# writing just "dependency('')" is an error, because it can only fail
if name == '' and required and 'fallback' not in kwargs:
raise InvalidArguments('Dependency is both required and not-found')
if '<' in name or '>' in name or '=' in name:
raise InvalidArguments('Characters <, > and = are forbidden in dependency names. To specify'
@ -2840,14 +2839,15 @@ external dependencies (including libraries) must go to "dependencies".''')
exception = None
dep = NotFoundDependency(self.environment)
# Search for it outside the project
if self.coredata.wrap_mode != WrapMode.forcefallback or 'fallback' not in kwargs:
# Unless a fallback exists and is forced ...
if self.coredata.wrap_mode == WrapMode.forcefallback and 'fallback' in kwargs:
exception = DependencyException("fallback for %s not found" % name)
# ... search for it outside the project
elif name != '':
try:
dep = dependencies.find_external_dependency(name, self.environment, kwargs)
except DependencyException as e:
exception = e
else:
exception = DependencyException("fallback for %s not found" % name)
# Search inside the projects list
if not dep.found():

@ -9,3 +9,5 @@ assert(dep.type_name() == 'not-found', 'dependency should be of type "not-found"
library('testlib', 'testlib.c', dependencies: [dep])
subdir('sub', if_found: dep)
subdep = dependency('', fallback: ['trivial', 'trivial_dep'])

@ -0,0 +1,3 @@
project('trivial subproject', 'c')
trivial_lib = static_library('trivial', 'trivial.c', install: false)
trivial_dep = declare_dependency(link_with: trivial_lib)
Loading…
Cancel
Save