Comparison with an unknown dependency version should always fail

Consistently use None to store an unknown dependency version (rather than
'none', 'unknown' or some made up version)
This commit is contained in:
Jon Turney 2018-08-15 00:18:51 +01:00
parent 1ffb44fa01
commit 6a4c2d63d7
No known key found for this signature in database
GPG Key ID: C7C86F0370285C81
5 changed files with 36 additions and 36 deletions

View File

@ -98,7 +98,7 @@ class Dependency:
def __init__(self, type_name, kwargs): def __init__(self, type_name, kwargs):
self.name = "null" self.name = "null"
self.version = 'none' self.version = None
self.language = None # None means C-like self.language = None # None means C-like
self.is_found = False self.is_found = False
self.type_name = type_name self.type_name = type_name
@ -138,7 +138,10 @@ class Dependency:
return self.name return self.name
def get_version(self): def get_version(self):
if self.version:
return self.version return self.version
else:
return 'unknown'
def get_exe_args(self, compiler): def get_exe_args(self, compiler):
return [] return []
@ -283,6 +286,18 @@ class ExternalDependency(Dependency):
return return
if self.version_reqs: if self.version_reqs:
# 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'), 'unknown version, but need:',
self.version_reqs]
mlog.log(*found_msg)
if self.required:
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) = \ (self.is_found, not_found, found) = \
version_compare_many(self.version, self.version_reqs) version_compare_many(self.version, self.version_reqs)
if not self.is_found: if not self.is_found:
@ -400,7 +415,7 @@ class ConfigToolDependency(ExternalDependency):
# don't fail with --version, in that case just assume that there is # don't fail with --version, in that case just assume that there is
# only one version and return it. # only one version and return it.
if not out: if not out:
return (tool, 'none') return (tool, None)
if versions: if versions:
is_found = version_compare_many(out, versions)[0] is_found = version_compare_many(out, versions)[0]
# This allows returning a found version without a config tool, # This allows returning a found version without a config tool,
@ -1236,9 +1251,6 @@ class ExtraFrameworkDependency(ExternalDependency):
self.is_found = True self.is_found = True
return return
def get_version(self):
return 'unknown'
def log_info(self): def log_info(self):
return os.path.join(self.path, self.name) return os.path.join(self.path, self.name)
@ -1331,7 +1343,7 @@ def find_external_dependency(name, env, kwargs):
if info: if info:
info = ', ' + 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 return d

View File

@ -35,7 +35,6 @@ class GTestDependency(ExternalDependency):
self.detect() self.detect()
def detect(self): def detect(self):
self.version = '1.something_maybe'
gtest_detect = self.clib_compiler.find_library("gtest", self.env, []) gtest_detect = self.clib_compiler.find_library("gtest", self.env, [])
gtest_main_detect = self.clib_compiler.find_library("gtest_main", 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): if gtest_detect and (not self.main or gtest_main_detect):
@ -85,7 +84,6 @@ class GTestDependency(ExternalDependency):
class GMockDependency(ExternalDependency): class GMockDependency(ExternalDependency):
def __init__(self, environment, kwargs): def __init__(self, environment, kwargs):
super().__init__('gmock', environment, 'cpp', kwargs) super().__init__('gmock', environment, 'cpp', kwargs)
self.version = '1.something_maybe'
# GMock may be a library or just source. # GMock may be a library or just source.
# Work with both. # Work with both.
gmock_detect = self.clib_compiler.find_library("gmock", self.env, []) gmock_detect = self.clib_compiler.find_library("gmock", self.env, [])

View File

@ -180,7 +180,7 @@ class MPIDependency(ExternalDependency):
if version: if version:
version = version.group(0) version = version.group(0)
else: else:
version = 'none' version = None
return version, cargs, libs return version, cargs, libs
@ -197,7 +197,7 @@ class MPIDependency(ExternalDependency):
return return
args = shlex.split(o) args = shlex.split(o)
version = 'none' version = None
return version, args, args return version, args, args
@ -222,11 +222,11 @@ class MPIDependency(ExternalDependency):
else: else:
return return
if self.language == 'fortran': if self.language == 'fortran':
return ('none', return (None,
['-I' + incdir, '-I' + os.path.join(incdir, post)], ['-I' + incdir, '-I' + os.path.join(incdir, post)],
[os.path.join(libdir, 'msmpi.lib'), os.path.join(libdir, 'msmpifec.lib')]) [os.path.join(libdir, 'msmpi.lib'), os.path.join(libdir, 'msmpifec.lib')])
else: else:
return ('none', return (None,
['-I' + incdir, '-I' + os.path.join(incdir, post)], ['-I' + incdir, '-I' + os.path.join(incdir, post)],
[os.path.join(libdir, 'msmpi.lib')]) [os.path.join(libdir, 'msmpi.lib')])
@ -274,9 +274,6 @@ class ThreadDependency(ExternalDependency):
def need_threads(self): def need_threads(self):
return True return True
def get_version(self):
return 'unknown'
class Python3Dependency(ExternalDependency): class Python3Dependency(ExternalDependency):
def __init__(self, environment, kwargs): def __init__(self, environment, kwargs):

View File

@ -34,6 +34,3 @@ class AppleFrameworks(ExternalDependency):
self.link_args += ['-framework', f] self.link_args += ['-framework', f]
self.is_found = mesonlib.is_osx() self.is_found = mesonlib.is_osx()
def get_version(self):
return 'unknown'

View File

@ -44,14 +44,12 @@ class GLDependency(ExternalDependency):
# FIXME: Use AppleFrameworks dependency # FIXME: Use AppleFrameworks dependency
self.link_args = ['-framework', 'OpenGL'] self.link_args = ['-framework', 'OpenGL']
# FIXME: Detect version using self.clib_compiler # FIXME: Detect version using self.clib_compiler
self.version = '1'
return return
if mesonlib.is_windows(): if mesonlib.is_windows():
self.is_found = True self.is_found = True
# FIXME: Use self.clib_compiler.find_library() # FIXME: Use self.clib_compiler.find_library()
self.link_args = ['-lopengl32'] self.link_args = ['-lopengl32']
# FIXME: Detect version using self.clib_compiler # FIXME: Detect version using self.clib_compiler
self.version = '1'
return return
@classmethod @classmethod
@ -224,7 +222,7 @@ class QtBaseDependency(ExternalDependency):
self.compile_args = [] self.compile_args = []
self.link_args = [] self.link_args = []
self.from_text = mlog.format_list(methods) self.from_text = mlog.format_list(methods)
self.version = 'none' self.version = None
def compilers_detect(self): def compilers_detect(self):
"Detect Qt (4 or 5) moc, uic, rcc in the specified bindir or in PATH" "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? # 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) # Usually it is a part of the path to it (but does not have to be)
self.version = '1'
return return
else: else:
# simply try to guess it, usually works on linux # 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): if libs is not None and self.clib_compiler.has_header('vulkan/vulkan.h', '', environment):
self.type_name = 'system' self.type_name = 'system'
self.is_found = True self.is_found = True
self.version = 1 # TODO
for lib in libs: for lib in libs:
self.link_args.append(lib) self.link_args.append(lib)
return return