aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/compilers/compilers.py
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2023-02-22 13:10:24 -0800
committerNirbheek Chauhan <nirbheek.chauhan@gmail.com>2023-04-21 15:18:56 +0530
commitbfce5c45a4784d86be8472a00f628f2ffac74cf2 (patch)
tree420ebb65147f91175e9b84bc9dbb50cbf20b8684 /mesonbuild/compilers/compilers.py
parentc0c9f755a40a51889e73275578cb49296de84e43 (diff)
downloadmeson-bfce5c45a4784d86be8472a00f628f2ffac74cf2.zip
meson-bfce5c45a4784d86be8472a00f628f2ffac74cf2.tar.gz
meson-bfce5c45a4784d86be8472a00f628f2ffac74cf2.tar.bz2
compilers: convert method to get assert control to a boolean
C like compilers only off `-DNDEBUG` to disable asserts. This is not a universal paradigm however. Rust, for example has an argument that takes a boolean. To better represent this, we allow passing a `disable` boolean. `disable` was chosen rather than `enable` because it allowed all existing logic to be left in place
Diffstat (limited to 'mesonbuild/compilers/compilers.py')
-rw-r--r--mesonbuild/compilers/compilers.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py
index 2f3086a..ee382f0 100644
--- a/mesonbuild/compilers/compilers.py
+++ b/mesonbuild/compilers/compilers.py
@@ -365,10 +365,10 @@ def get_base_compile_args(options: 'KeyedOptionDictType', compiler: 'Compiler')
except KeyError:
pass
try:
- if (options[OptionKey('b_ndebug')].value == 'true' or
- (options[OptionKey('b_ndebug')].value == 'if-release' and
- options[OptionKey('buildtype')].value in {'release', 'plain'})):
- args += compiler.get_disable_assert_args()
+ disable = (options[OptionKey('b_ndebug')].value == 'true' or
+ (options[OptionKey('b_ndebug')].value == 'if-release' and
+ options[OptionKey('buildtype')].value in {'release', 'plain'}))
+ args += compiler.get_assert_args(disable)
except KeyError:
pass
# This does not need a try...except
@@ -1071,7 +1071,12 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta):
def get_coverage_link_args(self) -> T.List[str]:
return self.linker.get_coverage_args()
- def get_disable_assert_args(self) -> T.List[str]:
+ def get_assert_args(self, disable: bool) -> T.List[str]:
+ """Get arguments to enable or disable assertion.
+
+ :param disable: Whether to disable assertions
+ :return: A list of string arguments for this compiler
+ """
return []
def get_crt_compile_args(self, crt_val: str, buildtype: str) -> T.List[str]: