aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2020-11-20 11:41:36 -0800
committerDylan Baker <dylan@pnwbakers.com>2020-11-20 14:48:35 -0800
commit51b361fdbed3955d6f97de59fc9c898fc93c2411 (patch)
treedf384415932fde7ba0b1122cbd1ab72225af7645
parent226945bbc78e7dd96c8645546a85d38cd6fe79e7 (diff)
downloadmeson-51b361fdbed3955d6f97de59fc9c898fc93c2411.zip
meson-51b361fdbed3955d6f97de59fc9c898fc93c2411.tar.gz
meson-51b361fdbed3955d6f97de59fc9c898fc93c2411.tar.bz2
optinterpreter: organize the validation of arguments to be more readable
-rw-r--r--mesonbuild/optinterpreter.py23
1 files changed, 13 insertions, 10 deletions
diff --git a/mesonbuild/optinterpreter.py b/mesonbuild/optinterpreter.py
index c9f999d..0b18f7e 100644
--- a/mesonbuild/optinterpreter.py
+++ b/mesonbuild/optinterpreter.py
@@ -218,16 +218,6 @@ class OptionInterpreter:
raise OptionException('Only calls to option() are allowed in option files.')
(posargs, kwargs) = self.reduce_arguments(node.args)
- if 'yield' in kwargs:
- FeatureNew.single_use('option yield', '0.45.0', self.subproject)
-
- if 'type' not in kwargs:
- raise OptionException('Option call missing mandatory "type" keyword argument')
- opt_type = kwargs.pop('type')
- if not isinstance(opt_type, str):
- raise OptionException('option() type must be a string')
- if opt_type not in option_types:
- raise OptionException('Unknown type %s.' % opt_type)
if len(posargs) != 1:
raise OptionException('Option() must have one (and only one) positional argument')
opt_name = posargs[0]
@@ -239,9 +229,22 @@ class OptionInterpreter:
raise OptionException('Option name %s is reserved.' % opt_name)
if self.subproject != '':
opt_name = self.subproject + ':' + opt_name
+
+ if 'yield' in kwargs:
+ FeatureNew.single_use('option yield', '0.45.0', self.subproject)
+
+ if 'type' not in kwargs:
+ raise OptionException('Option call missing mandatory "type" keyword argument')
+ opt_type = kwargs.pop('type')
+ if not isinstance(opt_type, str):
+ raise OptionException('option() type must be a string')
+ if opt_type not in option_types:
+ raise OptionException('Unknown type %s.' % opt_type)
+
description = kwargs.pop('description', '')
if not isinstance(description, str):
raise OptionException('Option descriptions must be strings.')
+
opt = option_types[opt_type](opt_name, description, kwargs)
if opt.description == '':
opt.description = opt_name