From 2dc4978d8af326c310057ca8fd22a4c7f5d09335 Mon Sep 17 00:00:00 2001 From: Manuel Stoeckl Date: Sat, 22 Jun 2019 23:13:19 -0400 Subject: Use -fmacro-prefix-map to strip build path Because meson does not provide a simple way to get the relative build path, it is computed with a pair of foreach loops. As meson does not have a simple way to compute string length (except via underscorify and 63 split operations), the build script uses a shell command instead. If the compiler does not suppot -fmacro-prefix-map, then fall back to passing in the relative path prefix, and use its length to offset the uses of __FILE__ in log messages so that the build path is at least still not included in the logs. This is significantly more efficient than calling _sway_strip_path. --- common/log.c | 17 ----------------- 1 file changed, 17 deletions(-) (limited to 'common/log.c') diff --git a/common/log.c b/common/log.c index 669fd360..17648e44 100644 --- a/common/log.c +++ b/common/log.c @@ -93,20 +93,3 @@ void _sway_log(sway_log_importance_t verbosity, const char *fmt, ...) { sway_log_stderr(verbosity, fmt, args); va_end(args); } - -// strips the path prefix from filepath -// will try to strip SWAY_SRC_DIR as well as a relative src dir -// e.g. '/src/build/sway/util/log.c' and -// '../util/log.c' will both be stripped to -// 'util/log.c' -const char *_sway_strip_path(const char *filepath) { - static int srclen = sizeof(SWAY_SRC_DIR); - if (strstr(filepath, SWAY_SRC_DIR) == filepath) { - filepath += srclen; - } else if (*filepath == '.') { - while (*filepath == '.' || *filepath == '/') { - ++filepath; - } - } - return filepath; -} -- cgit v1.2.3-70-g09d2