aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2017-08-14 20:28:12 +0300
committerJussi Pakkanen <jpakkane@gmail.com>2017-08-14 22:32:29 +0300
commit4a766147fb3f79451d650ef7b94a7e6dfe2c9404 (patch)
tree508da5ff56cc6658f43bec0cd6374ce763c2a23a
parentc8e61f112d8b62388f4fa8ab75e032226a1d4fb8 (diff)
downloadmeson-4a766147fb3f79451d650ef7b94a7e6dfe2c9404.zip
meson-4a766147fb3f79451d650ef7b94a7e6dfe2c9404.tar.gz
meson-4a766147fb3f79451d650ef7b94a7e6dfe2c9404.tar.bz2
Printing unknown kwarg error message no longer crashes the parser.
-rw-r--r--mesonbuild/interpreter.py8
-rw-r--r--mesonbuild/interpreterbase.py14
-rw-r--r--test cases/frameworks/7 gnome/gir/meson.build4
3 files changed, 19 insertions, 7 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index 970ab7c..40ab1fe 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -1015,9 +1015,10 @@ class CompilerHolder(InterpreterObject):
return []
ModuleState = namedtuple('ModuleState', [
- 'build_to_src', 'subdir', 'environment', 'project_name', 'project_version',
- 'backend', 'compilers', 'targets', 'data', 'headers', 'man', 'global_args',
- 'project_args', 'build_machine', 'host_machine', 'target_machine'])
+ 'build_to_src', 'subdir', 'current_lineno', 'environment', 'project_name',
+ 'project_version', 'backend', 'compilers', 'targets', 'data', 'headers',
+ 'man', 'global_args', 'project_args', 'build_machine', 'host_machine',
+ 'target_machine'])
class ModuleHolder(InterpreterObject):
def __init__(self, modname, module, interpreter):
@@ -1040,6 +1041,7 @@ class ModuleHolder(InterpreterObject):
build_to_src=os.path.relpath(self.interpreter.environment.get_source_dir(),
self.interpreter.environment.get_build_dir()),
subdir=self.interpreter.subdir,
+ current_lineno=self.interpreter.current_lineno,
environment=self.interpreter.environment,
project_name=self.interpreter.build.project_name,
project_version=self.interpreter.build.dep_manifest[self.interpreter.active_projectname],
diff --git a/mesonbuild/interpreterbase.py b/mesonbuild/interpreterbase.py
index c075541..d2e2ab3 100644
--- a/mesonbuild/interpreterbase.py
+++ b/mesonbuild/interpreterbase.py
@@ -62,13 +62,19 @@ class permittedKwargs:
def __call__(self, f):
@wraps(f)
- def wrapped(s, node, args, kwargs):
+ def wrapped(s, node_or_state, args, kwargs):
+ if hasattr(s, 'subdir'):
+ subdir = s.subdir
+ lineno = s.current_lineno
+ elif hasattr(node_or_state, 'subdir'):
+ subdir = node_or_state.subdir
+ lineno = node_or_state.current_lineno
for k in kwargs:
if k not in self.permitted:
- fname = os.path.join(s.subdir, environment.build_filename)
+ fname = os.path.join(subdir, environment.build_filename)
mlog.warning('''Passed invalid keyword argument "%s" in %s line %d.
-This will become a hard error in the future.''' % (k, fname, s.current_lineno))
- return f(s, node, args, kwargs)
+This will become a hard error in the future.''' % (k, fname, lineno))
+ return f(s, node_or_state, args, kwargs)
return wrapped
diff --git a/test cases/frameworks/7 gnome/gir/meson.build b/test cases/frameworks/7 gnome/gir/meson.build
index 0b26754..3598b66 100644
--- a/test cases/frameworks/7 gnome/gir/meson.build
+++ b/test cases/frameworks/7 gnome/gir/meson.build
@@ -30,6 +30,10 @@ gnome.generate_gir(
dependencies : [fake_dep, dep1_dep],
install : true,
build_by_default : true,
+ # Test that unknown kwargs do not crash the parser.
+ # Unknown kwargs will eventually become a hard error.
+ # Once that happens remove this.
+ unknown_kwarg : true,
)
test('gobject introspection/c', girexe)