aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/coredata.py
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2019-04-04 13:55:17 -0700
committerDylan Baker <dylan@pnwbakers.com>2019-04-04 15:02:20 -0700
commit5aa2219f50685b24e933960455cd279dd7af801d (patch)
treef679cb7aed59bd5085b09d337c8cd7cb90bfc26d /mesonbuild/coredata.py
parent1e5496d1ba949bdb9422e6c476014e079320f788 (diff)
downloadmeson-5aa2219f50685b24e933960455cd279dd7af801d.zip
meson-5aa2219f50685b24e933960455cd279dd7af801d.tar.gz
meson-5aa2219f50685b24e933960455cd279dd7af801d.tar.bz2
coredata: pull get_builtin_option_choices into BuiltinOption
We can remove some guards here since we know the object will have certain attributes.
Diffstat (limited to 'mesonbuild/coredata.py')
-rw-r--r--mesonbuild/coredata.py21
1 files changed, 8 insertions, 13 deletions
diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py
index 9fa1317..a662ce5 100644
--- a/mesonbuild/coredata.py
+++ b/mesonbuild/coredata.py
@@ -654,18 +654,6 @@ def save(obj, build_dir):
os.replace(tempfilename, filename)
return filename
-def get_builtin_option_choices(optname):
- if optname in builtin_options:
- b = builtin_options[optname]
- if b.opt_type is UserBooleanOption:
- return [True, False]
- elif b.opt_type is UserFeatureOption:
- return UserFeatureOption.static_choices
- else:
- return b.choices
- else:
- raise RuntimeError('Tried to get the supported values for an unknown builtin option \'%s\'.' % optname)
-
def get_builtin_option_default(optname, prefix=''):
if optname in builtin_options:
o = builtin_options[optname]
@@ -693,7 +681,7 @@ def add_builtin_argument(p, name):
kwargs = {}
- c = get_builtin_option_choices(name)
+ c = builtin.argparse_choices()
b = builtin.argparse_action()
h = builtin.description
if not b:
@@ -770,6 +758,13 @@ class BuiltinOption(Generic[_U]):
return 'store_true'
return None
+ def argparse_choices(self) -> Any:
+ if self.opt_type is UserBooleanOption:
+ return [True, False]
+ elif self.opt_type is UserFeatureOption:
+ return UserFeatureOption.static_choices
+ return self.choices
+
builtin_options = {
'buildtype': BuiltinOption(UserComboOption, 'Build type to use', 'debug',