diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2023-02-22 13:38:05 -0800 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek.chauhan@gmail.com> | 2023-04-21 15:18:56 +0530 |
commit | f80f40fa4feb0fa3f365f3debcbe2a43d7d125af (patch) | |
tree | b68cd5595907f68ffa83e9bdb288d8378cfaecca /mesonbuild | |
parent | bfce5c45a4784d86be8472a00f628f2ffac74cf2 (diff) | |
download | meson-f80f40fa4feb0fa3f365f3debcbe2a43d7d125af.zip meson-f80f40fa4feb0fa3f365f3debcbe2a43d7d125af.tar.gz meson-f80f40fa4feb0fa3f365f3debcbe2a43d7d125af.tar.bz2 |
compilers: split code for deciding if debug is needed into a helper
Diffstat (limited to 'mesonbuild')
-rw-r--r-- | mesonbuild/compilers/compilers.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index ee382f0..5f6fa08 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -334,6 +334,17 @@ def get_option_value(options: 'KeyedOptionDictType', opt: OptionKey, fallback: ' return v +def are_asserts_disabled(options: KeyedOptionDictType) -> bool: + """Should debug assertions be disabled + + :param options: OptionDictionary + :return: whether to disable assertions or not + """ + return (options[OptionKey('b_ndebug')].value == 'true' or + (options[OptionKey('b_ndebug')].value == 'if-release' and + options[OptionKey('buildtype')].value in {'release', 'plain'})) + + def get_base_compile_args(options: 'KeyedOptionDictType', compiler: 'Compiler') -> T.List[str]: args = [] # type T.List[str] try: @@ -365,10 +376,7 @@ def get_base_compile_args(options: 'KeyedOptionDictType', compiler: 'Compiler') except KeyError: pass try: - 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) + args += compiler.get_assert_args(are_asserts_disabled(options)) except KeyError: pass # This does not need a try...except |