summaryrefslogtreecommitdiff
path: root/mesonbuild/coredata.py
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2020-03-07 00:18:40 +0530
committerXavier Claessens <xclaesse@gmail.com>2020-03-11 07:11:59 -0400
commitbd953b6b2977eb9d9afb92208f117dd8845a3088 (patch)
tree337d2d90634de56e9c6619aa655bc2d362e8fe17 /mesonbuild/coredata.py
parentc7aa4c8861eb6c1d3534b3b0e94e901b7b2d0206 (diff)
downloadmeson-bd953b6b2977eb9d9afb92208f117dd8845a3088.tar.gz
coredata: Passing an option is supposed to set it, not flip the default
With the current logic passing `--debug` will actually be parsed as `-Ddebug=false`, which is absolutely not what is expected. There is no case in which the presence of a boolean option in `--foo` form will mean 'I want feature foo disabled', regardless of the *default* value of that option. Also includes a test. Closes https://github.com/mesonbuild/meson/issues/4686
Diffstat (limited to 'mesonbuild/coredata.py')
-rw-r--r--mesonbuild/coredata.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py
index a0df24ded..344da4cc5 100644
--- a/mesonbuild/coredata.py
+++ b/mesonbuild/coredata.py
@@ -1001,9 +1001,10 @@ class BuiltinOption(T.Generic[_T, _U]):
return self.opt_type(self.description, **keywords)
def _argparse_action(self) -> T.Optional[str]:
- if self.default is True:
- return 'store_false'
- elif self.default is False:
+ # If the type is a boolean, the presence of the argument in --foo form
+ # is to enable it. Disabling happens by using -Dfoo=false, which is
+ # parsed under `args.projectoptions` and does not hit this codepath.
+ if isinstance(self.default, bool):
return 'store_true'
return None