summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2018-06-27 14:24:54 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2018-07-09 13:27:15 +1000
commit00fdbe3951d7717b03c46b31d1712c45fe492cf1 (patch)
tree50a4e8c2a2d92d25d7fd500a4d41e9c13a5d39d6
parent6be9c3c84e861332938e50d04e82e235a5e2765f (diff)
downloadlibinput-00fdbe3951d7717b03c46b31d1712c45fe492cf1.tar.gz
tools: don't add the debug behavior for release builds
When the meson build type is something other than the debug types, we don't need the special behavior where we adjust executable paths and data dir lookup for tools run directly from the builddir. This avoids leaking the build dir into the final executables. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--meson.build6
-rw-r--r--tools/shared.c5
-rw-r--r--tools/test-builddir-lookup.c12
3 files changed, 19 insertions, 4 deletions
diff --git a/meson.build b/meson.build
index 815afba8..7d21f364 100644
--- a/meson.build
+++ b/meson.build
@@ -31,7 +31,11 @@ add_project_arguments(cppflags, language : 'cpp')
config_h = configuration_data()
config_h.set('_GNU_SOURCE', '1')
-config_h.set_quoted('MESON_BUILD_ROOT', meson.build_root())
+if get_option('buildtype') == 'debug' or get_option('buildtype') == 'debugoptimized'
+ config_h.set_quoted('MESON_BUILD_ROOT', meson.build_root())
+else
+ config_h.set_quoted('MESON_BUILD_ROOT', '')
+endif
prefix = '''#define _GNU_SOURCE 1
#include <assert.h>
diff --git a/tools/shared.c b/tools/shared.c
index 74c0cdad..3cda4573 100644
--- a/tools/shared.c
+++ b/tools/shared.c
@@ -477,6 +477,11 @@ tools_execdir_is_builddir(void)
char *pathsep;
ssize_t sz;
+ /* In the case of release builds, the builddir is
+ the empty string */
+ if (streq(MESON_BUILD_ROOT, ""))
+ return NULL;
+
sz = readlink("/proc/self/exe", execdir, sizeof(execdir) - 1);
if (sz <= 0 || sz == sizeof(execdir) - 1)
return NULL;
diff --git a/tools/test-builddir-lookup.c b/tools/test-builddir-lookup.c
index fc50b0f6..821ca70f 100644
--- a/tools/test-builddir-lookup.c
+++ b/tools/test-builddir-lookup.c
@@ -36,9 +36,15 @@ int main(int argc, char **argv) {
if (streq(mode, "--builddir-is-null")) {
assert(builddir == NULL);
} else if (streq(mode, "--builddir-is-set")) {
- assert(builddir != NULL);
- assert(streq(MESON_BUILD_ROOT, builddir));
- free(builddir);
+ /* In the case of release builds, the builddir is
+ the empty string */
+ if (streq(MESON_BUILD_ROOT, "")) {
+ assert(builddir == NULL);
+ } else {
+ assert(builddir != NULL);
+ assert(streq(MESON_BUILD_ROOT, builddir));
+ free(builddir);
+ }
} else {
abort();
}