diff options
author | Paulo Antonio Alvarez <pauloaalvarez@gmail.com> | 2017-10-04 21:04:51 -0300 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2017-10-31 22:17:01 +0200 |
commit | 1540e615f13503722f1067c693f3d394218cbd9e (patch) | |
tree | e7548d21d121894ade5ad9c82f30eb17d7b3c7f8 | |
parent | 7b9843da02acb6e37de17218748a9af8f472c8e5 (diff) | |
download | meson-1540e615f13503722f1067c693f3d394218cbd9e.zip meson-1540e615f13503722f1067c693f3d394218cbd9e.tar.gz meson-1540e615f13503722f1067c693f3d394218cbd9e.tar.bz2 |
interpreter: Add warning function
-rw-r--r-- | docs/markdown/Reference-manual.md | 8 | ||||
-rw-r--r-- | docs/markdown/snippets/warning_function | 6 | ||||
-rw-r--r-- | mesonbuild/interpreter.py | 14 |
3 files changed, 26 insertions, 2 deletions
diff --git a/docs/markdown/Reference-manual.md b/docs/markdown/Reference-manual.md index 42d02e1..ba86e48 100644 --- a/docs/markdown/Reference-manual.md +++ b/docs/markdown/Reference-manual.md @@ -847,6 +847,14 @@ The keyword arguments for this are the same as for [`executable`](#executable) w This function prints its argument to stdout. +### warning() + +``` meson + void warning(text) +``` + +This function prints its argument to stdout prefixed with WARNING:. + ### project() ``` meson diff --git a/docs/markdown/snippets/warning_function b/docs/markdown/snippets/warning_function new file mode 100644 index 0000000..537651e --- /dev/null +++ b/docs/markdown/snippets/warning_function @@ -0,0 +1,6 @@ +# Added warning function + +This function prints its argument to the console prefixed by "WARNING:" in +yellow color. A simple example: + +warning('foo is deprecated, please use bar instead') diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 39c0de6..28cb5ad 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -1443,6 +1443,7 @@ class Interpreter(InterpreterBase): 'join_paths': self.func_join_paths, 'library': self.func_library, 'message': self.func_message, + 'warning': self.func_warning, 'option': self.func_option, 'project': self.func_project, 'run_target': self.func_run_target, @@ -1869,8 +1870,7 @@ to directly access options of other subprojects.''') def func_add_languages(self, node, args, kwargs): return self.add_languages(args, kwargs.get('required', True)) - @noKwargs - def func_message(self, node, args, kwargs): + def get_message_string_arg(self, node): # reduce arguments again to avoid flattening posargs (posargs, _) = self.reduce_arguments(node.args) if len(posargs) != 1: @@ -1886,9 +1886,19 @@ to directly access options of other subprojects.''') else: raise InvalidArguments('Function accepts only strings, integers, lists and lists thereof.') + return argstr + + @noKwargs + def func_message(self, node, args, kwargs): + argstr = self.get_message_string_arg(node) mlog.log(mlog.bold('Message:'), argstr) @noKwargs + def func_warning(self, node, args, kwargs): + argstr = self.get_message_string_arg(node) + mlog.warning(argstr) + + @noKwargs def func_error(self, node, args, kwargs): self.validate_arguments(args, 1, [str]) raise InterpreterException('Error encountered: ' + args[0]) |