Remove duplicated definition of -D cmdline arg
This commit is contained in:
parent
3ad45ef94e
commit
cb5ad2f211
|
@ -437,6 +437,8 @@ def add_builtin_argument(p, name):
|
||||||
def register_builtin_arguments(parser):
|
def register_builtin_arguments(parser):
|
||||||
for n in builtin_options:
|
for n in builtin_options:
|
||||||
add_builtin_argument(parser, n)
|
add_builtin_argument(parser, n)
|
||||||
|
parser.add_argument('-D', action='append', dest='projectoptions', default=[], metavar="option",
|
||||||
|
help='Set the value of an option, can be used several times to set multiple options.')
|
||||||
|
|
||||||
builtin_options = {
|
builtin_options = {
|
||||||
'buildtype': [UserComboOption, 'Build type to use.', ['plain', 'debug', 'debugoptimized', 'release', 'minsize'], 'debug'],
|
'buildtype': [UserComboOption, 'Build type to use.', ['plain', 'debug', 'debugoptimized', 'release', 'minsize'], 'debug'],
|
||||||
|
|
|
@ -21,8 +21,6 @@ def buildparser():
|
||||||
parser = argparse.ArgumentParser(prog='meson configure')
|
parser = argparse.ArgumentParser(prog='meson configure')
|
||||||
coredata.register_builtin_arguments(parser)
|
coredata.register_builtin_arguments(parser)
|
||||||
|
|
||||||
parser.add_argument('-D', action='append', default=[], dest='sets',
|
|
||||||
help='Set an option to the given value.')
|
|
||||||
parser.add_argument('directory', nargs='*')
|
parser.add_argument('directory', nargs='*')
|
||||||
parser.add_argument('--clearcache', action='store_true', default=False,
|
parser.add_argument('--clearcache', action='store_true', default=False,
|
||||||
help='Clear cached state (e.g. found dependencies)')
|
help='Clear cached state (e.g. found dependencies)')
|
||||||
|
@ -35,10 +33,10 @@ def filter_builtin_options(args, original_args):
|
||||||
if not arg.startswith('--') or arg == '--clearcache':
|
if not arg.startswith('--') or arg == '--clearcache':
|
||||||
continue
|
continue
|
||||||
name = arg.lstrip('--').split('=', 1)[0]
|
name = arg.lstrip('--').split('=', 1)[0]
|
||||||
if any([a.startswith(name + '=') for a in args.sets]):
|
if any([a.startswith(name + '=') for a in args.projectoptions]):
|
||||||
raise mesonlib.MesonException(
|
raise mesonlib.MesonException(
|
||||||
'Got argument {0} as both -D{0} and --{0}. Pick one.'.format(name))
|
'Got argument {0} as both -D{0} and --{0}. Pick one.'.format(name))
|
||||||
args.sets.append('{}={}'.format(name, getattr(args, name)))
|
args.projectoptions.append('{}={}'.format(name, getattr(args, name)))
|
||||||
delattr(args, name)
|
delattr(args, name)
|
||||||
|
|
||||||
|
|
||||||
|
@ -255,8 +253,8 @@ def run(args):
|
||||||
try:
|
try:
|
||||||
c = Conf(builddir)
|
c = Conf(builddir)
|
||||||
save = False
|
save = False
|
||||||
if len(options.sets) > 0:
|
if len(options.projectoptions) > 0:
|
||||||
c.set_options(options.sets)
|
c.set_options(options.projectoptions)
|
||||||
save = True
|
save = True
|
||||||
elif options.clearcache:
|
elif options.clearcache:
|
||||||
c.clear_cache()
|
c.clear_cache()
|
||||||
|
|
|
@ -30,8 +30,6 @@ def create_parser():
|
||||||
coredata.register_builtin_arguments(p)
|
coredata.register_builtin_arguments(p)
|
||||||
p.add_argument('--cross-file', default=None,
|
p.add_argument('--cross-file', default=None,
|
||||||
help='File describing cross compilation environment.')
|
help='File describing cross compilation environment.')
|
||||||
p.add_argument('-D', action='append', dest='projectoptions', default=[], metavar="option",
|
|
||||||
help='Set the value of an option, can be used several times to set multiple options.')
|
|
||||||
p.add_argument('-v', '--version', action='version',
|
p.add_argument('-v', '--version', action='version',
|
||||||
version=coredata.version)
|
version=coredata.version)
|
||||||
# See the mesonlib.WrapMode enum for documentation
|
# See the mesonlib.WrapMode enum for documentation
|
||||||
|
|
Loading…
Reference in New Issue