Support multiple args to message() and warning()
This commit is contained in:
parent
dbad64cf34
commit
b74ece344f
|
@ -1195,6 +1195,9 @@ them for the default behaviour for each platform.
|
||||||
|
|
||||||
This function prints its argument to stdout.
|
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()
|
### warning()
|
||||||
|
|
||||||
``` meson
|
``` meson
|
||||||
|
@ -1205,6 +1208,9 @@ This function prints its argument to stdout prefixed with WARNING:.
|
||||||
|
|
||||||
*Added 0.44.0*
|
*Added 0.44.0*
|
||||||
|
|
||||||
|
**Since 0.54.0** Can take more more than one argument that will be separated by
|
||||||
|
space.
|
||||||
|
|
||||||
### summary()
|
### summary()
|
||||||
|
|
||||||
``` meson
|
``` 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 False
|
||||||
return self.add_languages(args, required)
|
return self.add_languages(args, required)
|
||||||
|
|
||||||
def get_message_string_arg(self, node):
|
def get_message_string_arg(self, arg):
|
||||||
# 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]
|
|
||||||
if isinstance(arg, list):
|
if isinstance(arg, list):
|
||||||
argstr = stringifyUserArguments(arg)
|
argstr = stringifyUserArguments(arg)
|
||||||
elif isinstance(arg, dict):
|
elif isinstance(arg, dict):
|
||||||
|
@ -2878,13 +2872,16 @@ external dependencies (including libraries) must go to "dependencies".''')
|
||||||
|
|
||||||
return argstr
|
return argstr
|
||||||
|
|
||||||
|
@noArgsFlattening
|
||||||
@noKwargs
|
@noKwargs
|
||||||
def func_message(self, node, args, kwargs):
|
def func_message(self, node, args, kwargs):
|
||||||
argstr = self.get_message_string_arg(node)
|
if len(args) > 1:
|
||||||
self.message_impl(argstr)
|
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):
|
def message_impl(self, args):
|
||||||
mlog.log(mlog.bold('Message:'), argstr)
|
mlog.log(mlog.bold('Message:'), *args)
|
||||||
|
|
||||||
@noArgsFlattening
|
@noArgsFlattening
|
||||||
@permittedKwargs({'section', 'bool_yn'})
|
@permittedKwargs({'section', 'bool_yn'})
|
||||||
|
@ -2928,11 +2925,14 @@ external dependencies (including libraries) must go to "dependencies".''')
|
||||||
if main_summary:
|
if main_summary:
|
||||||
main_summary.dump()
|
main_summary.dump()
|
||||||
|
|
||||||
|
@noArgsFlattening
|
||||||
@FeatureNew('warning', '0.44.0')
|
@FeatureNew('warning', '0.44.0')
|
||||||
@noKwargs
|
@noKwargs
|
||||||
def func_warning(self, node, args, kwargs):
|
def func_warning(self, node, args, kwargs):
|
||||||
argstr = self.get_message_string_arg(node)
|
if len(args) > 1:
|
||||||
mlog.warning(argstr, location=node)
|
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
|
@noKwargs
|
||||||
def func_error(self, node, args, kwargs):
|
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)
|
d = self.dependency_impl(name, display_name, kwargs)
|
||||||
except Exception:
|
except Exception:
|
||||||
if not_found_message:
|
if not_found_message:
|
||||||
self.message_impl(not_found_message)
|
self.message_impl([not_found_message])
|
||||||
raise
|
raise
|
||||||
if not d.found() and not_found_message:
|
if not d.found() and not_found_message:
|
||||||
self.message_impl(not_found_message)
|
self.message_impl([not_found_message])
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def dependency_impl(self, name, display_name, kwargs):
|
def dependency_impl(self, name, display_name, kwargs):
|
||||||
|
|
|
@ -4534,6 +4534,14 @@ class FailureTests(BasePlatformTests):
|
||||||
r"Dependency \'notfound\' not found and fallback is disabled",
|
r"Dependency \'notfound\' not found and fallback is disabled",
|
||||||
extra_args=['--wrap-mode=nofallback'])
|
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)")
|
@unittest.skipUnless(is_windows() or is_cygwin(), "requires Windows (or Windows via Cygwin)")
|
||||||
class WindowsTests(BasePlatformTests):
|
class WindowsTests(BasePlatformTests):
|
||||||
'''
|
'''
|
||||||
|
|
Loading…
Reference in New Issue