From 3576623b0f46dab27fbb243f6d5595916187642f Mon Sep 17 00:00:00 2001 From: Jon Turney Date: Fri, 1 Jun 2018 01:27:40 +0100 Subject: [PATCH] Consolidate raising a DependencyException() if required but not-found This is now done by find_external_dependency() in all cases I can't help but think this perhaps should be in a few more places... --- mesonbuild/dependencies/base.py | 19 +++---------------- mesonbuild/dependencies/misc.py | 3 --- mesonbuild/dependencies/ui.py | 4 ---- 3 files changed, 3 insertions(+), 23 deletions(-) diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py index 6af11f011..e3faacd63 100644 --- a/mesonbuild/dependencies/base.py +++ b/mesonbuild/dependencies/base.py @@ -392,8 +392,6 @@ class ConfigToolDependency(ExternalDependency): mlog.log('Found', mlog.bold(self.tool_name), repr(req_version), mlog.red('NO')) mlog.log('Dependency', mlog.bold(self.name), 'found:', mlog.red('NO')) - if self.required: - raise DependencyException('Dependency {} not found'.format(self.name)) return False mlog.log('Found {}:'.format(self.tool_name), mlog.bold(shutil.which(self.config)), '({})'.format(version)) @@ -475,9 +473,6 @@ class PkgConfigDependency(ExternalDependency): '{!r}'.format(name, self.pkgbin.get_path())) ret, self.version = self._call_pkgbin(['--modversion', name]) if ret != 0: - if self.required: - raise DependencyException('{} dependency {!r} not found' - ''.format(self.type_string, name)) return found_msg = [self.type_string + ' dependency', mlog.bold(name), 'found:'] if self.version_reqs is None: @@ -826,8 +821,6 @@ class DubDependency(ExternalDependency): ret, res = self._call_dubbin(['describe', name]) if ret != 0: - if self.required: - raise DependencyException('Dependency {!r} not found'.format(name)) self.is_found = False mlog.log('Dependency', mlog.bold(name), 'found:', mlog.red('NO')) return @@ -840,8 +833,6 @@ class DubDependency(ExternalDependency): msg = ['Dependency', mlog.bold(name), 'found but it was compiled with'] msg += [mlog.bold(j['compiler']), 'and we are using', mlog.bold(comp)] mlog.error(*msg) - if self.required: - raise DependencyException('Dependency {!r} not found'.format(name)) self.is_found = False mlog.log('Dependency', mlog.bold(name), 'found:', mlog.red('NO')) return @@ -897,11 +888,9 @@ class DubDependency(ExternalDependency): self.link_args.append(file) if not found: - if self.required: - raise DependencyException('Dependency {!r} not found'.format(name)) - self.is_found = False - mlog.log('Dependency', mlog.bold(name), 'found:', mlog.red('NO')) - return + self.is_found = False + mlog.log('Dependency', mlog.bold(name), 'found:', mlog.red('NO')) + return if not self.silent: mlog.log(*found_msg) @@ -1249,8 +1238,6 @@ class ExtraFrameworkDependency(ExternalDependency): self.name = d self.is_found = True return - if not self.found() and self.required: - raise DependencyException('Framework dependency %s not found.' % (name, )) def get_version(self): return 'unknown' diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py index bf6018612..389157a3f 100644 --- a/mesonbuild/dependencies/misc.py +++ b/mesonbuild/dependencies/misc.py @@ -38,7 +38,6 @@ class MPIDependency(ExternalDependency): def __init__(self, environment, kwargs): language = kwargs.get('language', 'c') super().__init__('mpi', environment, language, kwargs) - required = kwargs.pop('required', True) kwargs['required'] = False kwargs['silent'] = True self.is_found = False @@ -108,8 +107,6 @@ class MPIDependency(ExternalDependency): mlog.log('Dependency', mlog.bold(self.name), 'for', self.language, 'found:', mlog.green('YES'), self.version) else: mlog.log('Dependency', mlog.bold(self.name), 'for', self.language, 'found:', mlog.red('NO')) - if required: - raise DependencyException('MPI dependency {!r} not found'.format(self.name)) def _filter_compile_args(self, args): """ diff --git a/mesonbuild/dependencies/ui.py b/mesonbuild/dependencies/ui.py index ca7db3fef..904c37f44 100644 --- a/mesonbuild/dependencies/ui.py +++ b/mesonbuild/dependencies/ui.py @@ -227,10 +227,6 @@ class QtBaseDependency(ExternalDependency): self.link_args = [] from_text = '(checked {})'.format(mlog.format_list(methods)) self.version = 'none' - if self.required: - err_msg = '{} {} dependency not found {}' \ - ''.format(self.qtname, type_text, from_text) - raise DependencyException(err_msg) if not self.silent: mlog.log(found_msg.format(from_text), mlog.red('NO')) return