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)
pull/4035/head
Jon Turney 6 years ago
parent 1ffb44fa01
commit 6a4c2d63d7
No known key found for this signature in database
GPG Key ID: C7C86F0370285C81
  1. 24
      mesonbuild/dependencies/base.py
  2. 2
      mesonbuild/dependencies/dev.py
  3. 11
      mesonbuild/dependencies/misc.py
  4. 3
      mesonbuild/dependencies/platform.py
  5. 6
      mesonbuild/dependencies/ui.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):
if self.version:
return self.version
else:
return 'unknown'
def get_exe_args(self, compiler):
return []
@ -283,6 +286,18 @@ class ExternalDependency(Dependency):
return
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) = \
version_compare_many(self.version, self.version_reqs)
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
# 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

@ -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, [])

@ -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):

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

@ -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

Loading…
Cancel
Save