From: Joel Rosdahl Date: Fri, 7 Aug 2020 12:20:02 +0000 (+0200) Subject: Add -d/--directory option X-Git-Tag: v4.0~201 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f108509f69c1945d33b29b89e6a5e88af61f1ca0;p=thirdparty%2Fccache.git Add -d/--directory option The option makes subsequent command line options operate on the given cache directory instead of the default. --- diff --git a/doc/MANUAL.adoc b/doc/MANUAL.adoc index 1f7c0f287..c2d800de0 100644 --- a/doc/MANUAL.adoc +++ b/doc/MANUAL.adoc @@ -94,6 +94,12 @@ Common options Clear the entire cache, removing all cached files, but keeping the configuration file. +*`-d`*, *`--directory`* _PATH_ + + Let the subsequent command line options operate on cache directory PATH + instead of the default for. For example, to show statistics for a cache + directory at `/shared/ccache` you can run `ccache -d /shared/ccache -s`. + *`--evict-older-than`* _AGE_:: Remove files older than _AGE_ from the cache. _AGE_ should be an unsigned diff --git a/src/ccache.cpp b/src/ccache.cpp index aca587784..d02fc4e6e 100644 --- a/src/ccache.cpp +++ b/src/ccache.cpp @@ -102,6 +102,8 @@ Common options: (normally not needed as this is done automatically) -C, --clear clear the cache completely (except configuration) + -d, --directory PATH operate on cache directory PATH instead of the + default --evict-older-than AGE remove files older than AGE (unsigned integer with a d (days) or s (seconds) suffix) -F, --max-files NUM set maximum number of files in cache to NUM (use @@ -2170,6 +2172,7 @@ handle_main_options(int argc, const char* const* argv) {"checksum-file", required_argument, nullptr, CHECKSUM_FILE}, {"cleanup", no_argument, nullptr, 'c'}, {"clear", no_argument, nullptr, 'C'}, + {"directory", no_argument, nullptr, 'd'}, {"dump-manifest", required_argument, nullptr, DUMP_MANIFEST}, {"dump-result", required_argument, nullptr, DUMP_RESULT}, {"evict-older-than", required_argument, nullptr, EVICT_OLDER_THAN}, @@ -2195,7 +2198,7 @@ handle_main_options(int argc, const char* const* argv) int c; while ((c = getopt_long(argc, const_cast(argv), - "cCk:hF:M:po:sVxX:z", + "cCd:k:hF:M:po:sVxX:z", options, nullptr)) != -1) { @@ -2282,6 +2285,10 @@ handle_main_options(int argc, const char* const* argv) break; } + case 'd': // --directory + Util::setenv("CCACHE_DIR", arg); + break; + case 'h': // --help fmt::print(stdout, USAGE_TEXT, CCACHE_NAME, CCACHE_NAME); exit(EXIT_SUCCESS);