hash anything), mtime (hash the compiler's mtime and size) and content
(hash the content of the compiler binary). The default is mtime.
+ - It is now possible to specify extra files whose contents should be
+ included in the hash sum by setting the `CCACHE_EXTRAFILES` option.
+
- Temporary files are now created in the directory they will end up in.
This makes ccache more friendly to Linux's directory layout.
{
struct stat st;
const char *compilercheck;
+ char *p;
hash_string(hash, HASH_PREFIX);
hash_delimiter(hash);
}
}
hash_delimiter(hash);
+
+ p = getenv("CCACHE_EXTRAFILES");
+ if (p) {
+ char *path, *q;
+ p = x_strdup(p);
+ q = p;
+ while ((path = strtok(q, " \t\r\n"))) {
+ cc_log("Hashing extra file %s", path);
+ if (!hash_file(hash, path)) {
+ stats_update(STATS_BADEXTRAFILE);
+ failed();
+ }
+ hash_delimiter(hash);
+ q = NULL;
+ }
+ free(p);
+ }
}
/*
STATS_CACHEHIT_DIR,
STATS_NOOUTPUT,
STATS_EMPTYOUTPUT,
+ STATS_BADEXTRAFILE,
STATS_END
};
*CCACHE_EXTENSION* option to override the default. On HP-UX set this
environment variable to *i* if you use the ``aCC'' compiler.
+*CCACHE_EXTRAFILES*::
+
+ If you set the environment variable *CCACHE_EXTRAFILES* to a
+ space-separated list of paths then ccache will include the contents of
+ those files when calculating the hash sum.
+
*CCACHE_HARDLINK*::
If you set the environment variable *CCACHE_HARDLINK* then ccache will
{ STATS_OUTSTDOUT, "output to stdout ", NULL, 0 },
{ STATS_DEVICE, "output to a non-regular file ", NULL, 0 },
{ STATS_NOINPUT, "no input file ", NULL, 0 },
+ { STATS_BADEXTRAFILE, "error hashing extra file ", NULL, 0 },
{ STATS_NUMFILES, "files in cache ", NULL, FLAG_NOZERO|FLAG_ALWAYS },
{ STATS_TOTALSIZE, "cache size ", display_size , FLAG_NOZERO|FLAG_ALWAYS },
{ STATS_MAXFILES, "max files ", NULL, FLAG_NOZERO },
unset CCACHE_DIR
unset CCACHE_DISABLE
unset CCACHE_EXTENSION
+unset CCACHE_EXTRAFILES
unset CCACHE_HARDLINK
unset CCACHE_HASHDIR
unset CCACHE_LOGFILE
##################################################################
}
+extrafiles_suite() {
+ ##################################################################
+ # Create some code to compile.
+ cat <<EOF >test.c
+int test;
+EOF
+ echo a >a
+ echo b >b
+
+ ##################################################################
+ # Test the CCACHE_EXTRAFILES feature.
+
+ testname="cache hit"
+ $CCACHE $COMPILER -c test.c
+ checkstat 'cache hit (preprocessed)' 0
+ checkstat 'cache miss' 1
+
+ testname="cache miss"
+ $CCACHE $COMPILER -c test.c
+ checkstat 'cache hit (preprocessed)' 1
+ checkstat 'cache miss' 1
+
+ testname="cache miss a b"
+ CCACHE_EXTRAFILES="a b" $CCACHE $COMPILER -c test.c
+ checkstat 'cache hit (preprocessed)' 1
+ checkstat 'cache miss' 2
+
+ testname="cache hit a b"
+ CCACHE_EXTRAFILES="a b" $CCACHE $COMPILER -c test.c
+ checkstat 'cache hit (preprocessed)' 2
+ checkstat 'cache miss' 2
+
+ testname="cache miss a b2"
+ echo b2 >b
+ CCACHE_EXTRAFILES="a b" $CCACHE $COMPILER -c test.c
+ checkstat 'cache hit (preprocessed)' 2
+ checkstat 'cache miss' 3
+
+ testname="cache hit a b2"
+ CCACHE_EXTRAFILES="a b" $CCACHE $COMPILER -c test.c
+ checkstat 'cache hit (preprocessed)' 3
+ checkstat 'cache miss' 3
+
+ testname="cache miss doesntexist"
+ CCACHE_EXTRAFILES="doesntexist" $CCACHE $COMPILER -c test.c
+ checkstat 'cache hit (preprocessed)' 3
+ checkstat 'cache miss' 3
+ checkstat 'error hashing extra file' 1
+}
+
######################################################################
# main program
basedir
compression
readonly
+extrafiles
"
if [ -z "$suites" ]; then