diff options
author | Jon Turney <jon.turney@dronecode.org.uk> | 2020-02-12 17:18:53 +0000 |
---|---|---|
committer | Jon Turney <jon.turney@dronecode.org.uk> | 2020-02-28 11:54:04 +0000 |
commit | 534a974da756c4b71b7ba10a6853c2be14a9b30e (patch) | |
tree | 7585e2faf0d8ef0ae84d3e533c89c2d25d455ddd | |
parent | 4895830c28dda6f009aeaec0663b5bba88b3d1b3 (diff) | |
download | meson-534a974da756c4b71b7ba10a6853c2be14a9b30e.zip meson-534a974da756c4b71b7ba10a6853c2be14a9b30e.tar.gz meson-534a974da756c4b71b7ba10a6853c2be14a9b30e.tar.bz2 |
Adjust all the other places MesonException file attribute is set
A MesonException has file, lineno and colno attributes, which get
formatted as a location in mlog.exception().
The file attribute got changed from a path relative to the root source
directory to a pathname (absolute or relative to cwd) in one place in
commit b8fbbf59. Adjust all the other places the file attribute is set
to match.
Also:
Setting MesonException.file seems to be missing in the case where Parser
returned a non-CodeBlockNode object. Fortunately, that looks like it's
unreachable, but add it just in case.
-rw-r--r-- | mesonbuild/ast/interpreter.py | 2 | ||||
-rw-r--r-- | mesonbuild/interpreter.py | 2 | ||||
-rw-r--r-- | mesonbuild/interpreterbase.py | 2 | ||||
-rw-r--r-- | mesonbuild/optinterpreter.py | 5 |
4 files changed, 6 insertions, 5 deletions
diff --git a/mesonbuild/ast/interpreter.py b/mesonbuild/ast/interpreter.py index b5aade3..bee5165 100644 --- a/mesonbuild/ast/interpreter.py +++ b/mesonbuild/ast/interpreter.py @@ -156,7 +156,7 @@ class AstInterpreter(interpreterbase.InterpreterBase): try: codeblock = mparser.Parser(code, subdir).parse() except mesonlib.MesonException as me: - me.file = buildfilename + me.file = absname raise me self.subdir = subdir diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index c29ed89..bd85577 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -3750,7 +3750,7 @@ This will become a hard error in the future.''' % kwargs['input'], location=self try: codeblock = mparser.Parser(code, self.subdir).parse() except mesonlib.MesonException as me: - me.file = buildfilename + me.file = absname raise me try: self.evaluate_codeblock(codeblock) diff --git a/mesonbuild/interpreterbase.py b/mesonbuild/interpreterbase.py index 2a976d3..842aeac 100644 --- a/mesonbuild/interpreterbase.py +++ b/mesonbuild/interpreterbase.py @@ -432,7 +432,7 @@ class InterpreterBase: if not hasattr(e, 'lineno'): e.lineno = cur.lineno e.colno = cur.colno - e.file = os.path.join(self.subdir, 'meson.build') + e.file = os.path.join(self.source_root, self.subdir, environment.build_filename) raise e i += 1 # In THE FUTURE jump over blocks and stuff. diff --git a/mesonbuild/optinterpreter.py b/mesonbuild/optinterpreter.py index 1a8a04a..2632b31 100644 --- a/mesonbuild/optinterpreter.py +++ b/mesonbuild/optinterpreter.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import os, re +import re import functools import typing as T @@ -147,6 +147,7 @@ class OptionInterpreter: if not isinstance(ast, mparser.CodeBlockNode): e = OptionException('Option file is malformed.') e.lineno = ast.lineno() + e.file = option_file raise e for cur in ast.lines: try: @@ -154,7 +155,7 @@ class OptionInterpreter: except Exception as e: e.lineno = cur.lineno e.colno = cur.colno - e.file = os.path.join('meson_options.txt') + e.file = option_file raise e def reduce_single(self, arg): |