aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElliott Sales de Andrade <quantum.analyst@gmail.com>2022-10-23 21:54:47 -0400
committerXavier Claessens <xclaesse@gmail.com>2022-10-24 11:17:18 +0200
commit9c4d6088b1f061c7cd8dba00eda5e72427ad3d0e (patch)
tree97e8bcdd609a78870c21f580600939ea7a358c69
parent4f4076bfc0dacbc5f804ad2d970054ab43d162b3 (diff)
downloadmeson-9c4d6088b1f061c7cd8dba00eda5e72427ad3d0e.zip
meson-9c4d6088b1f061c7cd8dba00eda5e72427ad3d0e.tar.gz
meson-9c4d6088b1f061c7cd8dba00eda5e72427ad3d0e.tar.bz2
Accept disablers in summary values
They are commonly used as a replacement for a `dependency`, and not accepting them in `summary` breaks the last example in [1] when used as a value. [1] https://mesonbuild.com/Disabler.html#disabling-parts-of-the-build
-rw-r--r--docs/markdown/snippets/summary-disabler.md3
-rw-r--r--mesonbuild/interpreter/interpreter.py5
-rw-r--r--test cases/unit/71 summary/meson.build5
-rw-r--r--unittests/allplatformstests.py5
4 files changed, 13 insertions, 5 deletions
diff --git a/docs/markdown/snippets/summary-disabler.md b/docs/markdown/snippets/summary-disabler.md
new file mode 100644
index 0000000..97b8d0f
--- /dev/null
+++ b/docs/markdown/snippets/summary-disabler.md
@@ -0,0 +1,3 @@
+## `summary()` accepts disablers
+
+Disabler options can be passed to `summary()` as the value to be printed.
diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py
index 7e80d23..7f4c182 100644
--- a/mesonbuild/interpreter/interpreter.py
+++ b/mesonbuild/interpreter/interpreter.py
@@ -166,11 +166,14 @@ class Summary:
elif isinstance(i, (ExternalProgram, Dependency)):
FeatureNew.single_use('dependency or external program in summary', '0.57.0', subproject)
formatted_values.append(i.summary_value())
+ elif isinstance(i, Disabler):
+ FeatureNew.single_use('disabler in summary', '0.64.0', subproject)
+ formatted_values.append(mlog.red('NO'))
elif isinstance(i, coredata.UserOption):
FeatureNew.single_use('feature option in summary', '0.58.0', subproject)
formatted_values.append(i.printable_value())
else:
- m = 'Summary value in section {!r}, key {!r}, must be string, integer, boolean, dependency or external program'
+ m = 'Summary value in section {!r}, key {!r}, must be string, integer, boolean, dependency, disabler, or external program'
raise InterpreterException(m.format(section, k))
self.sections[section][k] = (formatted_values, list_sep)
self.max_key_len = max(self.max_key_len, len(k))
diff --git a/test cases/unit/71 summary/meson.build b/test cases/unit/71 summary/meson.build
index 6e0f69a..ce97fb3 100644
--- a/test cases/unit/71 summary/meson.build
+++ b/test cases/unit/71 summary/meson.build
@@ -15,9 +15,10 @@ summary({'missing prog': find_program('xyzzy', required: false),
'missing dep': dependency('', required: false),
'external dep': dependency('zlib', required: false),
'internal dep': declare_dependency(),
+ 'disabler': disabler(),
}, section: 'Stuff')
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')
+summary('comma list', ['a', 'b', 'c'], list_sep: ', ', section: 'Configuration')
+summary('long comma list', ['alpha', 'alphacolor', 'apetag', 'audiofx', 'audioparsers', 'auparse', 'autodetect', 'avi'], list_sep: ', ', section: 'Plugins')
diff --git a/unittests/allplatformstests.py b/unittests/allplatformstests.py
index 7382f40..0cc1706 100644
--- a/unittests/allplatformstests.py
+++ b/unittests/allplatformstests.py
@@ -3317,7 +3317,7 @@ class AllPlatformTests(BasePlatformTests):
A number : 1
yes : YES
no : NO
- coma list : a, b, c
+ comma list : a, b, c
Stuff
missing prog : NO
@@ -3325,9 +3325,10 @@ class AllPlatformTests(BasePlatformTests):
missing dep : NO
external dep : YES 1.2.3
internal dep : YES
+ disabler : NO
Plugins
- long coma list : alpha, alphacolor, apetag, audiofx, audioparsers, auparse,
+ long comma list: alpha, alphacolor, apetag, audiofx, audioparsers, auparse,
autodetect, avi
Subprojects