From: Gregor Jasny Date: Tue, 20 Jul 2021 14:18:43 +0000 (+0200) Subject: Derive ccache featues from storage registry (#903) X-Git-Tag: v4.4~110 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=01e72eaa8a92cfd94cf56ccd1533804644f6a952;p=thirdparty%2Fccache.git Derive ccache featues from storage registry (#903) --- diff --git a/src/ccache.cpp b/src/ccache.cpp index 7388e87ae..2ffba2d90 100644 --- a/src/ccache.cpp +++ b/src/ccache.cpp @@ -57,6 +57,7 @@ #include #include +#include #include #include #include @@ -164,13 +165,6 @@ Options for scripting or debugging: See also the manual on . )"; -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 diff --git a/src/storage/Storage.cpp b/src/storage/Storage.cpp index 90dd36eee..fd2847b4f 100644 --- a/src/storage/Storage.cpp +++ b/src/storage/Storage.cpp @@ -38,6 +38,7 @@ #include #include +#include namespace storage { @@ -51,6 +52,19 @@ const std::unordered_map 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; diff --git a/src/storage/Storage.hpp b/src/storage/Storage.hpp index 963f48a78..54640d666 100644 --- a/src/storage/Storage.hpp +++ b/src/storage/Storage.hpp @@ -34,6 +34,8 @@ class Digest; namespace storage { +std::string get_features(); + struct SecondaryStorageEntry; class Storage