From 68cfe1bb52ffa033796fe87493d0107d77ff9f74 Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Mon, 3 Sep 2018 21:49:58 +0530 Subject: [PATCH] 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. --- mesonbuild/interpreter.py | 9 ++++++++- test cases/common/50 subproject subproject/meson.build | 6 +++++- .../50 subproject subproject/subprojects/c/meson.build | 3 +++ 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 test cases/common/50 subproject subproject/subprojects/c/meson.build diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 9bd21e3aa..98fab7cf4 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -3069,7 +3069,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) @@ -3077,6 +3078,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), diff --git a/test cases/common/50 subproject subproject/meson.build b/test cases/common/50 subproject subproject/meson.build index f7df3611d..d8735a1cd 100644 --- a/test cases/common/50 subproject subproject/meson.build +++ b/test cases/common/50 subproject subproject/meson.build @@ -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) \ No newline at end of file +test('basic', exe) diff --git a/test cases/common/50 subproject subproject/subprojects/c/meson.build b/test cases/common/50 subproject subproject/subprojects/c/meson.build new file mode 100644 index 000000000..97a5be1d0 --- /dev/null +++ b/test cases/common/50 subproject subproject/subprojects/c/meson.build @@ -0,0 +1,3 @@ +project('not-found-dep-subproj', 'c', version : '1.0') + +notfound_dep = dependency('', required : false)