Support multiple args to message() and warning()

pull/6523/head
Xavier Claessens 5 years ago committed by Xavier Claessens
parent dbad64cf34
commit b74ece344f
  1. 6
      docs/markdown/Reference-manual.md
  2. 4
      docs/markdown/snippets/message_warning_concat.md
  3. 30
      mesonbuild/interpreter.py
  4. 8
      run_unittests.py

@ -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

@ -0,0 +1,4 @@
## More than one argument to `message()` and `warning()`
Arguments passed to `message()` and `warning()` will be printed separated by
space.

@ -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):

@ -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):
'''

Loading…
Cancel
Save