From 504e979320c938af5f23f4201f09aa38ea41dbe4 Mon Sep 17 00:00:00 2001 From: Pavol Sakac <26042917+pavsa@users.noreply.github.com> Date: Sun, 31 Mar 2019 13:09:10 +0200 Subject: [PATCH] Enable generating relative paths in dependency file in depend mode (#366) This was previously only done if preprocessor was run. --- src/ccache.c | 2 +- test/suites/depend.bash | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/ccache.c b/src/ccache.c index 2a04ce743..afc10f86f 100644 --- a/src/ccache.c +++ b/src/ccache.c @@ -1040,7 +1040,7 @@ use_relative_paths_in_depfile(const char *depfile) cc_log("Base dir not set, skip using relative paths"); return; // nothing to do } - if (!has_absolute_include_headers) { + if (!has_absolute_include_headers && !conf->depend_mode) { cc_log("No absolute path for included files found, skip using relative" " paths"); return; // nothing to do diff --git a/test/suites/depend.bash b/test/suites/depend.bash index f0e74f233..3d2f2adc1 100644 --- a/test/suites/depend.bash +++ b/test/suites/depend.bash @@ -127,6 +127,14 @@ SUITE_depend() { expect_stat 'cache miss' 1 expect_stat 'files in cache' 3 + # ------------------------------------------------------------------------- + TEST "Dependency file paths converted to relative if CCACHE_BASEDIR specified" + + CCACHE_DEPEND=1 CCACHE_BASEDIR="`pwd`" $CCACHE_COMPILE $DEPSFLAGS_CCACHE -c "`pwd`/test.c" + if grep -q "[^.]/test.c" "test.d"; then + test_failed "Dependency file does not contain relative path to test.c" + fi + # ------------------------------------------------------------------------- TEST "stderr from both preprocessor and compiler" -- 2.47.2