diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2018-03-15 16:19:13 -0700 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2018-04-17 11:32:26 -0700 |
commit | 1c48cc08e09b1ea860a4972b752d4f053433fa6f (patch) | |
tree | 6cbb0ccdfc73c70479da8a9900537c4a832e9aeb | |
parent | 8120ff9cf75bf35bed049f0624314967f35bae51 (diff) | |
download | meson-1c48cc08e09b1ea860a4972b752d4f053433fa6f.zip meson-1c48cc08e09b1ea860a4972b752d4f053433fa6f.tar.gz meson-1c48cc08e09b1ea860a4972b752d4f053433fa6f.tar.bz2 |
mconf: accept -- options like `meson` does
I'm not really happy about this to be honest, I don't like having both
-- and -D options, I think it's stupid to have two ways to do exactly
the same thing, especially since we then have to validate that someone
hasn't passed the argument both ways.
However, other people want this, so here it is.
Fixes #969
-rw-r--r-- | docs/markdown/snippets/d-options-for-meson-setup.md | 8 | ||||
-rw-r--r-- | mesonbuild/mconf.py | 15 |
2 files changed, 19 insertions, 4 deletions
diff --git a/docs/markdown/snippets/d-options-for-meson-setup.md b/docs/markdown/snippets/d-options-for-meson-setup.md index 90dc452..37afbe0 100644 --- a/docs/markdown/snippets/d-options-for-meson-setup.md +++ b/docs/markdown/snippets/d-options-for-meson-setup.md @@ -1,6 +1,6 @@ -## Meson now accepts -D for builtin arguments at setup time like configure time +## Meson and meson configure now accept the same arguments Previously meson required that builtin arguments (like prefix) be passed as -`--prefix` to `meson` and `-Dprefix` to `meson configure`. Meson now accepts -D -form like meson configure does. `meson configure` still does not accept the -`--prefix` form. +`--prefix` to `meson` and `-Dprefix` to `meson configure`. `meson` now accepts -D +form like `meson configure` has. `meson configure` also accepts the `--prefix` +form, like `meson` has. 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.') |