diff options
Diffstat (limited to 'mesonbuild')
-rw-r--r-- | mesonbuild/coredata.py | 15 | ||||
-rw-r--r-- | mesonbuild/optinterpreter.py | 7 |
2 files changed, 18 insertions, 4 deletions
diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py index cf06ac6..b9a4828 100644 --- a/mesonbuild/coredata.py +++ b/mesonbuild/coredata.py @@ -81,7 +81,7 @@ class UserOption(T.Generic[_T], HoldableObject): if not isinstance(yielding, bool): raise MesonException('Value of "yielding" must be a boolean.') self.yielding = yielding - self.deprecated: T.Union[bool, T.Dict[str, str], T.List[str]] = False + self.deprecated: T.Union[bool, str, T.Dict[str, str], T.List[str]] = False def listify(self, value: T.Any) -> T.List[T.Any]: return [value] @@ -660,6 +660,19 @@ class CoreData: return v newvalue = [replace(v) for v in opt.listify(value)] value = ','.join(newvalue) + elif isinstance(opt.deprecated, str): + # Option is deprecated and replaced by another. Note that a project + # option could be replaced by a built-in or module option, which is + # why we use OptionKey.from_string(newname) instead of + # key.evolve(newname). We set the value on both the old and new names, + # assuming they accept the same value. That could for example be + # achieved by adding the values from old option as deprecated on the + # new option, for example in the case of boolean option is replaced + # by a feature option with a different name. + newname = opt.deprecated + newkey = OptionKey.from_string(newname).evolve(subproject=key.subproject) + mlog.deprecation(f'Option {key.name!r} is replaced by {newname!r}') + self.set_option(newkey, value) opt.set_value(value) diff --git a/mesonbuild/optinterpreter.py b/mesonbuild/optinterpreter.py index eeb7cf8..549d564 100644 --- a/mesonbuild/optinterpreter.py +++ b/mesonbuild/optinterpreter.py @@ -32,7 +32,7 @@ if T.TYPE_CHECKING: 'value': object, 'min': T.Optional[int], 'max': T.Optional[int], - 'deprecated': T.Union[bool, T.Dict[str, str], T.List[str]], + 'deprecated': T.Union[bool, str, T.Dict[str, str], T.List[str]], }) ParserArgs = TypedDict('ParserArgs', { 'yield': bool, @@ -153,7 +153,7 @@ class OptionInterpreter: KwargInfo('value', object), KwargInfo('min', (int, type(None))), KwargInfo('max', (int, type(None))), - KwargInfo('deprecated', (bool, ContainerTypeInfo(dict, str), ContainerTypeInfo(list, str)), + KwargInfo('deprecated', (bool, str, ContainerTypeInfo(dict, str), ContainerTypeInfo(list, str)), default=False, since='0.60.0') ) @typed_pos_args('option', str) @@ -177,7 +177,8 @@ class OptionInterpreter: parser_kwargs = {k: v for k, v in kwargs.items() if k in known_parser_kwargs and v is not None} opt = parser(description, T.cast('ParserArgs', parser_kwargs)) opt.deprecated = kwargs['deprecated'] - + if isinstance(opt.deprecated, str): + FeatureNew.single_use('String value to "deprecated" keyword argument', '0.63.0', self.subproject) if key in self.options: mlog.deprecation(f'Option {opt_name} already exists.') self.options[key] = opt |