diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 4f09c0f904fe..abe6d4a66411 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -2012,6 +2012,7 @@ def build_func_dict(self): 'subdir': self.func_subdir, 'subdir_done': self.func_subdir_done, 'subproject': self.func_subproject, + 'summary': self.func_summary, 'shared_library': self.func_shared_lib, 'shared_module': self.func_shared_module, 'static_library': self.func_static_lib, @@ -2606,6 +2607,32 @@ def func_message(self, node, args, kwargs): argstr = self.get_message_string_arg(node) mlog.log(mlog.bold('Message:'), argstr) + @FeatureNew('summary', '0.50.0') + @noKwargs + def func_summary(self, node, args, kwargs): + if len(args) != 1: + raise InterpreterException('Summary accepts exactly one argument.') + arg = args[0] + if not isinstance(arg, dict): + raise InterpreterException('Summary argument must be a dictionary.') + + seen_dict = False + for v in arg.values(): + if isinstance(v, dict): + seen_dict = True + elif seen_dict: + raise InterpreterException('Summary argument values must be exclusively dictionaries or exclusively not dictionaries.') + + mlog.log('') + mlog.log(mlog.bold('Configuration Summary:')) + for s, t in arg.items(): + if isinstance(t, dict): + mlog.log(' ', mlog.bold(s + ':')) + for k, v in t.items(): + mlog.log(' ', k, '=', v) + else: + mlog.log(' ', s, '=', t) + @FeatureNew('warning', '0.44.0') @noKwargs def func_warning(self, node, args, kwargs):