Test + fix for not-found dependency fallback version comparison

Fixes:
meson.build:6:0: ERROR:  Uncomparable version string 'unknown'.

This was previously partially fixed in a8694f4b, which only fixed it
for cached fallback dependencies.
0.47
Nirbheek Chauhan 6 years ago
parent a08a80d83a
commit 1fb631bf8f
  1. 9
      mesonbuild/interpreter.py
  2. 6
      test cases/common/53 subproject subproject/meson.build
  3. 3
      test cases/common/53 subproject subproject/subprojects/c/meson.build

@ -2990,7 +2990,8 @@ root and issuing %s.
msg.append(traceback.format_exc())
mlog.log(*msg)
return None
dep = self.get_subproject_dep(name, dirname, varname, kwargs.get('required', True))
required = kwargs.get('required', True)
dep = self.get_subproject_dep(name, dirname, varname, required)
if not dep:
return None
subproj_path = os.path.join(self.subproject_dir, dirname)
@ -2998,6 +2999,12 @@ root and issuing %s.
if 'version' in kwargs:
wanted = kwargs['version']
found = dep.version_method([], {})
# Don't do a version check if the dependency is not found and not required
if not dep.found_method([], {}) and not required:
subproj_path = os.path.join(self.subproject_dir, dirname)
mlog.log('Dependency', mlog.bold(display_name), 'from subproject',
mlog.bold(subproj_path), 'found:', mlog.red('NO'))
return dep
if not self.check_subproject_version(wanted, found):
mlog.log('Subproject', mlog.bold(subproj_path), 'dependency',
mlog.bold(display_name), 'version is', mlog.bold(found),

@ -3,5 +3,9 @@ project('sub sub', 'c')
a = subproject('a')
lib = a.get_variable('l')
dependency('not-found-dep', required : false,
version : '>=1',
fallback : ['c', 'notfound_dep'])
exe = executable('prog', 'prog.c', link_with : lib)
test('basic', exe)
test('basic', exe)

@ -0,0 +1,3 @@
project('not-found-dep-subproj', 'c', version : '1.0')
notfound_dep = dependency('', required : false)
Loading…
Cancel
Save