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