|
|
5515ae |
From b705e45c48b79348bbb70fddc06b408a19ecedc7 Mon Sep 17 00:00:00 2001
|
|
|
5515ae |
From: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
5515ae |
Date: Wed, 2 Nov 2022 10:08:52 +0100
|
|
|
5515ae |
Subject: [PATCH 3/9] Revert "coredata: throw a MesonException on unknown
|
|
|
5515ae |
options"
|
|
|
5515ae |
Content-Type: text/plain
|
|
|
5515ae |
|
|
|
5515ae |
This reverts commit dbf2ace6ca1ce39aa01497f815b65856079cc581.
|
|
|
5515ae |
---
|
|
|
5515ae |
mesonbuild/coredata.py | 15 ++++++++-------
|
|
|
5515ae |
unittests/allplatformstests.py | 8 +++-----
|
|
|
5515ae |
2 files changed, 11 insertions(+), 12 deletions(-)
|
|
|
5515ae |
|
|
|
5515ae |
diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py
|
|
|
5515ae |
index f34694281..b274a5777 100644
|
|
|
5515ae |
--- a/mesonbuild/coredata.py
|
|
|
5515ae |
+++ b/mesonbuild/coredata.py
|
|
|
5515ae |
@@ -803,7 +803,7 @@ class CoreData:
|
|
|
5515ae |
except KeyError:
|
|
|
5515ae |
continue
|
|
|
5515ae |
|
|
|
5515ae |
- def set_options(self, options: T.Dict[OptionKey, T.Any], subproject: str = '') -> None:
|
|
|
5515ae |
+ def set_options(self, options: T.Dict[OptionKey, T.Any], subproject: str = '', warn_unknown: bool = True) -> None:
|
|
|
5515ae |
if not self.is_cross_build():
|
|
|
5515ae |
options = {k: v for k, v in options.items() if k.machine is not MachineChoice.BUILD}
|
|
|
5515ae |
# Set prefix first because it's needed to sanitize other options
|
|
|
5515ae |
@@ -819,15 +819,16 @@ class CoreData:
|
|
|
5515ae |
for k, v in options.items():
|
|
|
5515ae |
if k == pfk:
|
|
|
5515ae |
continue
|
|
|
5515ae |
- elif k in self.options:
|
|
|
5515ae |
- self.set_option(k, v)
|
|
|
5515ae |
- elif k.machine != MachineChoice.BUILD:
|
|
|
5515ae |
+ elif k not in self.options:
|
|
|
5515ae |
unknown_options.append(k)
|
|
|
5515ae |
- if unknown_options:
|
|
|
5515ae |
+ else:
|
|
|
5515ae |
+ self.set_option(k, v)
|
|
|
5515ae |
+ if unknown_options and warn_unknown:
|
|
|
5515ae |
unknown_options_str = ', '.join(sorted(str(s) for s in unknown_options))
|
|
|
5515ae |
sub = f'In subproject {subproject}: ' if subproject else ''
|
|
|
5515ae |
- raise MesonException(f'{sub}Unknown options: "{unknown_options_str}"')
|
|
|
5515ae |
-
|
|
|
5515ae |
+ mlog.warning(f'{sub}Unknown options: "{unknown_options_str}"')
|
|
|
5515ae |
+ mlog.log('The value of new options can be set with:')
|
|
|
5515ae |
+ mlog.log(mlog.bold('meson setup <builddir> --reconfigure -Dnew_option=new_value ...'))
|
|
|
5515ae |
if not self.is_cross_build():
|
|
|
5515ae |
self.copy_build_options_from_regular_ones()
|
|
|
5515ae |
|
|
|
5515ae |
diff --git a/unittests/allplatformstests.py b/unittests/allplatformstests.py
|
|
|
5515ae |
index 6ba95b652..f848cc547 100644
|
|
|
5515ae |
--- a/unittests/allplatformstests.py
|
|
|
5515ae |
+++ b/unittests/allplatformstests.py
|
|
|
5515ae |
@@ -2297,11 +2297,9 @@ class AllPlatformTests(BasePlatformTests):
|
|
|
5515ae |
self.assertEqual(obj.options[OptionKey('default_library')].value, 'shared')
|
|
|
5515ae |
self.wipe()
|
|
|
5515ae |
|
|
|
5515ae |
- # Should fail on unknown options
|
|
|
5515ae |
- with self.assertRaises((subprocess.CalledProcessError, RuntimeError)) as cm:
|
|
|
5515ae |
- self.init(testdir, extra_args=['-Dbad=1', '-Dfoo=2', '-Dwrong_link_args=foo'])
|
|
|
5515ae |
- self.assertNotEqual(0, cm.exception.returncode)
|
|
|
5515ae |
- self.assertIn(msg, cm.exception.output)
|
|
|
5515ae |
+ # Should warn on unknown options
|
|
|
5515ae |
+ out = self.init(testdir, extra_args=['-Dbad=1', '-Dfoo=2', '-Dwrong_link_args=foo'])
|
|
|
5515ae |
+ self.assertIn('Unknown options: "bad, foo, wrong_link_args"', out)
|
|
|
5515ae |
self.wipe()
|
|
|
5515ae |
|
|
|
5515ae |
# Should fail on malformed option
|
|
|
5515ae |
--
|
|
|
5515ae |
2.38.1
|
|
|
5515ae |
|