aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2020-01-20 15:04:16 -0500
committerXavier Claessens <xclaesse@gmail.com>2020-01-26 07:51:16 -0500
commitb74ece344fe6d40e1040670a12be1dde3adb71b2 (patch)
tree4a884bc30f7b91437066390139e242922be35322
parentdbad64cf34ba43b24dc2d71bd260f137acc37ea5 (diff)
downloadmeson-b74ece344fe6d40e1040670a12be1dde3adb71b2.zip
meson-b74ece344fe6d40e1040670a12be1dde3adb71b2.tar.gz
meson-b74ece344fe6d40e1040670a12be1dde3adb71b2.tar.bz2
Support multiple args to message() and warning()
-rw-r--r--docs/markdown/Reference-manual.md6
-rw-r--r--docs/markdown/snippets/message_warning_concat.md4
-rw-r--r--mesonbuild/interpreter.py30
-rwxr-xr-xrun_unittests.py8
4 files changed, 33 insertions, 15 deletions
diff --git a/docs/markdown/Reference-manual.md b/docs/markdown/Reference-manual.md
index 57e2bc1..6699d75 100644
--- a/docs/markdown/Reference-manual.md
+++ b/docs/markdown/Reference-manual.md
@@ -1195,6 +1195,9 @@ them for the default behaviour for each platform.
This function prints its argument to stdout.
+**Since 0.54.0** Can take more more than one argument that will be separated by
+space.
+
### warning()
``` meson
@@ -1205,6 +1208,9 @@ This function prints its argument to stdout prefixed with WARNING:.
*Added 0.44.0*
+**Since 0.54.0** Can take more more than one argument that will be separated by
+space.
+
### summary()
``` meson
diff --git a/docs/markdown/snippets/message_warning_concat.md b/docs/markdown/snippets/message_warning_concat.md
new file mode 100644
index 0000000..39e9e6d
--- /dev/null
+++ b/docs/markdown/snippets/message_warning_concat.md
@@ -0,0 +1,4 @@
+## More than one argument to `message()` and `warning()`
+
+Arguments passed to `message()` and `warning()` will be printed separated by
+space.
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index 9f661b6..f1ed2d4 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -2858,13 +2858,7 @@ external dependencies (including libraries) must go to "dependencies".''')
return False
return self.add_languages(args, required)
- def get_message_string_arg(self, node):
- # reduce arguments again to avoid flattening posargs
- (posargs, _) = self.reduce_arguments(node.args)
- if len(posargs) != 1:
- raise InvalidArguments('Expected 1 argument, got %d' % len(posargs))
-
- arg = posargs[0]
+ def get_message_string_arg(self, arg):
if isinstance(arg, list):
argstr = stringifyUserArguments(arg)
elif isinstance(arg, dict):
@@ -2878,13 +2872,16 @@ external dependencies (including libraries) must go to "dependencies".''')
return argstr
+ @noArgsFlattening
@noKwargs
def func_message(self, node, args, kwargs):
- argstr = self.get_message_string_arg(node)
- self.message_impl(argstr)
+ if len(args) > 1:
+ FeatureNew('message with more than one argument', '0.54.0').use(self.subproject)
+ args_str = [self.get_message_string_arg(i) for i in args]
+ self.message_impl(args_str)
- def message_impl(self, argstr):
- mlog.log(mlog.bold('Message:'), argstr)
+ def message_impl(self, args):
+ mlog.log(mlog.bold('Message:'), *args)
@noArgsFlattening
@permittedKwargs({'section', 'bool_yn'})
@@ -2928,11 +2925,14 @@ external dependencies (including libraries) must go to "dependencies".''')
if main_summary:
main_summary.dump()
+ @noArgsFlattening
@FeatureNew('warning', '0.44.0')
@noKwargs
def func_warning(self, node, args, kwargs):
- argstr = self.get_message_string_arg(node)
- mlog.warning(argstr, location=node)
+ if len(args) > 1:
+ FeatureNew('warning with more than one argument', '0.54.0').use(self.subproject)
+ args_str = [self.get_message_string_arg(i) for i in args]
+ mlog.warning(*args_str, location=node)
@noKwargs
def func_error(self, node, args, kwargs):
@@ -3234,10 +3234,10 @@ external dependencies (including libraries) must go to "dependencies".''')
d = self.dependency_impl(name, display_name, kwargs)
except Exception:
if not_found_message:
- self.message_impl(not_found_message)
+ self.message_impl([not_found_message])
raise
if not d.found() and not_found_message:
- self.message_impl(not_found_message)
+ self.message_impl([not_found_message])
return d
def dependency_impl(self, name, display_name, kwargs):
diff --git a/run_unittests.py b/run_unittests.py
index da18a8b..ae12f4e 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -4534,6 +4534,14 @@ class FailureTests(BasePlatformTests):
r"Dependency \'notfound\' not found and fallback is disabled",
extra_args=['--wrap-mode=nofallback'])
+ def test_message(self):
+ self.assertMesonOutputs("message('Array:', ['a', 'b'])",
+ r"Message:.* Array: \['a', 'b'\]")
+
+ def test_warning(self):
+ self.assertMesonOutputs("warning('Array:', ['a', 'b'])",
+ r"WARNING:.* Array: \['a', 'b'\]")
+
@unittest.skipUnless(is_windows() or is_cygwin(), "requires Windows (or Windows via Cygwin)")
class WindowsTests(BasePlatformTests):
'''