summaryrefslogtreecommitdiff
path: root/src/buildtool/execution_api
diff options
context:
space:
mode:
authorMaksim Denisov <denisov.maksim@huawei.com>2024-07-05 17:27:13 +0200
committerMaksim Denisov <denisov.maksim@huawei.com>2024-07-22 17:01:13 +0200
commitdd23c6e397584f4bf1cf84a73d9c382a8ff81de7 (patch)
tree0f0f600a4674a03da42c07f4ea016ff3c2dc578e /src/buildtool/execution_api
parentbeb3faa6956b9bfd58d4ea6644a9b2987409aaba (diff)
downloadjustbuild-dd23c6e397584f4bf1cf84a73d9c382a8ff81de7.tar.gz
Pass HashFunction to ArtifactDigest::Create
Diffstat (limited to 'src/buildtool/execution_api')
-rw-r--r--src/buildtool/execution_api/bazel_msg/TARGETS1
-rw-r--r--src/buildtool/execution_api/bazel_msg/bazel_msg_factory.cpp10
-rw-r--r--src/buildtool/execution_api/common/tree_reader_utils.cpp4
-rw-r--r--src/buildtool/execution_api/git/TARGETS1
-rw-r--r--src/buildtool/execution_api/git/git_api.hpp9
-rw-r--r--src/buildtool/execution_api/local/TARGETS1
-rw-r--r--src/buildtool/execution_api/local/local_api.hpp7
-rw-r--r--src/buildtool/execution_api/local/local_response.hpp9
-rw-r--r--src/buildtool/execution_api/remote/TARGETS1
-rw-r--r--src/buildtool/execution_api/remote/bazel/bazel_network_reader.cpp13
-rw-r--r--src/buildtool/execution_api/remote/bazel/bazel_response.cpp20
11 files changed, 48 insertions, 28 deletions
diff --git a/src/buildtool/execution_api/bazel_msg/TARGETS b/src/buildtool/execution_api/bazel_msg/TARGETS
index cc14a0df..db495aa5 100644
--- a/src/buildtool/execution_api/bazel_msg/TARGETS
+++ b/src/buildtool/execution_api/bazel_msg/TARGETS
@@ -34,6 +34,7 @@
[ ["src/buildtool/compatibility", "compatibility"]
, ["src/utils/cpp", "hex_string"]
, ["src/buildtool/file_system", "file_system_manager"]
+ , ["src/buildtool/crypto", "hash_function"]
, ["src/buildtool/file_system", "git_repo"]
]
, "stage": ["src", "buildtool", "execution_api", "bazel_msg"]
diff --git a/src/buildtool/execution_api/bazel_msg/bazel_msg_factory.cpp b/src/buildtool/execution_api/bazel_msg/bazel_msg_factory.cpp
index 48c8b062..155067fd 100644
--- a/src/buildtool/execution_api/bazel_msg/bazel_msg_factory.cpp
+++ b/src/buildtool/execution_api/bazel_msg/bazel_msg_factory.cpp
@@ -27,6 +27,7 @@
#include "src/buildtool/common/bazel_types.hpp"
#include "src/buildtool/compatibility/native_support.hpp"
+#include "src/buildtool/crypto/hash_function.hpp"
#include "src/buildtool/file_system/file_system_manager.hpp"
#include "src/buildtool/file_system/git_repo.hpp"
#include "src/utils/cpp/hex_string.hpp"
@@ -184,7 +185,8 @@ template <class T>
if (not content) {
return std::nullopt;
}
- auto digest = ArtifactDigest::Create<ObjectType::File>(*content);
+ auto digest = ArtifactDigest::Create<ObjectType::File>(
+ HashFunction::Instance(), *content);
auto msg = CreateDirectoryNode(dir_name);
msg.set_allocated_digest(
@@ -223,7 +225,8 @@ template <class T>
if (not content) {
return std::nullopt;
}
- auto digest = ArtifactDigest::Create<ObjectType::File>(*content);
+ auto digest = ArtifactDigest::Create<ObjectType::File>(
+ HashFunction::Instance(), *content);
return BazelBlob{digest, std::move(*content), /*is_exec=*/false};
}
@@ -259,7 +262,8 @@ template <class T>
if (not content) {
return std::nullopt;
}
- auto digest = ArtifactDigest::Create<ObjectType::File>(*content);
+ auto digest = ArtifactDigest::Create<ObjectType::File>(
+ HashFunction::Instance(), *content);
return BazelBlob{digest, std::move(*content), /*is_exec=*/false};
}
diff --git a/src/buildtool/execution_api/common/tree_reader_utils.cpp b/src/buildtool/execution_api/common/tree_reader_utils.cpp
index 1ec7edc0..874d1884 100644
--- a/src/buildtool/execution_api/common/tree_reader_utils.cpp
+++ b/src/buildtool/execution_api/common/tree_reader_utils.cpp
@@ -19,6 +19,7 @@
#include "nlohmann/json.hpp"
#include "src/buildtool/common/artifact_digest.hpp"
+#include "src/buildtool/crypto/hash_function.hpp"
#include "src/buildtool/file_system/object_type.hpp"
#include "src/buildtool/logging/log_level.hpp"
#include "src/buildtool/logging/logger.hpp"
@@ -42,7 +43,8 @@ namespace {
[[nodiscard]] auto CreateObjectInfo(bazel_re::SymlinkNode const& node)
-> Artifact::ObjectInfo {
return Artifact::ObjectInfo{
- .digest = ArtifactDigest::Create<ObjectType::File>(node.target()),
+ .digest = ArtifactDigest::Create<ObjectType::File>(
+ HashFunction::Instance(), node.target()),
.type = ObjectType::Symlink};
}
diff --git a/src/buildtool/execution_api/git/TARGETS b/src/buildtool/execution_api/git/TARGETS
index df3dfcdc..2c614f08 100644
--- a/src/buildtool/execution_api/git/TARGETS
+++ b/src/buildtool/execution_api/git/TARGETS
@@ -11,6 +11,7 @@
, ["src/buildtool/execution_api/common", "common_api"]
, ["src/buildtool/logging", "log_level"]
, ["src/buildtool/logging", "logging"]
+ , ["src/buildtool/crypto", "hash_function"]
]
, "stage": ["src", "buildtool", "execution_api", "git"]
}
diff --git a/src/buildtool/execution_api/git/git_api.hpp b/src/buildtool/execution_api/git/git_api.hpp
index a18bd71b..b6a30a9b 100644
--- a/src/buildtool/execution_api/git/git_api.hpp
+++ b/src/buildtool/execution_api/git/git_api.hpp
@@ -25,6 +25,7 @@
#include "gsl/gsl"
#include "src/buildtool/common/artifact_digest.hpp"
#include "src/buildtool/common/repository_config.hpp"
+#include "src/buildtool/crypto/hash_function.hpp"
#include "src/buildtool/execution_api/bazel_msg/bazel_msg_factory.hpp"
#include "src/buildtool/execution_api/common/artifact_blob_container.hpp"
#include "src/buildtool/execution_api/common/common_api.hpp"
@@ -227,7 +228,7 @@ class GitApi final : public IExecutionApi {
return false;
}
auto digest = ArtifactDigest::Create<ObjectType::File>(
- *entry_content);
+ HashFunction::Instance(), *entry_content);
// Collect blob and upload to remote CAS if transfer
// size reached.
if (not UpdateContainerAndUpload<ArtifactDigest>(
@@ -258,8 +259,10 @@ class GitApi final : public IExecutionApi {
ArtifactDigest digest =
IsTreeObject(info.type)
- ? ArtifactDigest::Create<ObjectType::Tree>(*content)
- : ArtifactDigest::Create<ObjectType::File>(*content);
+ ? ArtifactDigest::Create<ObjectType::Tree>(
+ HashFunction::Instance(), *content)
+ : ArtifactDigest::Create<ObjectType::File>(
+ HashFunction::Instance(), *content);
// Collect blob and upload to remote CAS if transfer size reached.
if (not UpdateContainerAndUpload<ArtifactDigest>(
diff --git a/src/buildtool/execution_api/local/TARGETS b/src/buildtool/execution_api/local/TARGETS
index 53b7f717..682c8624 100644
--- a/src/buildtool/execution_api/local/TARGETS
+++ b/src/buildtool/execution_api/local/TARGETS
@@ -42,6 +42,7 @@
, ["src/buildtool/execution_api/execution_service", "cas_utils"]
, ["src/buildtool/file_system", "git_repo"]
, ["src/utils/cpp", "tmp_dir"]
+ , ["src/buildtool/crypto", "hash_function"]
]
, "stage": ["src", "buildtool", "execution_api", "local"]
, "private-deps":
diff --git a/src/buildtool/execution_api/local/local_api.hpp b/src/buildtool/execution_api/local/local_api.hpp
index 5f8fb6a4..e8ba0831 100644
--- a/src/buildtool/execution_api/local/local_api.hpp
+++ b/src/buildtool/execution_api/local/local_api.hpp
@@ -34,6 +34,7 @@
#include "src/buildtool/common/repository_config.hpp"
#include "src/buildtool/compatibility/compatibility.hpp"
#include "src/buildtool/compatibility/native_support.hpp"
+#include "src/buildtool/crypto/hash_function.hpp"
#include "src/buildtool/execution_api/bazel_msg/bazel_blob_container.hpp"
#include "src/buildtool/execution_api/common/artifact_blob_container.hpp"
#include "src/buildtool/execution_api/common/blob_tree.hpp"
@@ -214,8 +215,10 @@ class LocalApi final : public IExecutionApi {
// storage_.ReadTreeInfos() will contain 0 as size.
ArtifactDigest digest =
IsTreeObject(info.type)
- ? ArtifactDigest::Create<ObjectType::Tree>(*content)
- : ArtifactDigest::Create<ObjectType::File>(*content);
+ ? ArtifactDigest::Create<ObjectType::Tree>(
+ HashFunction::Instance(), *content)
+ : ArtifactDigest::Create<ObjectType::File>(
+ HashFunction::Instance(), *content);
// Collect blob and upload to remote CAS if transfer size reached.
if (not UpdateContainerAndUpload<ArtifactDigest>(
diff --git a/src/buildtool/execution_api/local/local_response.hpp b/src/buildtool/execution_api/local/local_response.hpp
index 30d47ca7..c6214320 100644
--- a/src/buildtool/execution_api/local/local_response.hpp
+++ b/src/buildtool/execution_api/local/local_response.hpp
@@ -20,6 +20,7 @@
#include <utility>
#include "gsl/gsl"
+#include "src/buildtool/crypto/hash_function.hpp"
#include "src/buildtool/execution_api/common/execution_response.hpp"
#include "src/buildtool/execution_api/local/local_action.hpp"
#include "src/buildtool/file_system/file_system_manager.hpp"
@@ -139,7 +140,7 @@ class LocalResponse final : public IExecutionResponse {
link.path(),
Artifact::ObjectInfo{
.digest = ArtifactDigest::Create<ObjectType::File>(
- link.target()),
+ HashFunction::Instance(), link.target()),
.type = ObjectType::Symlink});
} catch (...) {
return false;
@@ -151,7 +152,7 @@ class LocalResponse final : public IExecutionResponse {
link.path(),
Artifact::ObjectInfo{
.digest = ArtifactDigest::Create<ObjectType::File>(
- link.target()),
+ HashFunction::Instance(), link.target()),
.type = ObjectType::Symlink});
dir_symlinks.emplace(link.path()); // add it to set
} catch (...) {
@@ -166,7 +167,7 @@ class LocalResponse final : public IExecutionResponse {
link.path(),
Artifact::ObjectInfo{
.digest = ArtifactDigest::Create<ObjectType::File>(
- link.target()),
+ HashFunction::Instance(), link.target()),
.type = ObjectType::Symlink});
} catch (...) {
return false;
@@ -178,7 +179,7 @@ class LocalResponse final : public IExecutionResponse {
link.path(),
Artifact::ObjectInfo{
.digest = ArtifactDigest::Create<ObjectType::File>(
- link.target()),
+ HashFunction::Instance(), link.target()),
.type = ObjectType::Symlink});
} catch (...) {
return false;
diff --git a/src/buildtool/execution_api/remote/TARGETS b/src/buildtool/execution_api/remote/TARGETS
index ad4093f3..e45af2f1 100644
--- a/src/buildtool/execution_api/remote/TARGETS
+++ b/src/buildtool/execution_api/remote/TARGETS
@@ -56,7 +56,6 @@
, ["@", "grpc", "", "grpc++"]
, ["src/buildtool/common/remote", "retry"]
, ["src/buildtool/execution_api/common", "message_limits"]
- , ["src/buildtool/crypto", "hash_function"]
, ["src/utils/cpp", "path"]
]
}
diff --git a/src/buildtool/execution_api/remote/bazel/bazel_network_reader.cpp b/src/buildtool/execution_api/remote/bazel/bazel_network_reader.cpp
index 4547ff8c..135cfd52 100644
--- a/src/buildtool/execution_api/remote/bazel/bazel_network_reader.cpp
+++ b/src/buildtool/execution_api/remote/bazel/bazel_network_reader.cpp
@@ -138,9 +138,10 @@ auto BazelNetworkReader::MakeAuxiliaryMap(
result.reserve(full_tree.size());
for (auto& dir : full_tree) {
try {
- result.emplace(ArtifactDigest::Create<ObjectType::File>(
- dir.SerializeAsString()),
- std::move(dir));
+ result.emplace(
+ ArtifactDigest::Create<ObjectType::File>(
+ HashFunction::Instance(), dir.SerializeAsString()),
+ std::move(dir));
} catch (...) {
return std::nullopt;
}
@@ -191,8 +192,10 @@ auto BazelNetworkReader::BatchReadBlobs(
auto BazelNetworkReader::Validate(BazelBlob const& blob) noexcept -> bool {
ArtifactDigest const rehashed_digest =
NativeSupport::IsTree(blob.digest.hash())
- ? ArtifactDigest::Create<ObjectType::Tree>(*blob.data)
- : ArtifactDigest::Create<ObjectType::File>(*blob.data);
+ ? ArtifactDigest::Create<ObjectType::Tree>(HashFunction::Instance(),
+ *blob.data)
+ : ArtifactDigest::Create<ObjectType::File>(HashFunction::Instance(),
+ *blob.data);
if (rehashed_digest == ArtifactDigest{blob.digest}) {
return true;
}
diff --git a/src/buildtool/execution_api/remote/bazel/bazel_response.cpp b/src/buildtool/execution_api/remote/bazel/bazel_response.cpp
index 1b7682bd..0cb860a3 100644
--- a/src/buildtool/execution_api/remote/bazel/bazel_response.cpp
+++ b/src/buildtool/execution_api/remote/bazel/bazel_response.cpp
@@ -18,6 +18,7 @@
#include "gsl/gsl"
#include "src/buildtool/compatibility/native_support.hpp"
+#include "src/buildtool/crypto/hash_function.hpp"
#include "src/buildtool/execution_api/bazel_msg/bazel_blob_container.hpp"
#include "src/buildtool/execution_api/common/common_api.hpp"
#include "src/buildtool/execution_api/remote/bazel/bazel_cas_client.hpp"
@@ -30,7 +31,8 @@ namespace {
auto ProcessDirectoryMessage(bazel_re::Directory const& dir) noexcept
-> std::optional<BazelBlob> {
auto data = dir.SerializeAsString();
- auto digest = ArtifactDigest::Create<ObjectType::File>(data);
+ auto digest = ArtifactDigest::Create<ObjectType::File>(
+ HashFunction::Instance(), data);
return BazelBlob{std::move(digest), std::move(data), /*is_exec=*/false};
}
@@ -99,8 +101,8 @@ auto BazelResponse::Populate() noexcept -> bool {
artifacts.emplace(
link.path(),
Artifact::ObjectInfo{
- .digest =
- ArtifactDigest::Create<ObjectType::File>(link.target()),
+ .digest = ArtifactDigest::Create<ObjectType::File>(
+ HashFunction::Instance(), link.target()),
.type = ObjectType::Symlink});
} catch (...) {
return false;
@@ -111,8 +113,8 @@ auto BazelResponse::Populate() noexcept -> bool {
artifacts.emplace(
link.path(),
Artifact::ObjectInfo{
- .digest =
- ArtifactDigest::Create<ObjectType::File>(link.target()),
+ .digest = ArtifactDigest::Create<ObjectType::File>(
+ HashFunction::Instance(), link.target()),
.type = ObjectType::Symlink});
dir_symlinks.emplace(link.path()); // add it to set
} catch (...) {
@@ -126,8 +128,8 @@ auto BazelResponse::Populate() noexcept -> bool {
artifacts.emplace(
link.path(),
Artifact::ObjectInfo{
- .digest =
- ArtifactDigest::Create<ObjectType::File>(link.target()),
+ .digest = ArtifactDigest::Create<ObjectType::File>(
+ HashFunction::Instance(), link.target()),
.type = ObjectType::Symlink});
} catch (...) {
return false;
@@ -138,8 +140,8 @@ auto BazelResponse::Populate() noexcept -> bool {
artifacts.emplace(
link.path(),
Artifact::ObjectInfo{
- .digest =
- ArtifactDigest::Create<ObjectType::File>(link.target()),
+ .digest = ArtifactDigest::Create<ObjectType::File>(
+ HashFunction::Instance(), link.target()),
.type = ObjectType::Symlink});
} catch (...) {
return false;