]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
- added CCACHE_NLEVELS variable
authorAndrew Tridgell <tridge@samba.org>
Wed, 3 Apr 2002 14:45:51 +0000 (16:45 +0200)
committerAndrew Tridgell <tridge@samba.org>
Wed, 3 Apr 2002 14:45:51 +0000 (16:45 +0200)
- fixed absolute path hanlding when launching ccache as "ccache /usr/blah/gcc"

ccache.1
ccache.c
ccache.yo
web/ccache-man.html

index 58ff795a730cbfb79d2073f0de2678d9d5e9447c..eacc9735c2a03239960fbc71f84d1f2bbcc8ba54 100644 (file)
--- a/ccache.1
+++ b/ccache.1
@@ -139,6 +139,11 @@ If you set the environment variable
 CCACHE_NOSTATS then ccache will not update the statistics files on
 each compile\&.
 .IP 
+.IP "\fBCCACHE_NLEVELS\fP" 
+The environment variable CCACHE_NLEVELS allows
+you to choose the number of levels of hash in the cache directory\&. The
+default is 2\&. The minimum is 1 and the maximum is 8\&. 
+.IP 
 .IP "\fBCCACHE_NOLINK\fP" 
 If you set the environment variable
 CCACHE_NOLINK then ccache will not use hard links from the cache
index c278ed70f5f5aa631d6977207dfb8b46fcbbec70..6f50cac7f6941eb1027df284fce823e0e3a05184 100644 (file)
--- a/ccache.c
+++ b/ccache.c
@@ -39,6 +39,7 @@ static void failed(void)
 {
        execv(orig_args->argv[0], orig_args->argv);
        cc_log("execv returned (%s)!\n", strerror(errno));
+       perror(orig_args->argv[0]);
        exit(1);
 }
 
@@ -115,11 +116,17 @@ static void find_hash(ARGS *args)
 {
        int i;
        char *path_stdout, *path_stderr;
-       char *hash_dir1;
        char *hash_dir;
        char *s;
        struct stat st;
        int status;
+       int nlevels = 2;
+
+       if ((s = getenv("CCACHE_NLEVELS"))) {
+               nlevels = atoi(s);
+               if (nlevels < 1) nlevels = 1;
+               if (nlevels > 8) nlevels = 8;
+       }
 
        hash_start();
 
@@ -196,23 +203,27 @@ static void find_hash(ARGS *args)
        free(path_stdout);
        free(path_stderr);
 
-       /* we use a 2 level subdir for the cache path to reduce the impact
+       /* we use a N level subdir for the cache path to reduce the impact
           on filesystems which are slow for large directories
        */
        s = hash_result();
-       x_asprintf(&hash_dir1, "%s/%c", cache_dir, s[0]);
-       x_asprintf(&stats_file, "%s/stats", hash_dir1);
-       if (create_dir(hash_dir1) != 0) {
-               cc_log("failed to create %s\n", hash_dir1);
-               failed();
+       x_asprintf(&hash_dir, "%s/%c", cache_dir, s[0]);
+       x_asprintf(&stats_file, "%s/stats", hash_dir);
+       for (i=1; i<nlevels; i++) {
+               char *p;
+               if (create_dir(hash_dir) != 0) {
+                       cc_log("failed to create %s\n", hash_dir);
+                       failed();
+               }
+               x_asprintf(&p, "%s/%c", hash_dir, s[i]);
+               free(hash_dir);
+               hash_dir = p;
        }
-       x_asprintf(&hash_dir, "%s/%c", hash_dir1, s[1]);
-       free(hash_dir1);
        if (create_dir(hash_dir) != 0) {
                cc_log("failed to create %s\n", hash_dir);
                failed();
        }
-       x_asprintf(&hashname, "%s/%s", hash_dir, s+2);
+       x_asprintf(&hashname, "%s/%s", hash_dir, s+nlevels);
        free(hash_dir);
 }
 
@@ -311,6 +322,10 @@ static void find_compiler(int argc, char **argv)
                orig_args->argv++;
                orig_args->argc--;
                free(base);
+               if (strchr(argv[1],'/')) {
+                       /* a full path was given */
+                       return;
+               }
                base = basename(argv[1]);
        }
 
index 472fc7e1c74549f05f892e14da6a17b936ef08df..547d0cf45cd2c52a93b6f9b932bdc535300c9dcf 100644 (file)
--- a/ccache.yo
+++ b/ccache.yo
@@ -118,6 +118,10 @@ dit(bf(CCACHE_NOSTATS)) If you set the environment variable
 CCACHE_NOSTATS then ccache will not update the statistics files on
 each compile.
 
+dit(bf(CCACHE_NLEVELS)) The environment variable CCACHE_NLEVELS allows
+you to choose the number of levels of hash in the cache directory. The
+default is 2. The minimum is 1 and the maximum is 8. 
+
 dit(bf(CCACHE_NOLINK)) If you set the environment variable
 CCACHE_NOLINK then ccache will not use hard links from the cache
 directory when creating the compiler output and will do a file copy
index be2238122238025e122e4c1a9952440f14f41d3c..63e46b41fbda3d6d6565b850d3b74296587ea11f 100644 (file)
@@ -116,6 +116,9 @@ bypassing the cache completely.
 <p><p></p><dt><strong><strong>CCACHE_NOSTATS</strong></strong><dd> If you set the environment variable
 CCACHE_NOSTATS then ccache will not update the statistics files on
 each compile.
+<p><p></p><dt><strong><strong>CCACHE_NLEVELS</strong></strong><dd> The environment variable CCACHE_NLEVELS allows
+you to choose the number of levels of hash in the cache directory. The
+default is 2. The minimum is 1 and the maximum is 8. 
 <p><p></p><dt><strong><strong>CCACHE_NOLINK</strong></strong><dd> If you set the environment variable
 CCACHE_NOLINK then ccache will not use hard links from the cache
 directory when creating the compiler output and will do a file copy