]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Derive ccache featues from storage registry (#903)
authorGregor Jasny <gregor.jasny@logmein.com>
Tue, 20 Jul 2021 14:18:43 +0000 (16:18 +0200)
committerGitHub <noreply@github.com>
Tue, 20 Jul 2021 14:18:43 +0000 (16:18 +0200)
src/ccache.cpp
src/storage/Storage.cpp
src/storage/Storage.hpp

index 7388e87aecd96b6f1e6d4e58b17f81658ae211c2..2ffba2d90894402e6e5037f701d285f940b0b0f0 100644 (file)
@@ -57,6 +57,7 @@
 
 #include <core/types.hpp>
 #include <core/wincompat.hpp>
+#include <storage/Storage.hpp>
 #include <util/expected.hpp>
 #include <util/path.hpp>
 #include <util/string.hpp>
@@ -164,13 +165,6 @@ Options for scripting or debugging:
 See also the manual on <https://ccache.dev/documentation.html>.
 )";
 
-constexpr const char FEATURE_TEXT[] =
-  "http-storage"
-#ifdef HAVE_REDIS_STORAGE_BACKEND
-  " redis-storage"
-#endif
-  ;
-
 // This is a string that identifies the current "version" of the hash sum
 // computed by ccache. If, for any reason, we want to force the hash sum to be
 // different for the same input in a new ccache version, we can just change
@@ -2466,7 +2460,7 @@ handle_main_options(int argc, const char* const* argv)
     }
 
     case 'V': // --version
-      PRINT(VERSION_TEXT, CCACHE_NAME, CCACHE_VERSION, FEATURE_TEXT);
+      PRINT(VERSION_TEXT, CCACHE_NAME, CCACHE_VERSION, storage::get_features());
       exit(EXIT_SUCCESS);
 
     case 'x': // --show-compression
index 90dd36eee091aa23ce622097f7d5615d1d2a8cd5..fd2847b4f9c45d9c10dbc0129bf278497c59e48b 100644 (file)
@@ -38,6 +38,7 @@
 
 #include <algorithm>
 #include <unordered_map>
+#include <vector>
 
 namespace storage {
 
@@ -51,6 +52,19 @@ const std::unordered_map<std::string /*scheme*/,
 #endif
 };
 
+std::string
+get_features()
+{
+  std::vector<std::string> features;
+  features.reserve(k_secondary_storage_implementations.size());
+  std::transform(k_secondary_storage_implementations.begin(),
+                 k_secondary_storage_implementations.end(),
+                 std::back_inserter(features),
+                 [](auto& entry) { return FMT("{}-storage", entry.first); });
+  std::sort(features.begin(), features.end());
+  return util::join(features, " ");
+}
+
 struct SecondaryStorageConfig
 {
   secondary::SecondaryStorage::Backend::Params params;
index 963f48a782f738003c057bedad36a91cc8ee6ef6..54640d666d56ec582bd77611c8f7f106b1ba1c23 100644 (file)
@@ -34,6 +34,8 @@ class Digest;
 
 namespace storage {
 
+std::string get_features();
+
 struct SecondaryStorageEntry;
 
 class Storage