diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2018-04-17 23:29:15 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-17 23:29:15 +0300 |
commit | 1952ef5ae13376084dc277de38ff3a6dafb8e595 (patch) | |
tree | b0ac33ea58e6ef4d92aca54f21d4c924fd43d821 /mesonbuild/mconf.py | |
parent | 8ee1e49ae683cbd7eb10da37327062a490cbee70 (diff) | |
parent | 1c48cc08e09b1ea860a4972b752d4f053433fa6f (diff) | |
download | meson-1952ef5ae13376084dc277de38ff3a6dafb8e595.zip meson-1952ef5ae13376084dc277de38ff3a6dafb8e595.tar.gz meson-1952ef5ae13376084dc277de38ff3a6dafb8e595.tar.bz2 |
Merge pull request #3243 from dcbaker/accept-d-setup
Accept -D for meson level options durring initial configuration
Diffstat (limited to 'mesonbuild/mconf.py')
-rw-r--r-- | mesonbuild/mconf.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/mesonbuild/mconf.py b/mesonbuild/mconf.py index cadd306..9a11332 100644 --- a/mesonbuild/mconf.py +++ b/mesonbuild/mconf.py @@ -19,6 +19,7 @@ from . import (coredata, mesonlib, build) def buildparser(): parser = argparse.ArgumentParser(prog='meson configure') + coredata.register_builtin_arguments(parser) parser.add_argument('-D', action='append', default=[], dest='sets', help='Set an option to the given value.') @@ -28,6 +29,19 @@ def buildparser(): return parser +def filter_builtin_options(args, original_args): + """Filter out any args passed with -- instead of -D.""" + for arg in original_args: + if not arg.startswith('--') or arg == '--clearcache': + continue + name = arg.lstrip('--').split('=', 1)[0] + if any([a.startswith(name + '=') for a in args.sets]): + raise mesonlib.MesonException( + 'Got argument {0} as both -D{0} and --{0}. Pick one.'.format(name)) + args.sets.append('{}={}'.format(name, getattr(args, name))) + delattr(args, name) + + class ConfException(mesonlib.MesonException): pass @@ -229,6 +243,7 @@ def run(args): if not args: args = [os.getcwd()] options = buildparser().parse_args(args) + filter_builtin_options(options, args) if len(options.directory) > 1: print('%s <build directory>' % args[0]) print('If you omit the build directory, the current directory is substituted.') |