summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesonbuild/mintro.py7
-rw-r--r--mesonbuild/options.py9
2 files changed, 12 insertions, 4 deletions
diff --git a/mesonbuild/mintro.py b/mesonbuild/mintro.py
index b9b09c557..cd68911ce 100644
--- a/mesonbuild/mintro.py
+++ b/mesonbuild/mintro.py
@@ -315,14 +315,15 @@ def list_buildoptions(coredata: cdata.CoreData, subprojects: T.Optional[T.List[s
elif isinstance(opt, options.UserBooleanOption):
typestr = 'boolean'
elif isinstance(opt, options.UserComboOption):
- optdict['choices'] = opt.choices
+ optdict['choices'] = opt.printable_choices()
typestr = 'combo'
elif isinstance(opt, options.UserIntegerOption):
typestr = 'integer'
elif isinstance(opt, options.UserArrayOption):
typestr = 'array'
- if opt.choices:
- optdict['choices'] = opt.choices
+ c = opt.printable_choices()
+ if c:
+ optdict['choices'] = c
else:
raise RuntimeError("Unknown option type")
optdict['type'] = typestr
diff --git a/mesonbuild/options.py b/mesonbuild/options.py
index aea38ec3e..d0cf231dc 100644
--- a/mesonbuild/options.py
+++ b/mesonbuild/options.py
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2013-2024 Contributors to the The Meson project
-# Copyright © 2019-2024 Intel Corporation
+# Copyright © 2019-2025 Intel Corporation
from __future__ import annotations
from collections import OrderedDict
@@ -265,6 +265,13 @@ class UserOption(T.Generic[_T], HoldableObject):
assert isinstance(self.value, (str, int, bool, list))
return self.value
+ def printable_choices(self) -> T.Optional[T.List[str]]:
+ if not self.choices:
+ return None
+ if isinstance(self.choices, str):
+ return [self.choices]
+ return [str(c) for c in self.choices]
+
# Check that the input is a valid value and return the
# "cleaned" or "native" version. For example the Boolean
# option could take the string "true" and return True.