pkg-config: Print 'NO' when version is too old

This gives a clearer output when the dependency is not required or has a
fallback subproject otherwise the user is left wondering why the optional
dependency wasn't used or why the fallback subproject is being used.
pull/657/head
Nirbheek Chauhan 8 years ago
parent 48b4defa37
commit baf8481c4f
  1. 20
      mesonbuild/dependencies.py

@ -124,8 +124,7 @@ class PkgConfigDependency(Dependency):
self.modversion = 'none' self.modversion = 'none'
return return
self.modversion = out.decode().strip() self.modversion = out.decode().strip()
mlog.log('%s dependency' % self.type_string, mlog.bold(name), 'found:', found_msg = ['%s dependency' % self.type_string, mlog.bold(name), 'found:']
mlog.green('YES'), self.modversion)
self.version_requirement = kwargs.get('version', None) self.version_requirement = kwargs.get('version', None)
if self.version_requirement is None: if self.version_requirement is None:
self.is_found = True self.is_found = True
@ -133,12 +132,17 @@ class PkgConfigDependency(Dependency):
if not isinstance(self.version_requirement, str): if not isinstance(self.version_requirement, str):
raise DependencyException('Version argument must be string.') raise DependencyException('Version argument must be string.')
self.is_found = mesonlib.version_compare(self.modversion, self.version_requirement) self.is_found = mesonlib.version_compare(self.modversion, self.version_requirement)
if not self.is_found and self.required: if not self.is_found:
raise DependencyException( found_msg += [mlog.red('NO'), 'found {!r}'.format(self.modversion),
'Invalid version of a dependency, needed %s %s found %s.' % 'but need {!r}'.format(self.version_requirement)]
(name, self.version_requirement, self.modversion)) mlog.log(*found_msg)
if not self.is_found: if self.required:
return raise DependencyException(
'Invalid version of a dependency, needed %s %s found %s.' %
(name, self.version_requirement, self.modversion))
return
found_msg += [mlog.green('YES'), self.modversion]
mlog.log(*found_msg)
# Fetch cargs to be used while using this dependency # Fetch cargs to be used while using this dependency
self._set_cargs() self._set_cargs()
# Fetch the libraries and library paths needed for using this # Fetch the libraries and library paths needed for using this

Loading…
Cancel
Save