aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2022-01-06 15:45:18 -0800
committerEli Schwartz <eschwartz93@gmail.com>2022-01-18 17:53:29 -0500
commit9c7ddf59fee75148153c0a05de727108b74b5ee7 (patch)
tree3e648c79fa1612fbd8565a86f00d5300dad1deaf
parentbf3fa728faf3e759e8d226b5ebb3d9847860cace (diff)
downloadmeson-9c7ddf59fee75148153c0a05de727108b74b5ee7.zip
meson-9c7ddf59fee75148153c0a05de727108b74b5ee7.tar.gz
meson-9c7ddf59fee75148153c0a05de727108b74b5ee7.tar.bz2
interpreterobjects: deprecated passing a number to configuration_data.set10
This is currently allowed, and is used in at least a few projects. It was not intended to work or documented, but it does and since it is in use a full deprecation period must be used. A warning has also been added for values < 0, which have surprising behavior.
-rw-r--r--docs/yaml/objects/cfg_data.yaml13
-rw-r--r--docs/yaml/objects/feature.yaml2
-rw-r--r--mesonbuild/interpreter/interpreterobjects.py8
3 files changed, 20 insertions, 3 deletions
diff --git a/docs/yaml/objects/cfg_data.yaml b/docs/yaml/objects/cfg_data.yaml
index 9a66b73..5cc4b84 100644
--- a/docs/yaml/objects/cfg_data.yaml
+++ b/docs/yaml/objects/cfg_data.yaml
@@ -41,8 +41,17 @@ methods:
type: str
description: The name of the variable to set
value:
- type: bool
- description: The value to set as either `1` or `0`
+ type: bool | int
+ description: |
+ The value to set as either `1` or `0`
+
+ Passing numbers was never intended to work, and since 0.62 it has been
+ deprecated. It will be removed in a future version of Meson. If you
+ need to pass numbers use the `.set` method.
+ warnings:
+ - numeric values < 0 have the surprising behavior of being converted to
+ [[true]], values > 1 have the more expected but unintentional behavior of
+ being interpretered as [[true]].
kwargs_inherit: cfg_data.set
diff --git a/docs/yaml/objects/feature.yaml b/docs/yaml/objects/feature.yaml
index 5b451e5..b6a754b 100644
--- a/docs/yaml/objects/feature.yaml
+++ b/docs/yaml/objects/feature.yaml
@@ -54,7 +54,7 @@ methods:
if get_option('directx').require(host_machine.system() == 'windows',
error_message: 'DirectX only available on Windows').allowed() then
src += ['directx.c']
- config.set10('HAVE_DIRECTX', 1)
+ config.set10('HAVE_DIRECTX', true)
endif
```
diff --git a/mesonbuild/interpreter/interpreterobjects.py b/mesonbuild/interpreter/interpreterobjects.py
index d222bff..9560221 100644
--- a/mesonbuild/interpreter/interpreterobjects.py
+++ b/mesonbuild/interpreter/interpreterobjects.py
@@ -320,6 +320,14 @@ class ConfigurationDataHolder(ObjectHolder[build.ConfigurationData], MutableInte
@typed_kwargs('configuration_data.set10', _CONF_DATA_SET_KWS)
def set10_method(self, args: T.Tuple[str, T.Union[int, bool]], kwargs: 'kwargs.ConfigurationDataSet') -> None:
self.__check_used()
+ if isinstance(args[1], int):
+ mlog.deprecation('configuration_data.set10 with number. the `set10` '
+ 'method should only be used with booleans',
+ location=self.interpreter.current_node)
+ if args[1] < 0:
+ mlog.warning('Passing a number that is less than 0 may not have the intended result, '
+ 'as meson will treat all non-zero values as true.',
+ location=self.interpreter.current_node)
self.held_object.values[args[0]] = (int(args[1]), kwargs['description'])
@typed_pos_args('configuration_data.has', (str, int, bool))