diff options
| author | 2025-09-08 12:06:30 -0400 | |
|---|---|---|
| committer | 2025-09-08 12:06:30 -0400 | |
| commit | ed6fc176a1ef6afd43eaa198c43eb813c3a81d99 (patch) | |
| tree | 9ffa752b3780c6c5a73b88ab9cace15846b792c1 | |
| parent | a36cb2f6f9df8e501baf614f8aca9b4bd28e4268 (diff) | |
| download | libalabaster-ed6fc176a1ef6afd43eaa198c43eb813c3a81d99.tar.gz libalabaster-ed6fc176a1ef6afd43eaa198c43eb813c3a81d99.tar.bz2 libalabaster-ed6fc176a1ef6afd43eaa198c43eb813c3a81d99.zip | |
build: Option for asserts in release builds
- Define NDEBUG in release builds.
- loccount -> sloccount.
Signed-off-by: Andrew Opalach <andrew@akon.city>
| -rw-r--r-- | include/al/lib.h | 8 | ||||
| -rw-r--r-- | meson.build | 10 | ||||
| -rw-r--r-- | meson_options.txt | 1 | ||||
| -rwxr-xr-x | scripts/line_count.sh | 2 |
4 files changed, 17 insertions, 4 deletions
diff --git a/include/al/lib.h b/include/al/lib.h index 73861a8..5e65149 100644 --- a/include/al/lib.h +++ b/include/al/lib.h @@ -43,7 +43,13 @@ #include <wchar.h> #include <stdio.h> #include <stdarg.h> +#if !defined AL_DEBUG && defined AL_RELEASE_ASSERTS +#undef NDEBUG #include <assert.h> +#define NDEBUG +#else +#include <assert.h> +#endif #include <ctype.h> #ifdef AL_MEMORY_TRACKING @@ -94,7 +100,7 @@ static inline void *al_realloc(void *ptr, size_t n) { return ptr ? realloc(ptr, #define al_snprintf snprintf #define al_vsnprintf vsnprintf #define al_fflush fflush -#ifdef AL_DEBUG +#if defined AL_DEBUG || defined AL_RELEASE_ASSERTS #define al_assert assert #else #define al_assert(expr) do { (void)sizeof(expr); } while (0) // NOLINT(bugprone-sizeof-expression) diff --git a/meson.build b/meson.build index 2c20b45..849aec6 100644 --- a/meson.build +++ b/meson.build @@ -24,8 +24,14 @@ have_wide_string_width = compiler.has_function('wcswidth') # For testing: '-Wshadow', '-Wconversion', '-Wc++-compat' alabaster_args = ['-fstrict-aliasing', '-Wstrict-aliasing'] +if get_option('release-asserts') + alabaster_args += ['-DAL_RELEASE_ASSERTS'] +endif + if is_debug alabaster_args += ['-DAL_DEBUG'] +else + alabaster_args += ['-DNDEBUG'] endif if is_msvc_specifically @@ -58,8 +64,8 @@ alabaster_src = [ 'src/lib.c', 'src/random.c', 'src/str.c', - 'src/log.c', - 'src/ring_buffer.c' + 'src/ring_buffer.c', + 'src/log.c' ] alabaster_inc = include_directories('include') alabaster_deps = [c89atomic] diff --git a/meson_options.txt b/meson_options.txt index 14a2c36..7f05e0a 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1 +1,2 @@ +option('release-asserts', type: 'boolean', value: false, yield: true) option('tests', type: 'feature', value: 'auto', yield: true) diff --git a/scripts/line_count.sh b/scripts/line_count.sh index 6af0fe0..a6ac787 100755 --- a/scripts/line_count.sh +++ b/scripts/line_count.sh @@ -1,3 +1,3 @@ #! /usr/bin/env sh export LC_ALL="C" -find ./src ./include -type f -exec loccount {} + +find ./src ./include -type f -exec sloccount {} + |