diff --git a/meson.build b/meson.build index ca56c97b..68a06b28 100644 --- a/meson.build +++ b/meson.build @@ -80,10 +80,11 @@ endif config_h.set_quoted('HTTP_DOC_LINK', doc_url) config_h.set('_GNU_SOURCE', '1') -if get_option('buildtype') == 'debug' or get_option('buildtype') == 'debugoptimized' + +is_debug_build = get_option('buildtype') == 'debug' or get_option('buildtype') == 'debugoptimized' +if is_debug_build + config_h.set('IS_DEBUG_BUILD', '1') config_h.set_quoted('MESON_BUILD_ROOT', meson.current_build_dir()) -else - config_h.set_quoted('MESON_BUILD_ROOT', '') endif prefix = '''#define _GNU_SOURCE 1 @@ -758,7 +759,7 @@ executable('ptraccel-debug', # Don't run the test during a release build because we rely on the magic # subtool lookup -if get_option('buildtype') == 'debug' or get_option('buildtype') == 'debugoptimized' +if is_debug_build config_tool_option_test = configuration_data() config_tool_option_test.set('DISABLE_WARNING', 'yes') config_tool_option_test.set('MESON_ENABLED_DEBUG_GUI', get_option('debug-gui')) diff --git a/src/builddir.h b/src/builddir.h index 1f90a563..74203bdc 100644 --- a/src/builddir.h +++ b/src/builddir.h @@ -36,6 +36,7 @@ static inline bool builddir_lookup(char **builddir) { +#ifdef IS_DEBUG_BUILD char execdir[PATH_MAX]; char *pathsep; ssize_t nread; @@ -65,4 +66,7 @@ builddir_lookup(char **builddir) *builddir = safe_strdup(execdir); return true; +#else + return false; +#endif } diff --git a/test/test-builddir-lookup.c b/test/test-builddir-lookup.c index ae118fb1..15e3eeae 100644 --- a/test/test-builddir-lookup.c +++ b/test/test-builddir-lookup.c @@ -40,16 +40,14 @@ main(int argc, char **argv) assert(!is_builddir); assert(builddir == NULL); } else if (streq(mode, "--builddir-is-set")) { - /* In the case of release builds, the builddir is - the empty string */ - if (streq(MESON_BUILD_ROOT, "")) { - assert(!is_builddir); - assert(builddir == NULL); - } else { - assert(is_builddir); - assert(builddir); - assert(streq(MESON_BUILD_ROOT, builddir)); - } +#ifdef IS_DEBUG_BUILD + assert(is_builddir); + assert(builddir); + assert(streq(MESON_BUILD_ROOT, builddir)); +#else + assert(!is_builddir); + assert(builddir == NULL); +#endif } else { abort(); }