]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Add --config-path option
authorJoel Rosdahl <joel@rosdahl.net>
Tue, 17 Nov 2020 18:58:37 +0000 (19:58 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Tue, 17 Nov 2020 19:08:33 +0000 (20:08 +0100)
The option makes subsequent command line options operate on the given
configuration file instead of the default.

Closes #719.

doc/MANUAL.adoc
src/ccache.cpp

index 4cc31e531292a6b7b84287b90ae7fe681f8a0753..b7d89124bf72cd279d2e73cf411f8a62e054a6f1 100644 (file)
@@ -95,10 +95,16 @@ Common options
     Clear the entire cache, removing all cached files, but keeping the
     configuration file.
 
+*`--config-path`* _PATH_::
+
+    Let the subsequent command line options operate on configuration file
+    _PATH_ instead of the default. Using this option has the same effect as
+    setting the environment variable `CCACHE_CONFIGPATH` temporarily.
+
 *`-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
+    instead of the default. For example, to show statistics for a cache
     directory at `/shared/ccache` you can run `ccache -d /shared/ccache -s`.
     Using this option has the same effect as setting the environment variable
     `CCACHE_DIR` temporarily.
index 3e383de3a9785779ccedf0828b5d2da7de1b4420..6b0b822c4dc00e9f49a2b568fea2052bc54a4a02 100644 (file)
@@ -107,6 +107,8 @@ Common options:
                                (normally not needed as this is done
                                automatically)
     -C, --clear                clear the cache completely (except configuration)
+        --config-path PATH     operate on configuration file PATH instead of the
+                               default
     -d, --directory PATH       operate on cache directory PATH instead of the
                                default
         --evict-older-than AGE remove files older than AGE (unsigned integer
@@ -2549,6 +2551,7 @@ handle_main_options(int argc, const char* const* argv)
 {
   enum longopts {
     CHECKSUM_FILE,
+    CONFIG_PATH,
     DUMP_MANIFEST,
     DUMP_RESULT,
     EVICT_OLDER_THAN,
@@ -2560,7 +2563,8 @@ 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'},
+    {"config-path", required_argument, nullptr, CONFIG_PATH},
+    {"directory", required_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},
@@ -2603,6 +2607,10 @@ handle_main_options(int argc, const char* const* argv)
       break;
     }
 
+    case CONFIG_PATH:
+      Util::setenv("CCACHE_CONFIGPATH", arg);
+      break;
+
     case DUMP_MANIFEST:
       return Manifest::dump(arg, stdout) ? 0 : 1;