diff options
| author | Dylan Baker <dylan@pnwbakers.com> | 2025-04-21 08:40:23 -0700 |
|---|---|---|
| committer | Eli Schwartz <eschwartz93@gmail.com> | 2025-04-23 16:56:42 -0400 |
| commit | 2e8a804a009d5ee0c4bfba8bf629ace3a28c6e14 (patch) | |
| tree | 4ba4479e7ca477920ba1dfebf3917b6ff24d145b /mesonbuild/interpreter/interpreter.py | |
| parent | 84a2bc483a1e276249e285e95a2884c8b1245c2f (diff) | |
| download | meson-2e8a804a009d5ee0c4bfba8bf629ace3a28c6e14.tar.gz | |
interpreter: fix interaction between option refactor and b_sanitize
If we return the default value of the `b_sanitize` option, it won't go
through the conversion back to string. This shows up in the ClangCL
implementation.
Fixes: #14501
Diffstat (limited to 'mesonbuild/interpreter/interpreter.py')
| -rw-r--r-- | mesonbuild/interpreter/interpreter.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py index 04de6fc6b..185bb07ee 100644 --- a/mesonbuild/interpreter/interpreter.py +++ b/mesonbuild/interpreter/interpreter.py @@ -1069,6 +1069,9 @@ 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: optkey = options.OptionKey(optname, self.subproject) value_object, value = self.coredata.optstore.get_value_object_and_value_for(optkey) @@ -1076,7 +1079,14 @@ 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. - return self.coredata.optstore.get_default_for_b_option(optkey) + # + # 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 else: if self.subproject: raise MesonException(f'Option {optname} does not exist for subproject {self.subproject}.') @@ -1087,7 +1097,7 @@ class Interpreter(InterpreterBase, HoldableObject): ocopy.value = value return ocopy elif optname == 'b_sanitize': - assert isinstance(value_object, options.UserStringArrayOption) + assert value_object is None or 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 @@ -1096,7 +1106,7 @@ class Interpreter(InterpreterBase, HoldableObject): return 'none' return ','.join(sorted(value)) - if isinstance(value_object.value, str): + if isinstance(value, str): return P_OBJ.OptionString(value, f'{{{optname}}}') return value |
