diff options
author | Scott D Phillips <scott.d.phillips@intel.com> | 2016-10-13 23:33:54 +0200 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2016-10-17 19:32:09 +0300 |
commit | 08aeac22a98eb17b3857e1885ae8c4b0b47dfeca (patch) | |
tree | 365f3219af7ff82a3b9162bfe5906bd5825aa117 | |
parent | 17ecb4fff489ca7866418c8e4af6b1b87858b730 (diff) | |
download | meson-08aeac22a98eb17b3857e1885ae8c4b0b47dfeca.zip meson-08aeac22a98eb17b3857e1885ae8c4b0b47dfeca.tar.gz meson-08aeac22a98eb17b3857e1885ae8c4b0b47dfeca.tar.bz2 |
Don't raise exception when a fallback dependency is not found
If a fallback dependency is not found just return None. The
caller can then raise the exception it already has if
required=True, or just continue on if required=False.
-rw-r--r-- | authors.txt | 1 | ||||
-rw-r--r-- | mesonbuild/interpreter.py | 20 |
2 files changed, 13 insertions, 8 deletions
diff --git a/authors.txt b/authors.txt index e60e3d0..505e35e 100644 --- a/authors.txt +++ b/authors.txt @@ -48,3 +48,4 @@ Daniel Brendle Franz Zapata Emanuele Aina Guillaume Poirier-Morency +Scott D Phillips diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index da96eb3..6e57107 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -1879,23 +1879,27 @@ class Interpreter(): mlog.log('Also couldn\'t find a fallback subproject in', mlog.bold(os.path.join(self.subproject_dir, dirname)), 'for the dependency', mlog.bold(name)) - if kwargs.get('required', True): - raise - else: - return None + return None try: dep = self.subprojects[dirname].get_variable_method([varname], {}) except KeyError: - raise InterpreterException('Fallback variable {!r} in the subproject {!r} does not exist'.format(varname, dirname)) + mlog.log('Fallback variable', mlog.bold(varname), + 'in the subproject', mlog.bold(dirname), 'does not exist') + return None if not isinstance(dep, DependencyHolder): - raise InterpreterException('Fallback variable {!r} in the subproject {!r} is not a dependency object.'.format(varname, dirname)) + mlog.log('Fallback variable', mlog.bold(varname), + 'in the subproject', mlog.bold(dirname), + 'is not a dependency object.') + return None # Check if the version of the declared dependency matches what we want if 'version' in kwargs: wanted = kwargs['version'] found = dep.version_method([], {}) if found == 'undefined' or not mesonlib.version_compare(found, wanted): - m = 'Subproject "{0}" dependency "{1}" version is "{2}" but "{3}" is required.' - raise InterpreterException(m.format(dirname, varname, found, wanted)) + mlog.log('Subproject', mlog.bold(dirname), 'dependency', + mlog.bold(varname), 'version is', mlog.bold(found), + 'but', mlog.bold(wanted), 'is required.') + return None mlog.log('Found a', mlog.green('fallback'), 'subproject', mlog.bold(os.path.join(self.subproject_dir, dirname)), 'for', mlog.bold(name)) |