aboutsummaryrefslogtreecommitdiff
path: root/include/wlr
diff options
context:
space:
mode:
authorManuel Stoeckl <code@mstoeckl.com>2019-07-16 13:04:27 -0400
committerDrew DeVault <sir@cmpwn.com>2019-07-17 21:00:09 -0400
commitbb056174146ae01448e0281ea204d2ddd60ebe3c (patch)
tree292a692ebe8fc83fda0cb4a7f869c6c6871fc172 /include/wlr
parent9e8f952997d9e37ccc97aded89e16d52dfd46e60 (diff)
Use -fmacro-prefix-map to strip build path
This commit matches sway's 2dc4978d8af326c310057ca8fd22a4c7f5d09335. To help ensure a reproducible build (when debug info is disabled), the meson build script now uses the -fmacro-prefix-map command line argument supported by GCC to strip the build-path dependent bytes of each __FILE__ string used by wlr_log and related functions. A rather ugly algorithm is used to compute the relative path between the build and source folders, because meson has no specific function for this. When the compiler does not support -fmacro-prefix-map, fall back to shifting the start of each __FILE__ string by the length of the relative path to the source directory.
Diffstat (limited to 'include/wlr')
-rw-r--r--include/wlr/util/log.h12
1 files changed, 9 insertions, 3 deletions
diff --git a/include/wlr/util/log.h b/include/wlr/util/log.h
index 2c441180..8eec425c 100644
--- a/include/wlr/util/log.h
+++ b/include/wlr/util/log.h
@@ -50,13 +50,19 @@ enum wlr_log_importance wlr_log_get_verbosity(void);
void _wlr_log(enum wlr_log_importance verbosity, const char *format, ...) _WLR_ATTRIB_PRINTF(2, 3);
void _wlr_vlog(enum wlr_log_importance verbosity, const char *format, va_list args) _WLR_ATTRIB_PRINTF(2, 0);
-const char *_wlr_strip_path(const char *filepath);
+
+#ifdef WLR_REL_SRC_DIR
+// strip prefix from __FILE__, leaving the path relative to the project root
+#define _WLR_FILENAME ((const char *)__FILE__ + sizeof(WLR_REL_SRC_DIR) - 1)
+#else
+#define _WLR_FILENAME __FILE__
+#endif
#define wlr_log(verb, fmt, ...) \
- _wlr_log(verb, "[%s:%d] " fmt, _wlr_strip_path(__FILE__), __LINE__, ##__VA_ARGS__)
+ _wlr_log(verb, "[%s:%d] " fmt, _WLR_FILENAME, __LINE__, ##__VA_ARGS__)
#define wlr_vlog(verb, fmt, args) \
- _wlr_vlog(verb, "[%s:%d] " fmt, _wlr_strip_path(__FILE__), __LINE__, args)
+ _wlr_vlog(verb, "[%s:%d] " fmt, _WLR_FILENAME, __LINE__, args)
#define wlr_log_errno(verb, fmt, ...) \
wlr_log(verb, fmt ": %s", ##__VA_ARGS__, strerror(errno))