]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
feat: Add HTTP_STORAGE_BACKEND build option (#1537)
authorMaksym Sobolyev <sobomax@sippysoft.com>
Mon, 30 Dec 2024 13:29:07 +0000 (05:29 -0800)
committerGitHub <noreply@github.com>
Mon, 30 Dec 2024 13:29:07 +0000 (14:29 +0100)
CMakeLists.txt
cmake/Dependencies.cmake
doc/INSTALL.md
src/ccache/CMakeLists.txt
src/ccache/storage/remote/CMakeLists.txt
src/ccache/storage/storage.cpp
src/third_party/CMakeLists.txt
test/CMakeLists.txt

index acedac4a670757a3030aece46b8c753573ff624e..590fdfedb279fbb8d7c8f5e60de6b46ff3d0411a 100644 (file)
@@ -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("    ")
index 05e1d47f6e9d5934ad0014939e7ba698bea4c262..31eb366bb68814148f7f11cae9482181d5a348ce 100644 (file)
@@ -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)
index bacb9c558df988abcc13600a5591b5fef230ba42..67d6e5061d0b4fba1bf5e9f3a5ab205f0f9b6d5f 100644 (file)
@@ -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]
index ddaf0f5e5f02ce3b7bcb64ea5afeab8a7fc60d4f..97616b68736383f5145132fdc55ce36d2f454954 100644 (file)
@@ -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)
 
index 68c9f12ded9f6239e605421203f6871dd8606db3..aa26f21ac4b4dd0fb80f4df50e27a81226bd9817 100644 (file)
@@ -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})
 
index f4fecc45919702fa3126ae059c8183453bdbe825..63e03380db5dfc08af92567851153223778fe3f7 100644 (file)
@@ -23,7 +23,9 @@
 #include <ccache/core/exceptions.hpp>
 #include <ccache/core/statistic.hpp>
 #include <ccache/storage/remote/filestorage.hpp>
-#include <ccache/storage/remote/httpstorage.hpp>
+#ifdef HAVE_HTTP_STORAGE_BACKEND
+#  include <ccache/storage/remote/httpstorage.hpp>
+#endif
 #ifdef HAVE_REDIS_STORAGE_BACKEND
 #  include <ccache/storage/remote/redisstorage.hpp>
 #endif
@@ -52,7 +54,9 @@ const std::unordered_map<std::string /*scheme*/,
                          std::shared_ptr<remote::RemoteStorage>>
   k_remote_storage_implementations = {
     {"file", std::make_shared<remote::FileStorage>()},
+#ifdef HAVE_HTTP_STORAGE_BACKEND
     {"http", std::make_shared<remote::HttpStorage>()},
+#endif
 #ifdef HAVE_REDIS_STORAGE_BACKEND
     {"redis", std::make_shared<remote::RedisStorage>()},
     {"redis+unix", std::make_shared<remote::RedisStorage>()},
index 69fb309e3ca0f0f0422d1d3d742d91d885d5d8b4..51244e111605879aa7e812ef9f95598b2c74a3af 100644 (file)
@@ -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)
index 8e5b07370719968e9f6a5aacd7a909cf0695e298..141e91d1036400347bfd97fa453412222eef0cf6 100644 (file)
@@ -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)