diff options
4 files changed, 16 insertions, 8 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index bf4a1e6..f0e7106 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -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(): diff --git a/test cases/common/171 not-found dependency/meson.build b/test cases/common/171 not-found dependency/meson.build index 85505ee..c1e3a9a 100644 --- a/test cases/common/171 not-found dependency/meson.build +++ b/test cases/common/171 not-found dependency/meson.build @@ -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']) diff --git a/test cases/common/171 not-found dependency/subprojects/trivial/meson.build b/test cases/common/171 not-found dependency/subprojects/trivial/meson.build new file mode 100644 index 0000000..8769c70 --- /dev/null +++ b/test cases/common/171 not-found dependency/subprojects/trivial/meson.build @@ -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) diff --git a/test cases/common/171 not-found dependency/subprojects/trivial/trivial.c b/test cases/common/171 not-found dependency/subprojects/trivial/trivial.c new file mode 100644 index 0000000..35b21e0 --- /dev/null +++ b/test cases/common/171 not-found dependency/subprojects/trivial/trivial.c @@ -0,0 +1,3 @@ +int subfunc() { + return 42; +} |