aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/mesonmain.py
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2018-02-06 12:10:32 -0800
committerDylan Baker <dylan@pnwbakers.com>2018-04-17 11:32:26 -0700
commitbbf71d9aa35c46c31e2363590d560f32455ba252 (patch)
treea868eb2b1332fbce2f5fd4a995bf7441c7b9e417 /mesonbuild/mesonmain.py
parent33c5c7e7e9cd5d091943f9b05f348d3a8d06080b (diff)
downloadmeson-bbf71d9aa35c46c31e2363590d560f32455ba252.zip
meson-bbf71d9aa35c46c31e2363590d560f32455ba252.tar.gz
meson-bbf71d9aa35c46c31e2363590d560f32455ba252.tar.bz2
coredata: Add helper for setting action
Currently we manually pass the argparse action, this isn't very DRY, since the builtin_types already has all the data necessary to find that. This adds a new function to determine the action based on the default type.
Diffstat (limited to 'mesonbuild/mesonmain.py')
-rw-r--r--mesonbuild/mesonmain.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/mesonbuild/mesonmain.py b/mesonbuild/mesonmain.py
index daf5907..4b55057 100644
--- a/mesonbuild/mesonmain.py
+++ b/mesonbuild/mesonmain.py
@@ -28,10 +28,12 @@ default_warning = '1'
def add_builtin_argument(p, name, **kwargs):
k = kwargs.get('dest', name.replace('-', '_'))
c = coredata.get_builtin_option_choices(k)
- b = kwargs.get('action', None) in ['store_true', 'store_false']
+ b = coredata.get_builtin_option_action(k)
h = coredata.get_builtin_option_description(k)
if not b:
h = h.rstrip('.') + ' (default: %s).' % coredata.get_builtin_option_default(k)
+ else:
+ kwargs['action'] = b
if c and not b:
kwargs['choices'] = c
default = coredata.get_builtin_option_default(k, noneIfSuppress=True)
@@ -58,14 +60,14 @@ def create_parser():
add_builtin_argument(p, 'sharedstatedir')
add_builtin_argument(p, 'backend')
add_builtin_argument(p, 'buildtype')
- add_builtin_argument(p, 'strip', action='store_true')
+ add_builtin_argument(p, 'strip')
add_builtin_argument(p, 'unity')
- add_builtin_argument(p, 'werror', action='store_true')
+ add_builtin_argument(p, 'werror')
add_builtin_argument(p, 'layout')
add_builtin_argument(p, 'default-library')
add_builtin_argument(p, 'warnlevel', dest='warning_level')
- add_builtin_argument(p, 'stdsplit', action='store_false')
- add_builtin_argument(p, 'errorlogs', action='store_false')
+ add_builtin_argument(p, 'stdsplit')
+ add_builtin_argument(p, 'errorlogs')
p.add_argument('--cross-file', default=None,
help='File describing cross compilation environment.')
p.add_argument('-D', action='append', dest='projectoptions', default=[], metavar="option",