aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/interpreter.py
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2016-10-25 11:16:22 +0530
committerNirbheek Chauhan <nirbheek@centricular.com>2016-11-05 03:17:27 +0530
commitfd260eac817c80105597149f615b71323602e949 (patch)
treec7150a3645f0c4e753d17dfb3fbe98a5cf9dbb4a /mesonbuild/interpreter.py
parent314eb5110e14a71939f1535f4271461d9c439b50 (diff)
downloadmeson-fd260eac817c80105597149f615b71323602e949.zip
meson-fd260eac817c80105597149f615b71323602e949.tar.gz
meson-fd260eac817c80105597149f615b71323602e949.tar.bz2
Don't ignore invalid code related to subproject calls
We should only silently return from a dependency() call if the error is transient (old version, wrap failed to download etc), not if the subproject invocation or dependency name are incorrect. For instance, if you use a dependency(..., fallback : ...) call in a meson.build not in the root directory, we would always ignore the call instead of erroring out due to invalid usage. We should consider categorising our exceptions in this manner elsewhere too.
Diffstat (limited to 'mesonbuild/interpreter.py')
-rw-r--r--mesonbuild/interpreter.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index 3044d51..8fa9385 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -1555,7 +1555,7 @@ class Interpreter():
if dirname in self.subproject_stack:
fullstack = self.subproject_stack + [dirname]
incpath = ' => '.join(fullstack)
- raise InterpreterException('Recursive include of subprojects: %s.' % incpath)
+ raise InvalidCode('Recursive include of subprojects: %s.' % incpath)
if dirname in self.subprojects:
return self.subprojects[dirname]
r = wrap.Resolver(os.path.join(self.build.environment.get_source_dir(), self.subproject_dir))
@@ -1908,8 +1908,14 @@ requirements use the version keyword argument instead.''')
def dependency_fallback(self, name, kwargs):
dirname, varname = self.get_subproject_infos(kwargs)
+ # Try to execute the subproject
try:
self.do_subproject(dirname, {})
+ # Invalid code is always an error
+ except InvalidCode:
+ raise
+ # If the subproject execution failed in a non-fatal way, don't raise an
+ # exception; let the caller handle things.
except:
mlog.log('Also couldn\'t find a fallback subproject in',
mlog.bold(os.path.join(self.subproject_dir, dirname)),
@@ -1918,13 +1924,11 @@ requirements use the version keyword argument instead.''')
try:
dep = self.subprojects[dirname].get_variable_method([varname], {})
except KeyError:
- mlog.log('Fallback variable', mlog.bold(varname),
- 'in the subproject', mlog.bold(dirname), 'does not exist')
- return None
+ raise InvalidCode('Fallback variable {!r} in the subproject '
+ '{!r} does not exist'.format(varname, dirname))
if not isinstance(dep, DependencyHolder):
- mlog.log('Fallback variable', mlog.bold(varname),
- 'in the subproject', mlog.bold(dirname),
- 'is not a dependency object.')
+ raise InvalidCode('Fallback variable {!r} in the subproject {!r} is '
+ 'not a dependency object.'.format(varname, dirname))
return None
# Check if the version of the declared dependency matches what we want
if 'version' in kwargs: