[PATCH libinput 5/5] tools: don't add the debug behavior for release builds

Peter Hutterer peter.hutterer at who-t.net
Wed Jun 27 23:51:43 UTC 2018


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 at who-t.net>
---
 meson.build             | 4 +++-
 tools/libinput-quirks.c | 5 ++++-
 tools/shared.c          | 6 +++++-
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/meson.build b/meson.build
index e10a0bc3..826b4fd0 100644
--- a/meson.build
+++ b/meson.build
@@ -31,7 +31,9 @@ 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())
+endif
 
 prefix = '''#define _GNU_SOURCE 1
 #include <assert.h>
diff --git a/tools/libinput-quirks.c b/tools/libinput-quirks.c
index 862bb0ae..fbb97dbf 100644
--- a/tools/libinput-quirks.c
+++ b/tools/libinput-quirks.c
@@ -162,13 +162,16 @@ main(int argc, char **argv)
 
 	/* Overriding the data dir means no custom override file */
 	if (!data_path) {
+#ifdef MESON_BUILD_ROOT
 		char *builddir;
 
 		builddir = tools_execdir_is_builddir();
 		if (builddir) {
 			data_path = LIBINPUT_DATA_SRCDIR;
 			free(builddir);
-		} else {
+		} else
+#endif
+		{
 			data_path = LIBINPUT_DATA_DIR;
 			override_file = LIBINPUT_DATA_OVERRIDE_FILE;
 		}
diff --git a/tools/shared.c b/tools/shared.c
index 776b3d3e..eef625ed 100644
--- a/tools/shared.c
+++ b/tools/shared.c
@@ -473,6 +473,8 @@ out:
 char *
 tools_execdir_is_builddir(void)
 {
+	char *dir = NULL;
+#ifdef MESON_BUILD_ROOT
 	char execdir[PATH_MAX];
 	char *pathsep;
 	ssize_t sz;
@@ -489,7 +491,9 @@ tools_execdir_is_builddir(void)
 	if (!streq(execdir, MESON_BUILD_ROOT))
 		return NULL;
 
-	return safe_strdup(execdir);
+	dir = safe_strdup(execdir);
+#endif
+	return dir;
 }
 
 static inline void
-- 
2.17.1



More information about the wayland-devel mailing list