summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesonbuild/mesonmain.py4
-rw-r--r--unittests/platformagnostictests.py5
2 files changed, 7 insertions, 2 deletions
diff --git a/mesonbuild/mesonmain.py b/mesonbuild/mesonmain.py
index dd265c41b..ca7a18414 100644
--- a/mesonbuild/mesonmain.py
+++ b/mesonbuild/mesonmain.py
@@ -240,14 +240,14 @@ def validate_original_args(args):
def has_startswith(coll, target):
for entry in coll:
- if entry.startswith(target):
+ if entry.startswith(target + '=') or entry == target:
return True
return False
#ds = [x for x in args if x.startswith('-D')]
#longs = [x for x in args if x.startswith('--')]
for optionkey in itertools.chain(mesonbuild.options.BUILTIN_DIR_OPTIONS, mesonbuild.options.BUILTIN_CORE_OPTIONS):
longarg = mesonbuild.options.argparse_name_to_arg(optionkey.name)
- shortarg = f'-D{optionkey.name}='
+ shortarg = f'-D{optionkey.name}'
if has_startswith(args, longarg) and has_startswith(args, shortarg):
sys.exit(
f'Got argument {optionkey.name} as both {shortarg} and {longarg}. Pick one.')
diff --git a/unittests/platformagnostictests.py b/unittests/platformagnostictests.py
index 6a1ea38be..37ac7ad7a 100644
--- a/unittests/platformagnostictests.py
+++ b/unittests/platformagnostictests.py
@@ -560,3 +560,8 @@ class PlatformAgnosticTests(BasePlatformTests):
self.clean()
self._run(self.mtest_command + ['runner-with-exedep'])
+
+ def test_setup_mixed_long_short_options(self) -> None:
+ """Mixing unity and unity_size as long and short options should work."""
+ testdir = self.copy_srcdir(os.path.join(self.common_test_dir, '1 trivial'))
+ self.init(testdir, extra_args=['-Dunity=on', '--unity-size=123'])