]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Support syntax CCACHE_COMPILERCHECK=string:<value>
authorJiang Jiang <jiangj@opera.com>
Tue, 2 Dec 2014 16:23:16 +0000 (17:23 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Sun, 8 Mar 2015 19:48:53 +0000 (20:48 +0100)
This can be faster than running a command directly, because the
command to run might just produce the same result for every ccache
invocation. By reading it from config file or environment variable
we can just run that command once and store the result in the string
following "string:" and reusing it.

For example when we want to use clang revision for clang built from
SVN trunk, we can just call clang --version once and store the
revision number like:

  export CCACHE_COMPILERCHECK=string:218707

(Assuming 218707 is the current build revision.)

MANUAL.txt
ccache.c

index 4ac113e12154d472934b2f56b8f3df2fba31e60f..d0ee09b8774378280a17157d41a0bf7fcc551a62 100644 (file)
@@ -281,6 +281,9 @@ setting key. Boolean options are indicated with ``[boolean]''
     compiler's source has not changed, or if the compiler only has changes that
     don't affect code generation). You should only use the *none* setting if
     you know what you are doing.
+*string:value*::
+    Use *value* as the string to calculate hash from. This can be the compiler
+    revision number you retrieved earlier and set here via environment variable.
 _a command string_::
     Hash the standard output and standard error output of the specified
     command. The string will be split on whitespace to find out the command and
index cd5ed65d6476ac2069cbc8e4e7e87400e4e62835..ac2b915b810e819f66f5067bd2697b516d536cdf 100644 (file)
--- a/ccache.c
+++ b/ccache.c
@@ -1106,6 +1106,9 @@ hash_compiler(struct mdfour *hash, struct stat *st, const char *path,
                hash_delimiter(hash, "cc_mtime");
                hash_int(hash, st->st_size);
                hash_int(hash, st->st_mtime);
+       } else if (str_startswith(conf->compiler_check, "string:")) {
+               hash_delimiter(hash, "cc_hash");
+               hash_string(hash, conf->compiler_check + strlen("string:"));
        } else if (str_eq(conf->compiler_check, "content") || !allow_command) {
                hash_delimiter(hash, "cc_content");
                hash_file(hash, path);