diff options
| -rw-r--r-- | mesonbuild/interpreter/interpreter.py | 13 | ||||
| -rw-r--r-- | mesonbuild/options.py | 4 | ||||
| -rw-r--r-- | unittests/optiontests.py | 5 |
3 files changed, 3 insertions, 19 deletions
diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py index 5013d1829..e37b4e281 100644 --- a/mesonbuild/interpreter/interpreter.py +++ b/mesonbuild/interpreter/interpreter.py @@ -1084,7 +1084,6 @@ class Interpreter(InterpreterBase, HoldableObject): if optname_regex.search(optname.split('.', maxsplit=1)[-1]) is not None: raise InterpreterException(f'Invalid option name {optname!r}') - # Will be None only if the value comes from the default value_object: T.Optional[options.AnyOptionType] try: @@ -1094,14 +1093,8 @@ class Interpreter(InterpreterBase, HoldableObject): if self.coredata.optstore.is_base_option(optkey): # Due to backwards compatibility return the default # option for base options instead of erroring out. - # - # TODO: This will have issues if we expect to return a user FeatureOption - # Of course, there's a bit of a layering violation here in - # that we return a UserFeatureOption, but otherwise the held value - # We probably need a lower level feature thing, or an enum - # instead of strings - value = self.coredata.optstore.get_default_for_b_option(optkey) - value_object = None + value_object = options.COMPILER_BASE_OPTIONS[optkey.evolve(subproject=None, machine=MachineChoice.HOST)] + value = value_object.default else: if self.subproject: raise MesonException(f'Option {optname} does not exist for subproject {self.subproject}.') @@ -1112,7 +1105,7 @@ class Interpreter(InterpreterBase, HoldableObject): ocopy.value = value return ocopy elif optname == 'b_sanitize': - assert value_object is None or isinstance(value_object, options.UserStringArrayOption) + assert isinstance(value_object, options.UserStringArrayOption) # To ensure backwards compatibility this always returns a string. # We may eventually want to introduce a new "format" kwarg that # allows the user to modify this behaviour, but for now this is diff --git a/mesonbuild/options.py b/mesonbuild/options.py index c2026827d..94152f6fc 100644 --- a/mesonbuild/options.py +++ b/mesonbuild/options.py @@ -1150,10 +1150,6 @@ class OptionStore: key = self.ensure_and_validate_key(key) return self.options[key] - def get_default_for_b_option(self, key: OptionKey) -> ElementaryOptionValues: - assert self.is_base_option(key) - return COMPILER_BASE_OPTIONS[key.evolve(subproject=None, machine=MachineChoice.HOST)].default - def remove(self, key: OptionKey) -> None: del self.options[key] try: diff --git a/unittests/optiontests.py b/unittests/optiontests.py index 73d55fe39..617988843 100644 --- a/unittests/optiontests.py +++ b/unittests/optiontests.py @@ -306,11 +306,6 @@ class OptionTests(unittest.TestCase): self.assertEqual(optstore.get_value_for(key), opt_value) self.assertEqual(optstore.get_value_for(key.as_build()), def_value) - def test_b_default(self): - optstore = OptionStore(False) - value = optstore.get_default_for_b_option(OptionKey('b_vscrt')) - self.assertEqual(value, 'from_buildtype') - def test_b_nonexistent(self): optstore = OptionStore(False) self.assertTrue(optstore.accept_as_pending_option(OptionKey('b_ndebug'))) |
