summaryrefslogtreecommitdiff
path: root/src/buildtool/execution_api/remote/bazel/bazel_response.cpp
diff options
context:
space:
mode:
authorMaksim Denisov <denisov.maksim@huawei.com>2024-07-08 15:07:36 +0200
committerMaksim Denisov <denisov.maksim@huawei.com>2024-07-22 17:01:13 +0200
commitf94b4663dc61a2987912faa3f1cd71378db0ad33 (patch)
tree24da5b6ff3868130d273f88417fed933c79e86a4 /src/buildtool/execution_api/remote/bazel/bazel_response.cpp
parentde112e6af5267a78f9b48a8b049e3c86ee95376e (diff)
downloadjustbuild-f94b4663dc61a2987912faa3f1cd71378db0ad33.tar.gz
Pass HashFunction to BazelNetwork
Diffstat (limited to 'src/buildtool/execution_api/remote/bazel/bazel_response.cpp')
-rw-r--r--src/buildtool/execution_api/remote/bazel/bazel_response.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/buildtool/execution_api/remote/bazel/bazel_response.cpp b/src/buildtool/execution_api/remote/bazel/bazel_response.cpp
index 0cb860a3..7db88a08 100644
--- a/src/buildtool/execution_api/remote/bazel/bazel_response.cpp
+++ b/src/buildtool/execution_api/remote/bazel/bazel_response.cpp
@@ -28,11 +28,11 @@
namespace {
-auto ProcessDirectoryMessage(bazel_re::Directory const& dir) noexcept
+auto ProcessDirectoryMessage(HashFunction hash_function,
+ bazel_re::Directory const& dir) noexcept
-> std::optional<BazelBlob> {
auto data = dir.SerializeAsString();
- auto digest = ArtifactDigest::Create<ObjectType::File>(
- HashFunction::Instance(), data);
+ auto digest = ArtifactDigest::Create<ObjectType::File>(hash_function, data);
return BazelBlob{std::move(digest), std::move(data), /*is_exec=*/false};
}
@@ -102,7 +102,7 @@ auto BazelResponse::Populate() noexcept -> bool {
link.path(),
Artifact::ObjectInfo{
.digest = ArtifactDigest::Create<ObjectType::File>(
- HashFunction::Instance(), link.target()),
+ network_->GetHashFunction(), link.target()),
.type = ObjectType::Symlink});
} catch (...) {
return false;
@@ -114,7 +114,7 @@ auto BazelResponse::Populate() noexcept -> bool {
link.path(),
Artifact::ObjectInfo{
.digest = ArtifactDigest::Create<ObjectType::File>(
- HashFunction::Instance(), link.target()),
+ network_->GetHashFunction(), link.target()),
.type = ObjectType::Symlink});
dir_symlinks.emplace(link.path()); // add it to set
} catch (...) {
@@ -129,7 +129,7 @@ auto BazelResponse::Populate() noexcept -> bool {
link.path(),
Artifact::ObjectInfo{
.digest = ArtifactDigest::Create<ObjectType::File>(
- HashFunction::Instance(), link.target()),
+ network_->GetHashFunction(), link.target()),
.type = ObjectType::Symlink});
} catch (...) {
return false;
@@ -141,7 +141,7 @@ auto BazelResponse::Populate() noexcept -> bool {
link.path(),
Artifact::ObjectInfo{
.digest = ArtifactDigest::Create<ObjectType::File>(
- HashFunction::Instance(), link.target()),
+ network_->GetHashFunction(), link.target()),
.type = ObjectType::Symlink});
} catch (...) {
return false;
@@ -215,7 +215,8 @@ auto BazelResponse::UploadTreeMessageDirectories(
bazel_re::Tree const& tree) const -> std::optional<ArtifactDigest> {
BazelBlobContainer dir_blobs{};
- auto rootdir_blob = ProcessDirectoryMessage(tree.root());
+ auto rootdir_blob =
+ ProcessDirectoryMessage(network_->GetHashFunction(), tree.root());
if (not rootdir_blob) {
return std::nullopt;
}
@@ -234,7 +235,8 @@ auto BazelResponse::UploadTreeMessageDirectories(
}
for (auto const& subdir : tree.children()) {
- auto subdir_blob = ProcessDirectoryMessage(subdir);
+ auto subdir_blob =
+ ProcessDirectoryMessage(network_->GetHashFunction(), subdir);
if (not subdir_blob) {
return std::nullopt;
}