]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
added -C option
authorAndrew Tridgell <tridge@samba.org>
Mon, 3 Jun 2002 03:22:17 +0000 (05:22 +0200)
committerAndrew Tridgell <tridge@samba.org>
Mon, 3 Jun 2002 03:22:17 +0000 (05:22 +0200)
ccache.1
ccache.c
ccache.h
ccache.yo
cleanup.c
web/ccache-man.html
web/index.html

index 4eae543dee33156f7dc3930a6057c9a220c1fd24..76a9736136f11753c461dd8a2eb7377656f648ce 100644 (file)
--- a/ccache.1
+++ b/ccache.1
@@ -26,6 +26,7 @@ Here is a summary of the options to ccache\&.
 -s                      show statistics summary
 -z                      zero statistics
 -c                      run a cache cleanup
+-C                      clear the cache completely
 -F <maxfiles>           set maximum files in cache
 -M <maxsize>            set maximum size of cache (use G, M or K)
 -h                      this help page
@@ -65,6 +66,9 @@ statistics up to date on each compile\&. This option is mostly useful
 if you manually modify the cache contents or believe that the cache
 size statistics may be inaccurate\&.
 .IP 
+.IP "\fB-C\fP" 
+Clear the entire cache, removing all cached files\&.
+.IP 
 .IP "\fB-F maxfiles\fP" 
 This sets the maximum number of files allowed in
 the cache\&. The value is stored inside the cache directory and applies
index 59a8b4a51f61baea737d556ff1b7387646199902..70f23fdbde1927aea05d86aca4daa3afcc61b735 100644 (file)
--- a/ccache.c
+++ b/ccache.c
@@ -199,7 +199,7 @@ static void to_cache(ARGS *args)
            stat(tmp_hashname, &st2) != 0 ||
            rename(tmp_hashname, hashname) != 0 ||
            rename(tmp_stderr, path_stderr) != 0) {
-               cc_log("failed to rename tmp files\n");
+               cc_log("failed to rename tmp files - %s\n", strerror(errno));
                stats_update(STATS_ERROR);
                failed();
        }
@@ -787,6 +787,7 @@ static void usage(void)
        printf("-s                      show statistics summary\n");
        printf("-z                      zero statistics\n");
        printf("-c                      run a cache cleanup\n");
+       printf("-C                      clear the cache completely\n");
        printf("-F <maxfiles>           set maximum files in cache\n");
        printf("-M <maxsize>            set maximum size of cache (use G, M or K)\n");
        printf("-h                      this help page\n");
@@ -800,7 +801,7 @@ static int ccache_main(int argc, char *argv[])
        int c;
        size_t v;
 
-       while ((c = getopt(argc, argv, "hszcF:M:V")) != -1) {
+       while ((c = getopt(argc, argv, "hszcCF:M:V")) != -1) {
                switch (c) {
                case 'V':
                        printf("ccache version %s\n", CCACHE_VERSION);
@@ -821,6 +822,11 @@ static int ccache_main(int argc, char *argv[])
                        printf("Cleaned cached\n");
                        break;
 
+               case 'C':
+                       wipe_all(cache_dir);
+                       printf("Cleared cache\n");
+                       break;
+
                case 'z':
                        stats_zero();
                        printf("Statistics cleared\n");
index 5206f46dda73450053de7c174749c1d44d9405eb..5a4d07967e3eae949e5d08fcfacd562679f29fac 100644 (file)
--- a/ccache.h
+++ b/ccache.h
@@ -106,6 +106,7 @@ int snprintf(char *,size_t ,const char *, ...);
 
 void cleanup_dir(const char *dir, size_t maxfiles, size_t maxsize);
 void cleanup_all(const char *dir);
+void wipe_all(const char *dir);
 
 int execute(char **argv, 
            const char *path_stdout,
index c9d0b32902be25d4f1f9b72a8ead892340aafed7..49ea00fa7accae7f64645687cc9498f1d33aa0d2 100644 (file)
--- a/ccache.yo
+++ b/ccache.yo
@@ -23,6 +23,7 @@ verb(
 -s                      show statistics summary
 -z                      zero statistics
 -c                      run a cache cleanup
+-C                      clear the cache completely
 -F <maxfiles>           set maximum files in cache
 -M <maxsize>            set maximum size of cache (use G, M or K)
 -h                      this help page
@@ -55,6 +56,8 @@ statistics up to date on each compile. This option is mostly useful
 if you manually modify the cache contents or believe that the cache
 size statistics may be inaccurate.
 
+dit(bf(-C)) Clear the entire cache, removing all cached files.
+
 dit(bf(-F maxfiles)) This sets the maximum number of files allowed in
 the cache. The value is stored inside the cache directory and applies
 to all future compiles. Due to the way the value is stored the actual
index cc4c8a86642f83d51e11fc42f5c6e8a5ca4d9829..4f9ef2b492071d1cf62bc58e6df55cb533f044e3 100644 (file)
--- a/cleanup.c
+++ b/cleanup.c
@@ -155,3 +155,38 @@ void cleanup_all(const char *dir)
                free(sfile);
        }
 }
+
+
+/* traverse function for wiping files */
+static void wipe_fn(const char *fname, struct stat *st)
+{
+       char *p;
+
+       if (!S_ISREG(st->st_mode)) return;
+
+       p = basename(fname);
+       if (strcmp(p, "stats") == 0) {
+               free(p);
+               return;
+       }
+       free(p);
+
+       unlink(fname);
+}
+
+
+/* wipe all cached files in all subdirs */
+void wipe_all(const char *dir)
+{
+       char *dname;
+       int i;
+       
+       for (i=0;i<=0xF;i++) {
+               x_asprintf(&dname, "%s/%1x", dir, i);
+               traverse(dir, wipe_fn);
+               free(dname);
+       }
+
+       /* and fix the counters */
+       cleanup_all(dir);
+}
index 7cd9cf6ce2b252a2ce3b47f1665457638b70f5be..ddeeeec4e4ece01b853c26d57add5a77aa98741d 100644 (file)
@@ -36,6 +36,7 @@ being done again.
 -s                      show statistics summary
 -z                      zero statistics
 -c                      run a cache cleanup
+-C                      clear the cache completely
 -F &lt;maxfiles&gt;           set maximum files in cache
 -M &lt;maxsize&gt;            set maximum size of cache (use G, M or K)
 -h                      this help page
@@ -63,6 +64,7 @@ keeps the cache below the specified limits at runtime and keeps
 statistics up to date on each compile. This option is mostly useful
 if you manually modify the cache contents or believe that the cache
 size statistics may be inaccurate.
+<p><p></p><dt><strong><strong>-C</strong></strong><dd> Clear the entire cache, removing all cached files.
 <p><p></p><dt><strong><strong>-F maxfiles</strong></strong><dd> This sets the maximum number of files allowed in
 the cache. The value is stored inside the cache directory and applies
 to all future compiles. Due to the way the value is stored the actual
index 064f87c06a66c32e22c73e94b47a896fa92ecb8f..c1a266aeb7f7667039479e50923ad3ba48c7e29c 100644 (file)
@@ -119,6 +119,15 @@ To fetch via rsync use this command:
   rsync -Pavz samba.org::ftp/unpacked/ccache .
 </pre>
 
+<h2>Related projects</h2>
+
+A bunch of related projects and patches have sprung up, particular
+related to building a distributed version of ccache. 
+
+<ul>
+<li> <a href="http://distcc.samba.org/">distcc</a>
+<li> 
+
 <hr>
 <tiny>
 <a href="http://samba.org/~tridge/">Andrew Tridgell</a><br>