Blob Blame History Raw
From b581c800a89afca4788aede2cd4de35d4a4782f5 Mon Sep 17 00:00:00 2001
From: Xavier Claessens <xavier.claessens@collabora.com>
Date: Thu, 26 Apr 2018 21:49:00 -0400
Subject: [PATCH 11/16] Remove duplicated definition of -D cmdline arg

---
 mesonbuild/coredata.py  |  2 ++
 mesonbuild/mconf.py     | 10 ++++------
 mesonbuild/mesonmain.py |  2 --
 3 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py
index dc702d60..93a9e718 100644
--- a/mesonbuild/coredata.py
+++ b/mesonbuild/coredata.py
@@ -413,6 +413,8 @@ def add_builtin_argument(p, name):
 def register_builtin_arguments(parser):
     for n in builtin_options:
         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 = {
     'buildtype':  [UserComboOption, 'Build type to use.', ['plain', 'debug', 'debugoptimized', 'release', 'minsize'], 'debug'],
diff --git a/mesonbuild/mconf.py b/mesonbuild/mconf.py
index c22b98ff..f907d752 100644
--- a/mesonbuild/mconf.py
+++ b/mesonbuild/mconf.py
@@ -22,8 +22,6 @@ 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.')
     parser.add_argument('directory', nargs='*')
     parser.add_argument('--clearcache', action='store_true', default=False,
                         help='Clear cached state (e.g. found dependencies)')
@@ -36,10 +34,10 @@ def filter_builtin_options(args, 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]):
+        if any([a.startswith(name + '=') for a in args.projectoptions]):
             raise mesonlib.MesonException(
                 '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)
 
 
@@ -256,8 +254,8 @@ def run(args):
     try:
         c = Conf(builddir)
         save = False
-        if len(options.sets) > 0:
-            c.set_options(options.sets)
+        if len(options.projectoptions) > 0:
+            c.set_options(options.projectoptions)
             save = True
         elif options.clearcache:
             c.clear_cache()
diff --git a/mesonbuild/mesonmain.py b/mesonbuild/mesonmain.py
index f4fec95a..9dda4af5 100644
--- a/mesonbuild/mesonmain.py
+++ b/mesonbuild/mesonmain.py
@@ -32,8 +32,6 @@ def create_parser():
     coredata.register_builtin_arguments(p)
     p.add_argument('--cross-file', default=None,
                    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',
                    version=coredata.version)
     # See the mesonlib.WrapMode enum for documentation
-- 
2.17.0