Interpreter: Fix subdir_done() to exit from inside if/foreach blocks

Closes: #3700.
pull/3708/head
Xavier Claessens 7 years ago committed by Nirbheek Chauhan
parent e581a8937f
commit 2d3bfa0778
  1. 5
      mesonbuild/interpreter.py
  2. 7
      mesonbuild/interpreterbase.py
  3. 4
      test cases/common/188 subdir_done/meson.build

@ -3128,7 +3128,10 @@ root and issuing %s.
except mesonlib.MesonException as me:
me.file = buildfilename
raise me
self.evaluate_codeblock(codeblock)
try:
self.evaluate_codeblock(codeblock)
except SubdirDoneRequest:
pass
self.subdir = prev_subdir
def _get_kwarg_install_mode(self, kwargs):

@ -326,7 +326,10 @@ class InterpreterBase:
def run(self):
# Evaluate everything after the first line, which is project() because
# we already parsed that in self.parse_project()
self.evaluate_codeblock(self.ast, start=1)
try:
self.evaluate_codeblock(self.ast, start=1)
except SubdirDoneRequest:
pass
def evaluate_codeblock(self, node, start=0, end=None):
if node is None:
@ -343,8 +346,6 @@ class InterpreterBase:
try:
self.current_lineno = cur.lineno
self.evaluate_statement(cur)
except SubdirDoneRequest:
break
except Exception as e:
if not(hasattr(e, 'lineno')):
e.lineno = cur.lineno

@ -3,7 +3,9 @@
project('example exit', 'cpp')
subdir_done()
if true
subdir_done()
endif
executable('main', 'main.cpp')
error('Unreachable')

Loading…
Cancel
Save