From: Maksym Sobolyev Date: Mon, 30 Dec 2024 13:29:07 +0000 (-0800) Subject: feat: Add HTTP_STORAGE_BACKEND build option (#1537) X-Git-Tag: v4.11~36 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9da7c09c9390b2db5c745a8dad58d7a3ac3af9b0;p=thirdparty%2Fccache.git feat: Add HTTP_STORAGE_BACKEND build option (#1537) --- diff --git a/CMakeLists.txt b/CMakeLists.txt index acedac4a..590fdfed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,6 +80,7 @@ include(EnableCcache) # option(REDIS_STORAGE_BACKEND "Enable Redis remote storage" ON) +option(HTTP_STORAGE_BACKEND "Enable HTTP remote storage" ON) option(ENABLE_TESTING "Enable tests" ON) include(InstallDirs) @@ -174,7 +175,7 @@ message(STATUS) message(STATUS "Configuration summary:") message(STATUS " Storage backends:") message(STATUS " file ON") -message(STATUS " http ON") +message(STATUS " http ${HTTP_STORAGE_BACKEND}") message(STATUS " redis ${REDIS_STORAGE_BACKEND}") message(STATUS " Dependencies:") print_dependency_summary(" ") diff --git a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake index 05e1d47f..31eb366b 100644 --- a/cmake/Dependencies.cmake +++ b/cmake/Dependencies.cmake @@ -21,7 +21,9 @@ if(FETCHCONTENT_FULLY_DISCONNECTED) endif() find_package(Blake3 1.4.0 MODULE REQUIRED) -find_package(CppHttplib 0.10.6 MODULE REQUIRED) +if(HTTP_STORAGE_BACKEND) + find_package(CppHttplib 0.10.6 MODULE REQUIRED) +endif() find_package(Fmt 8.0.0 MODULE REQUIRED) find_package(NonstdSpan 0.10.3 MODULE REQUIRED) find_package(TlExpected 1.1.0 MODULE REQUIRED) diff --git a/doc/INSTALL.md b/doc/INSTALL.md index bacb9c55..67d6e506 100644 --- a/doc/INSTALL.md +++ b/doc/INSTALL.md @@ -40,7 +40,8 @@ should be located or retrieved: ### Dependencies - [BLAKE3](https://github.com/BLAKE3-team/BLAKE3)[^1] -- [cpp-httplib](https://github.com/yhirose/cpp-httplib)[^1] +- [cpp-httplib](https://github.com/yhirose/cpp-httplib)[^1] (optional, disable + with `-DHTTP_STORAGE_BACKEND=OFF`) - [doctest](https://github.com/doctest/doctest)[^2] (optional, disable with `-D ENABLE_TESTING=OFF`) - [fmt](https://fmt.dev)[^1] diff --git a/src/ccache/CMakeLists.txt b/src/ccache/CMakeLists.txt index ddaf0f5e..97616b68 100644 --- a/src/ccache/CMakeLists.txt +++ b/src/ccache/CMakeLists.txt @@ -51,7 +51,6 @@ target_link_libraries( dep_tlexpected dep_xxhash PRIVATE - dep_cpphttplib dep_zstd standard_settings standard_warnings @@ -70,6 +69,11 @@ if(REDIS_STORAGE_BACKEND) target_link_libraries(ccache_framework PRIVATE dep_hiredis) endif() +if(HTTP_STORAGE_BACKEND) + target_compile_definitions(ccache_framework PUBLIC -DHAVE_HTTP_STORAGE_BACKEND) + target_link_libraries(ccache_framework PRIVATE dep_cpphttplib) +endif() + add_executable(test-lockfile test_lockfile.cpp) target_link_libraries(test-lockfile PRIVATE standard_settings standard_warnings ccache_framework) diff --git a/src/ccache/storage/remote/CMakeLists.txt b/src/ccache/storage/remote/CMakeLists.txt index 68c9f12d..aa26f21a 100644 --- a/src/ccache/storage/remote/CMakeLists.txt +++ b/src/ccache/storage/remote/CMakeLists.txt @@ -1,7 +1,6 @@ set( sources filestorage.cpp - httpstorage.cpp remotestorage.cpp ) @@ -9,6 +8,10 @@ if(REDIS_STORAGE_BACKEND) list(APPEND sources redisstorage.cpp) endif() +if(HTTP_STORAGE_BACKEND) + list(APPEND sources httpstorage.cpp) +endif() + file(GLOB headers *.hpp) list(APPEND sources ${headers}) diff --git a/src/ccache/storage/storage.cpp b/src/ccache/storage/storage.cpp index f4fecc45..63e03380 100644 --- a/src/ccache/storage/storage.cpp +++ b/src/ccache/storage/storage.cpp @@ -23,7 +23,9 @@ #include #include #include -#include +#ifdef HAVE_HTTP_STORAGE_BACKEND +# include +#endif #ifdef HAVE_REDIS_STORAGE_BACKEND # include #endif @@ -52,7 +54,9 @@ const std::unordered_map> k_remote_storage_implementations = { {"file", std::make_shared()}, +#ifdef HAVE_HTTP_STORAGE_BACKEND {"http", std::make_shared()}, +#endif #ifdef HAVE_REDIS_STORAGE_BACKEND {"redis", std::make_shared()}, {"redis+unix", std::make_shared()}, diff --git a/src/third_party/CMakeLists.txt b/src/third_party/CMakeLists.txt index 69fb309e..51244e11 100644 --- a/src/third_party/CMakeLists.txt +++ b/src/third_party/CMakeLists.txt @@ -4,8 +4,10 @@ add_subdirectory(win32-compat) if(NOT TARGET dep_blake3) add_subdirectory(blake3) endif() -if(NOT TARGET dep_cpphttplib) - add_subdirectory(cpp-httplib) +if(HTTP_STORAGE_BACKEND) + if(NOT TARGET dep_cpphttplib) + add_subdirectory(cpp-httplib) + endif() endif() if(NOT TARGET dep_fmt) add_subdirectory(fmt) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 8e5b0737..141e91d1 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -54,7 +54,9 @@ addtest(profiling_hip_clang) addtest(readonly) addtest(readonly_direct) addtest(remote_file) -addtest(remote_http) +if(HTTP_STORAGE_BACKEND) + addtest(remote_http) +endif() addtest(remote_only) addtest(remote_redis) addtest(remote_redis_unix)