diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/other_tools/ops_maps/TARGETS | 2 | ||||
-rw-r--r-- | src/other_tools/ops_maps/content_cas_map.cpp | 2 | ||||
-rw-r--r-- | src/other_tools/utils/TARGETS | 21 | ||||
-rw-r--r-- | src/other_tools/utils/curl_context.cpp (renamed from src/utils/cpp/curl_context.cpp) | 10 | ||||
-rw-r--r-- | src/other_tools/utils/curl_context.hpp (renamed from src/utils/cpp/curl_context.hpp) | 6 | ||||
-rw-r--r-- | src/other_tools/utils/curl_easy_handle.cpp (renamed from src/utils/cpp/curl_easy_handle.cpp) | 26 | ||||
-rw-r--r-- | src/other_tools/utils/curl_easy_handle.hpp (renamed from src/utils/cpp/curl_easy_handle.hpp) | 10 | ||||
-rw-r--r-- | src/utils/cpp/TARGETS | 21 |
8 files changed, 34 insertions, 64 deletions
diff --git a/src/other_tools/ops_maps/TARGETS b/src/other_tools/ops_maps/TARGETS index 72002975..bedf8cba 100644 --- a/src/other_tools/ops_maps/TARGETS +++ b/src/other_tools/ops_maps/TARGETS @@ -59,7 +59,7 @@ ] , "stage": ["src", "other_tools", "ops_maps"] , "private-deps": - [ ["src/utils/cpp", "curl_easy_handle"] + [ ["src/other_tools/utils", "curl_easy_handle"] , ["src/buildtool/crypto", "hasher"] , ["src/buildtool/execution_api/local", "local"] , ["src/buildtool/file_system", "file_storage"] diff --git a/src/other_tools/ops_maps/content_cas_map.cpp b/src/other_tools/ops_maps/content_cas_map.cpp index 55aa78a7..7ed1f3df 100644 --- a/src/other_tools/ops_maps/content_cas_map.cpp +++ b/src/other_tools/ops_maps/content_cas_map.cpp @@ -17,7 +17,7 @@ #include "src/buildtool/crypto/hasher.hpp" #include "src/buildtool/execution_api/local/local_cas.hpp" #include "src/buildtool/file_system/file_storage.hpp" -#include "src/utils/cpp/curl_easy_handle.hpp" +#include "src/other_tools/utils/curl_easy_handle.hpp" namespace { diff --git a/src/other_tools/utils/TARGETS b/src/other_tools/utils/TARGETS index 0893821d..883ab841 100644 --- a/src/other_tools/utils/TARGETS +++ b/src/other_tools/utils/TARGETS @@ -8,4 +8,25 @@ , "private-deps": [["src/buildtool/file_system", "file_system_manager"], ["", "libarchive"]] } +, "curl_context": + { "type": ["@", "rules", "CC", "library"] + , "name": ["curl_context"] + , "hdrs": ["curl_context.hpp"] + , "srcs": ["curl_context.cpp"] + , "stage": ["src", "other_tools", "utils"] + , "private-deps": [["src/buildtool/logging", "logging"], ["", "libcurl"]] + } +, "curl_easy_handle": + { "type": ["@", "rules", "CC", "library"] + , "name": ["curl_easy_handle"] + , "hdrs": ["curl_easy_handle.hpp"] + , "srcs": ["curl_easy_handle.cpp"] + , "deps": ["curl_context", ["@", "gsl-lite", "", "gsl-lite"]] + , "stage": ["src", "other_tools", "utils"] + , "private-deps": + [ ["src/buildtool/logging", "logging"] + , ["src/buildtool/file_system", "file_system_manager"] + , ["", "libcurl"] + ] + } } diff --git a/src/utils/cpp/curl_context.cpp b/src/other_tools/utils/curl_context.cpp index 3369b2d3..46f7cfac 100644 --- a/src/utils/cpp/curl_context.cpp +++ b/src/other_tools/utils/curl_context.cpp @@ -12,29 +12,23 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "src/utils/cpp/curl_context.hpp" +#include "src/other_tools/utils/curl_context.hpp" #include "src/buildtool/logging/logger.hpp" -#ifndef BOOTSTRAP_BUILD_TOOL extern "C" { #include <curl/curl.h> } -#endif // BOOTSTRAP_BUILD_TOOL CurlContext::CurlContext() noexcept { -#ifndef BOOTSTRAP_BUILD_TOOL // NOLINTNEXTLINE(hicpp-signed-bitwise) if (not(initialized_ = (curl_global_init(CURL_GLOBAL_DEFAULT) >= 0))) { Logger::Log(LogLevel::Error, "initializing libcurl failed"); } -#endif // BOOTSTRAP_BUILD_TOOL } CurlContext::~CurlContext() noexcept { -#ifndef BOOTSTRAP_BUILD_TOOL if (initialized_) { curl_global_cleanup(); } -#endif // BOOTSTRAP_BUILD_TOOL -}
\ No newline at end of file +} diff --git a/src/utils/cpp/curl_context.hpp b/src/other_tools/utils/curl_context.hpp index e408b8bf..22e561bb 100644 --- a/src/utils/cpp/curl_context.hpp +++ b/src/other_tools/utils/curl_context.hpp @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef INCLUDED_SRC_OTHER_TOOLS_CURL_CONTEXT_HPP -#define INCLUDED_SRC_OTHER_TOOLS_CURL_CONTEXT_HPP +#ifndef INCLUDED_SRC_OTHER_TOOLS_UTILS_CURL_CONTEXT_HPP +#define INCLUDED_SRC_OTHER_TOOLS_UTILS_CURL_CONTEXT_HPP /// \brief Maintainer of a libcurl state. /// Classes, static methods, and global functions dealing with curl operations @@ -33,4 +33,4 @@ class CurlContext { bool initialized_{false}; }; -#endif // INCLUDED_SRC_OTHER_TOOLS_CURL_CONTEXT_HPP
\ No newline at end of file +#endif // INCLUDED_SRC_OTHER_TOOLS_UTILS_CURL_CONTEXT_HPP diff --git a/src/utils/cpp/curl_easy_handle.cpp b/src/other_tools/utils/curl_easy_handle.cpp index 7fac31fc..29e7670e 100644 --- a/src/utils/cpp/curl_easy_handle.cpp +++ b/src/other_tools/utils/curl_easy_handle.cpp @@ -12,29 +12,22 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "src/utils/cpp/curl_easy_handle.hpp" +#include "src/other_tools/utils/curl_easy_handle.hpp" #include <fstream> #include "src/buildtool/file_system/file_system_manager.hpp" #include "src/buildtool/logging/logger.hpp" -#ifndef BOOTSTRAP_BUILD_TOOL extern "C" { #include "curl/curl.h" } -#endif // BOOTSTRAP_BUILD_TOOL void curl_easy_closer(gsl::owner<CURL*> curl) { -#ifndef BOOTSTRAP_BUILD_TOOL curl_easy_cleanup(curl); -#endif // BOOTSTRAP_BUILD_TOOL } auto CurlEasyHandle::Create() noexcept -> std::shared_ptr<CurlEasyHandle> { -#ifdef BOOTSTRAP_BUILD_TOOL - return nullptr; -#else try { auto curl = std::make_shared<CurlEasyHandle>(); auto* handle = curl_easy_init(); @@ -49,7 +42,6 @@ auto CurlEasyHandle::Create() noexcept -> std::shared_ptr<CurlEasyHandle> { ex.what()); return nullptr; } -#endif // BOOTSTRAP_BUILD_TOOL } auto CurlEasyHandle::EasyWriteToFile(gsl::owner<char*> data, @@ -57,14 +49,10 @@ auto CurlEasyHandle::EasyWriteToFile(gsl::owner<char*> data, size_t nmemb, gsl::owner<void*> userptr) -> std::streamsize { -#ifdef BOOTSTRAP_BUILD_TOOL - return 0; -#else auto actual_size = static_cast<std::streamsize>(size * nmemb); auto* file = static_cast<std::ofstream*>(userptr); file->write(data, actual_size); // append chunk return actual_size; -#endif // BOOTSTRAP_BUILD_TOOL } auto CurlEasyHandle::EasyWriteToString(gsl::owner<char*> data, @@ -72,21 +60,14 @@ auto CurlEasyHandle::EasyWriteToString(gsl::owner<char*> data, size_t nmemb, gsl::owner<void*> userptr) -> std::streamsize { -#ifdef BOOTSTRAP_BUILD_TOOL - return 0; -#else size_t actual_size = size * nmemb; (static_cast<std::string*>(userptr))->append(data, actual_size); return static_cast<std::streamsize>(actual_size); -#endif // BOOTSTRAP_BUILD_TOOL } auto CurlEasyHandle::DownloadToFile( std::string const& url, std::filesystem::path const& file_path) noexcept -> int { -#ifdef BOOTSTRAP_BUILD_TOOL - return 1; -#else try { // set URL // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg, hicpp-vararg) @@ -127,14 +108,10 @@ auto CurlEasyHandle::DownloadToFile( ex.what()); return 1; } -#endif // BOOTSTRAP_BUILD_TOOL } auto CurlEasyHandle::DownloadToString(std::string const& url) noexcept -> std::optional<std::string> { -#ifdef BOOTSTRAP_BUILD_TOOL - return std::nullopt; -#else try { // set URL // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg, hicpp-vararg) @@ -171,5 +148,4 @@ auto CurlEasyHandle::DownloadToString(std::string const& url) noexcept ex.what()); return std::nullopt; } -#endif // BOOTSTRAP_BUILD_TOOL } diff --git a/src/utils/cpp/curl_easy_handle.hpp b/src/other_tools/utils/curl_easy_handle.hpp index 5f318887..4f6f33c9 100644 --- a/src/utils/cpp/curl_easy_handle.hpp +++ b/src/other_tools/utils/curl_easy_handle.hpp @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef INCLUDED_SRC_OTHER_TOOLS_CURL_EASY_HANDLE_HPP -#define INCLUDED_SRC_OTHER_TOOLS_CURL_EASY_HANDLE_HPP +#ifndef INCLUDED_SRC_OTHER_TOOLS_UTILS_CURL_EASY_HANDLE_HPP +#define INCLUDED_SRC_OTHER_TOOLS_UTILS_CURL_EASY_HANDLE_HPP #include <filesystem> #include <functional> @@ -21,7 +21,7 @@ #include <optional> #include "gsl-lite/gsl-lite.hpp" -#include "src/utils/cpp/curl_context.hpp" +#include "src/other_tools/utils/curl_context.hpp" extern "C" { #if defined(BUILDING_LIBCURL) || defined(CURL_STRICTER) @@ -67,7 +67,7 @@ class CurlEasyHandle { nullptr, curl_easy_closer}; - /// \brief Overwrites write_callback to redirrect to file instead of stdout. + /// \brief Overwrites write_callback to redirect to file instead of stdout. [[nodiscard]] auto static EasyWriteToFile(gsl::owner<char*> data, size_t size, size_t nmemb, @@ -83,4 +83,4 @@ class CurlEasyHandle { -> std::streamsize; }; -#endif // INCLUDED_SRC_OTHER_TOOLS_CURL_EASY_HANDLE_HPP
\ No newline at end of file +#endif // INCLUDED_SRC_OTHER_TOOLS_UTILS_CURL_EASY_HANDLE_HPP
\ No newline at end of file diff --git a/src/utils/cpp/TARGETS b/src/utils/cpp/TARGETS index 4bc79e8e..42d8ae9e 100644 --- a/src/utils/cpp/TARGETS +++ b/src/utils/cpp/TARGETS @@ -58,27 +58,6 @@ , "stage": ["src", "utils", "cpp"] , "private-deps": [["src/buildtool/file_system", "file_system_manager"]] } -, "curl_context": - { "type": ["@", "rules", "CC", "library"] - , "name": ["curl_context"] - , "hdrs": ["curl_context.hpp"] - , "srcs": ["curl_context.cpp"] - , "stage": ["src", "utils", "cpp"] - , "private-deps": [["src/buildtool/logging", "logging"], ["", "libcurl"]] - } -, "curl_easy_handle": - { "type": ["@", "rules", "CC", "library"] - , "name": ["curl_easy_handle"] - , "hdrs": ["curl_easy_handle.hpp"] - , "srcs": ["curl_easy_handle.cpp"] - , "deps": ["curl_context", ["@", "gsl-lite", "", "gsl-lite"]] - , "stage": ["src", "utils", "cpp"] - , "private-deps": - [ ["src/buildtool/logging", "logging"] - , ["src/buildtool/file_system", "file_system_manager"] - , ["", "libcurl"] - ] - } , "file_locking": { "type": ["@", "rules", "CC", "library"] , "name": ["file_locking"] |