[ccache] [patch] better temporary filenames for ccache
Martin Pool
mbp at sourcefrog.net
Wed Sep 3 13:08:36 EST 2003
This patch makes ccache's temporary filename include the basename of the
original file. This means that when ccache is used in conjunction with
distcc, you can see meaningful names in the distcc monitor rather than
just tmp.stdout.vexed.1234. It's much nicer.
Index: ccache.c
===================================================================
RCS file: /data/cvs/ccache/ccache.c,v
retrieving revision 1.80
diff -u -c -r1.80 ccache.c
*** ccache.c 7 Mar 2003 12:09:19 -0000 1.80
--- ccache.c 3 Sep 2003 03:02:50 -0000
***************
*** 240,246 ****
struct stat st;
int status;
int nlevels = 2;
!
if ((s = getenv("CCACHE_NLEVELS"))) {
nlevels = atoi(s);
if (nlevels < 1) nlevels = 1;
--- 249,257 ----
struct stat st;
int status;
int nlevels = 2;
! char *input_base;
! char *tmp;
!
if ((s = getenv("CCACHE_NLEVELS"))) {
nlevels = atoi(s);
if (nlevels < 1) nlevels = 1;
***************
*** 309,316 ****
}
}
/* now the run */
! x_asprintf(&path_stdout, "%s/tmp.stdout.%s.%s", cache_dir, tmp_string(),
i_extension);
x_asprintf(&path_stderr, "%s/tmp.cpp_stderr.%s", cache_dir, tmp_string());
--- 320,336 ----
}
}
+ /* ~/hello.c -> tmp.hello.123.i */
+ if ((tmp = strrchr(input_file, '/')) != NULL)
+ input_base = x_strdup(tmp + 1);
+ else
+ input_base = x_strdup(input_file);
+ if ((tmp = strchr(input_base, '.')) != NULL)
+ *tmp = 0;
+
/* now the run */
! x_asprintf(&path_stdout, "%s/%s.tmp.%s.%s", cache_dir,
! input_base, tmp_string(),
i_extension);
x_asprintf(&path_stderr, "%s/tmp.cpp_stderr.%s", cache_dir, tmp_string());
--
Martin
More information about the ccache
mailing list