diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py index 3ece82c4d..04c47019e 100644 --- a/mesonbuild/dependencies/base.py +++ b/mesonbuild/dependencies/base.py @@ -98,7 +98,7 @@ class Dependency: def __init__(self, type_name, kwargs): self.name = "null" - self.version = 'none' + self.version = None self.language = None # None means C-like self.is_found = False self.type_name = type_name @@ -138,7 +138,10 @@ class Dependency: return self.name def get_version(self): - return self.version + if self.version: + return self.version + else: + return 'unknown' def get_exe_args(self, compiler): return [] @@ -283,22 +286,34 @@ class ExternalDependency(Dependency): return if self.version_reqs: - (self.is_found, not_found, found) = \ - version_compare_many(self.version, self.version_reqs) - if not self.is_found: + # an unknown version can never satisfy any requirement + if not self.version: found_msg = ['Dependency', mlog.bold(self.name), 'found:'] - found_msg += [mlog.red('NO'), - 'found {!r} but need:'.format(self.version), - ', '.join(["'{}'".format(e) for e in not_found])] - if found: - found_msg += ['; matched:', - ', '.join(["'{}'".format(e) for e in found])] + found_msg += [mlog.red('NO'), 'unknown version, but need:', + self.version_reqs] mlog.log(*found_msg) if self.required: - m = 'Invalid version of dependency, need {!r} {!r} found {!r}.' - raise DependencyException(m.format(self.name, not_found, self.version)) - return + m = 'Unknown version of dependency {!r}, but need {!r}.' + raise DependencyException(m.format(self.name, self.version_reqs)) + + else: + (self.is_found, not_found, found) = \ + version_compare_many(self.version, self.version_reqs) + if not self.is_found: + found_msg = ['Dependency', mlog.bold(self.name), 'found:'] + found_msg += [mlog.red('NO'), + 'found {!r} but need:'.format(self.version), + ', '.join(["'{}'".format(e) for e in not_found])] + if found: + found_msg += ['; matched:', + ', '.join(["'{}'".format(e) for e in found])] + mlog.log(*found_msg) + + if self.required: + m = 'Invalid version of dependency, need {!r} {!r} found {!r}.' + raise DependencyException(m.format(self.name, not_found, self.version)) + return class NotFoundDependency(Dependency): @@ -400,7 +415,7 @@ class ConfigToolDependency(ExternalDependency): # don't fail with --version, in that case just assume that there is # only one version and return it. if not out: - return (tool, 'none') + return (tool, None) if versions: is_found = version_compare_many(out, versions)[0] # This allows returning a found version without a config tool, @@ -1236,9 +1251,6 @@ class ExtraFrameworkDependency(ExternalDependency): self.is_found = True return - def get_version(self): - return 'unknown' - def log_info(self): return os.path.join(self.path, self.name) @@ -1331,7 +1343,7 @@ def find_external_dependency(name, env, kwargs): if info: info = ', ' + info - mlog.log(type_text, mlog.bold(display_name), details + 'found:', mlog.green('YES'), d.version + info) + mlog.log(type_text, mlog.bold(display_name), details + 'found:', mlog.green('YES'), (d.version if d.version else '') + info) return d diff --git a/mesonbuild/dependencies/dev.py b/mesonbuild/dependencies/dev.py index 0cd3c2bcb..087639107 100644 --- a/mesonbuild/dependencies/dev.py +++ b/mesonbuild/dependencies/dev.py @@ -35,7 +35,6 @@ class GTestDependency(ExternalDependency): self.detect() def detect(self): - self.version = '1.something_maybe' gtest_detect = self.clib_compiler.find_library("gtest", self.env, []) gtest_main_detect = self.clib_compiler.find_library("gtest_main", self.env, []) if gtest_detect and (not self.main or gtest_main_detect): @@ -85,7 +84,6 @@ class GTestDependency(ExternalDependency): class GMockDependency(ExternalDependency): def __init__(self, environment, kwargs): super().__init__('gmock', environment, 'cpp', kwargs) - self.version = '1.something_maybe' # GMock may be a library or just source. # Work with both. gmock_detect = self.clib_compiler.find_library("gmock", self.env, []) diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py index 72bda521d..014be84ab 100644 --- a/mesonbuild/dependencies/misc.py +++ b/mesonbuild/dependencies/misc.py @@ -180,7 +180,7 @@ class MPIDependency(ExternalDependency): if version: version = version.group(0) else: - version = 'none' + version = None return version, cargs, libs @@ -197,7 +197,7 @@ class MPIDependency(ExternalDependency): return args = shlex.split(o) - version = 'none' + version = None return version, args, args @@ -222,11 +222,11 @@ class MPIDependency(ExternalDependency): else: return if self.language == 'fortran': - return ('none', + return (None, ['-I' + incdir, '-I' + os.path.join(incdir, post)], [os.path.join(libdir, 'msmpi.lib'), os.path.join(libdir, 'msmpifec.lib')]) else: - return ('none', + return (None, ['-I' + incdir, '-I' + os.path.join(incdir, post)], [os.path.join(libdir, 'msmpi.lib')]) @@ -274,9 +274,6 @@ class ThreadDependency(ExternalDependency): def need_threads(self): return True - def get_version(self): - return 'unknown' - class Python3Dependency(ExternalDependency): def __init__(self, environment, kwargs): diff --git a/mesonbuild/dependencies/platform.py b/mesonbuild/dependencies/platform.py index e17a2f2d0..0c051563d 100644 --- a/mesonbuild/dependencies/platform.py +++ b/mesonbuild/dependencies/platform.py @@ -34,6 +34,3 @@ class AppleFrameworks(ExternalDependency): self.link_args += ['-framework', f] self.is_found = mesonlib.is_osx() - - def get_version(self): - return 'unknown' diff --git a/mesonbuild/dependencies/ui.py b/mesonbuild/dependencies/ui.py index 34c9fb28f..f19a76d32 100644 --- a/mesonbuild/dependencies/ui.py +++ b/mesonbuild/dependencies/ui.py @@ -44,14 +44,12 @@ class GLDependency(ExternalDependency): # FIXME: Use AppleFrameworks dependency self.link_args = ['-framework', 'OpenGL'] # FIXME: Detect version using self.clib_compiler - self.version = '1' return if mesonlib.is_windows(): self.is_found = True # FIXME: Use self.clib_compiler.find_library() self.link_args = ['-lopengl32'] # FIXME: Detect version using self.clib_compiler - self.version = '1' return @classmethod @@ -224,7 +222,7 @@ class QtBaseDependency(ExternalDependency): self.compile_args = [] self.link_args = [] self.from_text = mlog.format_list(methods) - self.version = 'none' + self.version = None def compilers_detect(self): "Detect Qt (4 or 5) moc, uic, rcc in the specified bindir or in PATH" @@ -557,7 +555,6 @@ class VulkanDependency(ExternalDependency): # TODO: find a way to retrieve the version from the sdk? # Usually it is a part of the path to it (but does not have to be) - self.version = '1' return else: # simply try to guess it, usually works on linux @@ -565,7 +562,6 @@ class VulkanDependency(ExternalDependency): if libs is not None and self.clib_compiler.has_header('vulkan/vulkan.h', '', environment): self.type_name = 'system' self.is_found = True - self.version = 1 # TODO for lib in libs: self.link_args.append(lib) return