From d232a80e90a9bd4e7c677c695a9c230ac1ec8361 Mon Sep 17 00:00:00 2001 From: Hemmo Nieminen Date: Sun, 17 Dec 2017 21:06:06 +0200 Subject: [PATCH] Allow value 'if-release' for b_ndebug project option. (#1896) When set, NDEBUG will be automatically defined for for release builds but not for other build types. --- docs/markdown/snippets/if-release.md | 7 +++++++ mesonbuild/compilers/compilers.py | 7 +++---- 2 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 docs/markdown/snippets/if-release.md diff --git a/docs/markdown/snippets/if-release.md b/docs/markdown/snippets/if-release.md new file mode 100644 index 000000000..96e12eff5 --- /dev/null +++ b/docs/markdown/snippets/if-release.md @@ -0,0 +1,7 @@ +## b_ndebug : if-release + +The value `if-release` can be given for the `b_ndebug` project option. + +This will make the `NDEBUG` pre-compiler macro to be defined for release +type builds as if the `b_ndebug` project option had had the value `true` +defined for it. diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index 011c222c4..4079d0f8f 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -224,9 +224,8 @@ base_options = {'b_pch': coredata.UserBooleanOption('b_pch', 'Use precompiled he 'b_colorout': coredata.UserComboOption('b_colorout', 'Use colored output', ['auto', 'always', 'never'], 'always'), - 'b_ndebug': coredata.UserBooleanOption('b_ndebug', - 'Disable asserts', - False), + 'b_ndebug': coredata.UserComboOption('b_ndebug', 'Disable asserts', + ['true', 'false', 'if-release'], 'false'), 'b_staticpic': coredata.UserBooleanOption('b_staticpic', 'Build static libraries as position independent', True), @@ -313,7 +312,7 @@ def get_base_compile_args(options, compiler): except KeyError: pass try: - if options['b_ndebug'].value: + if options['b_ndebug'].value == 'true' or (options['b_ndebug'].value == 'if-release' and options['buildtype'] == 'release'): args += ['-DNDEBUG'] except KeyError: pass