aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2016-11-06 09:09:36 -0800
committerGitHub <noreply@github.com>2016-11-06 09:09:36 -0800
commit90f5af8a90df5e8aa5a22a9d42e252703ee7f77d (patch)
tree83a96ccd27f7031435245e9f602298b1b74bdf69
parentd37bbef41163d211cf5e80628d15c4d03690e183 (diff)
parent52b589fd55b9fdd62bc07ebc958b3bea2908ac96 (diff)
downloadmeson-90f5af8a90df5e8aa5a22a9d42e252703ee7f77d.zip
meson-90f5af8a90df5e8aa5a22a9d42e252703ee7f77d.tar.gz
meson-90f5af8a90df5e8aa5a22a9d42e252703ee7f77d.tar.bz2
Merge pull request #950 from centricular/fix-dependency-subproject-exceptions
Don't ignore invalid code related to subproject calls
-rw-r--r--mesonbuild/interpreter.py18
-rw-r--r--test cases/failing/34 non-root subproject/meson.build3
-rw-r--r--test cases/failing/34 non-root subproject/some/meson.build1
3 files changed, 15 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:
diff --git a/test cases/failing/34 non-root subproject/meson.build b/test cases/failing/34 non-root subproject/meson.build
new file mode 100644
index 0000000..c84dce7
--- /dev/null
+++ b/test cases/failing/34 non-root subproject/meson.build
@@ -0,0 +1,3 @@
+project('non-root subproject', 'c')
+
+subdir('some')
diff --git a/test cases/failing/34 non-root subproject/some/meson.build b/test cases/failing/34 non-root subproject/some/meson.build
new file mode 100644
index 0000000..d82f451
--- /dev/null
+++ b/test cases/failing/34 non-root subproject/some/meson.build
@@ -0,0 +1 @@
+dependency('definitely-doesnt-exist', fallback : ['someproj', 'some_dep'])