From baf8481c4f8835b9c9bdaa6e82946ee123127394 Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Thu, 28 Jul 2016 21:11:34 +0530 Subject: [PATCH] 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. --- mesonbuild/dependencies.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/mesonbuild/dependencies.py b/mesonbuild/dependencies.py index bfcc42099..3f1e214df 100644 --- a/mesonbuild/dependencies.py +++ b/mesonbuild/dependencies.py @@ -124,8 +124,7 @@ class PkgConfigDependency(Dependency): self.modversion = 'none' return self.modversion = out.decode().strip() - mlog.log('%s dependency' % self.type_string, mlog.bold(name), 'found:', - mlog.green('YES'), self.modversion) + found_msg = ['%s dependency' % self.type_string, mlog.bold(name), 'found:'] self.version_requirement = kwargs.get('version', None) if self.version_requirement is None: self.is_found = True @@ -133,12 +132,17 @@ class PkgConfigDependency(Dependency): if not isinstance(self.version_requirement, str): raise DependencyException('Version argument must be string.') self.is_found = mesonlib.version_compare(self.modversion, self.version_requirement) - if not self.is_found and self.required: - raise DependencyException( - 'Invalid version of a dependency, needed %s %s found %s.' % - (name, self.version_requirement, self.modversion)) - if not self.is_found: - return + if not self.is_found: + found_msg += [mlog.red('NO'), 'found {!r}'.format(self.modversion), + 'but need {!r}'.format(self.version_requirement)] + mlog.log(*found_msg) + if self.required: + 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 self._set_cargs() # Fetch the libraries and library paths needed for using this