aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesonbuild/interpreter.py34
-rwxr-xr-xrun_unittests.py4
-rw-r--r--test cases/unit/73 summary/meson.build1
3 files changed, 34 insertions, 5 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index 24c2cc8..df81569 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -1844,10 +1844,18 @@ class Summary:
if bool_yn and isinstance(i, bool):
formatted_values.append(mlog.green('YES') if i else mlog.red('NO'))
else:
- formatted_values.append(i)
+ formatted_values.append(str(i))
self.sections[section][k] = (formatted_values, list_sep)
self.max_key_len = max(self.max_key_len, len(k))
+ def text_len(self, v):
+ if isinstance(v, str):
+ return len(v)
+ elif isinstance(v, mlog.AnsiDecorator):
+ return len(v.text)
+ else:
+ raise RuntimeError('Expecting only strings or AnsiDecorator')
+
def dump(self):
mlog.log(self.project_name, mlog.normal_cyan(self.project_version))
for section, values in self.sections.items():
@@ -1859,12 +1867,28 @@ class Summary:
indent = self.max_key_len - len(k) + 3
end = ' ' if v else ''
mlog.log(' ' * indent, k + ':', end=end)
- if list_sep is None:
- indent = self.max_key_len + 6
- list_sep = '\n' + ' ' * indent
- mlog.log(*v, sep=list_sep)
+ indent = self.max_key_len + 6
+ self.dump_value(v, list_sep, indent)
mlog.log('') # newline
+ def dump_value(self, arr, list_sep, indent):
+ lines_sep = '\n' + ' ' * indent
+ if list_sep is None:
+ mlog.log(*arr, sep=lines_sep)
+ return
+ max_len = shutil.get_terminal_size().columns
+ line = []
+ line_len = indent
+ lines_sep = list_sep.rstrip() + lines_sep
+ for v in arr:
+ v_len = self.text_len(v) + len(list_sep)
+ if line and line_len + v_len > max_len:
+ mlog.log(*line, sep=list_sep, end=lines_sep)
+ line_len = indent
+ line = []
+ line.append(v)
+ line_len += v_len
+ mlog.log(*line, sep=list_sep)
class MesonMain(InterpreterObject):
def __init__(self, build, interpreter):
diff --git a/run_unittests.py b/run_unittests.py
index aba77d5..ff6bb9c 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -4635,6 +4635,10 @@ recommended as it is not supported on some platforms''')
no: NO
coma list: a, b, c
+ Plugins
+ long coma list: alpha, alphacolor, apetag, audiofx, audioparsers, auparse,
+ autodetect, avi
+
Subprojects
sub: YES
sub2: NO Problem encountered: This subproject failed
diff --git a/test cases/unit/73 summary/meson.build b/test cases/unit/73 summary/meson.build
index df4540d..1bc05ca 100644
--- a/test cases/unit/73 summary/meson.build
+++ b/test cases/unit/73 summary/meson.build
@@ -13,3 +13,4 @@ summary('A number', 1, section: 'Configuration')
summary('yes', true, bool_yn : true, section: 'Configuration')
summary('no', false, bool_yn : true, section: 'Configuration')
summary('coma list', ['a', 'b', 'c'], list_sep: ', ', section: 'Configuration')
+summary('long coma list', ['alpha', 'alphacolor', 'apetag', 'audiofx', 'audioparsers', 'auparse', 'autodetect', 'avi'], list_sep: ', ', section: 'Plugins')