diff options
author | Maksim Denisov <denisov.maksim@huawei.com> | 2024-07-12 16:20:01 +0200 |
---|---|---|
committer | Maksim Denisov <denisov.maksim@huawei.com> | 2024-07-22 17:02:34 +0200 |
commit | 39b80d92da47fe0ff22b6c0dc8d872cbe7d53a21 (patch) | |
tree | 925330473b7752bf315d5169350fac638ebfe1ab | |
parent | cfdd16c676250a5d9776292e4aef0d112e0e3cfb (diff) | |
download | justbuild-39b80d92da47fe0ff22b6c0dc8d872cbe7d53a21.tar.gz |
Use HashFunction from StorageConfig in ApiBundle
-rw-r--r-- | src/buildtool/execution_api/common/TARGETS | 2 | ||||
-rw-r--r-- | src/buildtool/execution_api/common/api_bundle.cpp | 14 | ||||
-rw-r--r-- | src/buildtool/execution_api/common/api_bundle.hpp | 11 | ||||
-rw-r--r-- | src/buildtool/graph_traverser/TARGETS | 1 | ||||
-rw-r--r-- | src/buildtool/graph_traverser/graph_traverser.hpp | 7 |
5 files changed, 19 insertions, 16 deletions
diff --git a/src/buildtool/execution_api/common/TARGETS b/src/buildtool/execution_api/common/TARGETS index cfe2c35f..c2599e3e 100644 --- a/src/buildtool/execution_api/common/TARGETS +++ b/src/buildtool/execution_api/common/TARGETS @@ -50,12 +50,12 @@ , ["src/buildtool/execution_api/remote", "config"] , ["src/buildtool/storage", "config"] , ["src/buildtool/storage", "storage"] + , ["src/buildtool/crypto", "hash_function"] ] , "private-deps": [ ["src/buildtool/execution_api/bazel_msg", "bazel_msg"] , ["src/buildtool/execution_api/local", "local"] , ["src/buildtool/execution_api/remote", "bazel"] - , ["src/buildtool/crypto", "hash_function"] ] } , "message_limits": diff --git a/src/buildtool/execution_api/common/api_bundle.cpp b/src/buildtool/execution_api/common/api_bundle.cpp index 2908fb47..6dea80ce 100644 --- a/src/buildtool/execution_api/common/api_bundle.cpp +++ b/src/buildtool/execution_api/common/api_bundle.cpp @@ -15,7 +15,6 @@ #include "src/buildtool/execution_api/common/api_bundle.hpp" #include "src/buildtool/common/remote/retry_config.hpp" -#include "src/buildtool/crypto/hash_function.hpp" #include "src/buildtool/execution_api/bazel_msg/bazel_common.hpp" #include "src/buildtool/execution_api/local/local_api.hpp" #include "src/buildtool/execution_api/remote/bazel/bazel_api.hpp" @@ -28,13 +27,14 @@ ApiBundle::ApiBundle( gsl::not_null<Auth const*> const& authentication, gsl::not_null<RetryConfig const*> const& retry_config, gsl::not_null<RemoteExecutionConfig const*> const& remote_exec_config) - : local{std::make_shared<LocalApi>(storage_config, + : auth{*authentication}, + retry_config{*retry_config}, + remote_config{*remote_exec_config}, + hash_function{storage_config->hash_function}, + local{std::make_shared<LocalApi>(storage_config, storage, local_exec_config, - repo_config)}, // needed by remote - auth{*authentication}, // needed by remote - retry_config{*retry_config}, // needed by remote - remote_config{*remote_exec_config}, + repo_config)}, remote{CreateRemote(remote_exec_config->remote_address)} {} auto ApiBundle::CreateRemote(std::optional<ServerAddress> const& address) const @@ -48,7 +48,7 @@ auto ApiBundle::CreateRemote(std::optional<ServerAddress> const& address) const &auth, &retry_config, config, - HashFunction::Instance()); + hash_function); } return local; } diff --git a/src/buildtool/execution_api/common/api_bundle.hpp b/src/buildtool/execution_api/common/api_bundle.hpp index 5414423e..baa4594b 100644 --- a/src/buildtool/execution_api/common/api_bundle.hpp +++ b/src/buildtool/execution_api/common/api_bundle.hpp @@ -23,6 +23,7 @@ #include "src/buildtool/common/remote/remote_common.hpp" #include "src/buildtool/common/remote/retry_config.hpp" #include "src/buildtool/common/repository_config.hpp" +#include "src/buildtool/crypto/hash_function.hpp" #include "src/buildtool/execution_api/common/execution_api.hpp" #include "src/buildtool/execution_api/local/config.hpp" #include "src/buildtool/execution_api/remote/config.hpp" @@ -45,10 +46,14 @@ struct ApiBundle final { [[nodiscard]] auto CreateRemote(std::optional<ServerAddress> const& address) const -> gsl::not_null<IExecutionApi::Ptr>; - gsl::not_null<IExecutionApi::Ptr> const local; // needed by remote - Auth const& auth; // needed by remote - RetryConfig const& retry_config; // needed by remote + // Needed to be set before creating the remote (via CreateRemote) + Auth const& auth; + RetryConfig const& retry_config; RemoteExecutionConfig const& remote_config; + HashFunction const hash_function; + // 7 bytes of alignment. + + gsl::not_null<IExecutionApi::Ptr> const local; gsl::not_null<IExecutionApi::Ptr> const remote; }; diff --git a/src/buildtool/graph_traverser/TARGETS b/src/buildtool/graph_traverser/TARGETS index 189159f2..0bb9a8e8 100644 --- a/src/buildtool/graph_traverser/TARGETS +++ b/src/buildtool/graph_traverser/TARGETS @@ -25,7 +25,6 @@ , ["src/buildtool/logging", "log_level"] , ["src/buildtool/logging", "logging"] , ["src/buildtool/progress_reporting", "base_progress_reporter"] - , ["src/buildtool/crypto", "hash_function"] ] , "stage": ["src", "buildtool", "graph_traverser"] } diff --git a/src/buildtool/graph_traverser/graph_traverser.hpp b/src/buildtool/graph_traverser/graph_traverser.hpp index 0bd9c9c2..b10427cd 100644 --- a/src/buildtool/graph_traverser/graph_traverser.hpp +++ b/src/buildtool/graph_traverser/graph_traverser.hpp @@ -37,7 +37,6 @@ #include "src/buildtool/common/repository_config.hpp" #include "src/buildtool/common/statistics.hpp" #include "src/buildtool/common/tree.hpp" -#include "src/buildtool/crypto/hash_function.hpp" #include "src/buildtool/execution_api/common/api_bundle.hpp" #include "src/buildtool/execution_api/common/artifact_blob_container.hpp" #include "src/buildtool/execution_api/common/common_api.hpp" @@ -294,7 +293,7 @@ class GraphTraverser { ArtifactBlobContainer container; for (auto const& blob : blobs) { auto digest = ArtifactDigest::Create<ObjectType::File>( - HashFunction::Instance(), blob); + apis_.hash_function, blob); Logger::Log(logger_, LogLevel::Trace, [&]() { return fmt::format( "Uploaded blob {}, its digest has id {} and size {}.", @@ -364,7 +363,7 @@ class GraphTraverser { &*apis_.remote, platform_properties_, dispatch_list_, - HashFunction::Instance(), + apis_.hash_function, &apis_.auth, &apis_.retry_config, stats_, @@ -399,7 +398,7 @@ class GraphTraverser { &*api_cached, platform_properties_, dispatch_list_, - HashFunction::Instance(), + apis_.hash_function, &apis_.auth, &apis_.retry_config, stats_, |