summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/buildtool/common/artifact_digest.hpp7
-rw-r--r--src/buildtool/execution_api/execution_service/bytestream_server.cpp14
-rw-r--r--src/buildtool/execution_api/execution_service/cas_server.cpp15
-rw-r--r--src/buildtool/execution_api/execution_service/execution_server.cpp16
-rw-r--r--src/buildtool/execution_api/local/local_action.cpp6
-rw-r--r--src/buildtool/execution_api/local/local_action.hpp5
-rw-r--r--src/buildtool/execution_api/local/local_api.hpp3
-rw-r--r--src/buildtool/execution_api/remote/bazel/bazel_api.cpp23
-rw-r--r--src/buildtool/execution_api/remote/bazel/bazel_network_reader.cpp9
-rw-r--r--src/buildtool/serve_api/remote/target_client.cpp3
-rw-r--r--src/buildtool/serve_api/serve_service/target.cpp11
11 files changed, 61 insertions, 51 deletions
diff --git a/src/buildtool/common/artifact_digest.hpp b/src/buildtool/common/artifact_digest.hpp
index 987e654a..d7683d60 100644
--- a/src/buildtool/common/artifact_digest.hpp
+++ b/src/buildtool/common/artifact_digest.hpp
@@ -63,13 +63,14 @@ class ArtifactDigest final {
[[nodiscard]] auto size() const noexcept -> std::size_t { return size_; }
[[nodiscard]] auto IsTree() const noexcept -> bool { return is_tree_; }
- // NOLINTNEXTLINE allow implicit casts
- [[nodiscard]] operator bazel_re::Digest() const {
+ [[nodiscard]] explicit operator bazel_re::Digest() const {
return CreateBazelDigest(hash_, size_, is_tree_);
}
[[nodiscard]] auto operator==(ArtifactDigest const& other) const -> bool {
- return std::equal_to<bazel_re::Digest>{}(*this, other);
+ return std::equal_to<bazel_re::Digest>{}(
+ static_cast<bazel_re::Digest>(*this),
+ static_cast<bazel_re::Digest>(other));
}
template <ObjectType kType>
diff --git a/src/buildtool/execution_api/execution_service/bytestream_server.cpp b/src/buildtool/execution_api/execution_service/bytestream_server.cpp
index 1b2aad14..4a3fa300 100644
--- a/src/buildtool/execution_api/execution_service/bytestream_server.cpp
+++ b/src/buildtool/execution_api/execution_service/bytestream_server.cpp
@@ -181,15 +181,9 @@ auto BytestreamServiceImpl::Write(
}
// Store blob and verify hash
- std::optional<bazel_re::Digest> stored;
- if (is_tree) {
- stored = storage_.CAS().StoreTree</*kOwner=*/true>(tmp);
- }
- else {
- stored = storage_.CAS().StoreBlob</*kOwner=*/true>(
- tmp, /*is_executable=*/false);
- }
-
+ auto const stored = is_tree ? storage_.CAS().StoreTree</*kOwner=*/true>(tmp)
+ : storage_.CAS().StoreBlob</*kOwner=*/true>(
+ tmp, /*is_executable=*/false);
if (not stored) {
// This is a serious problem: we have a sequence of bytes, but cannot
// write them to CAS.
@@ -198,7 +192,7 @@ auto BytestreamServiceImpl::Write(
return ::grpc::Status{::grpc::StatusCode::INTERNAL, str};
}
- if (stored->hash() != *hash) {
+ if (static_cast<bazel_re::Digest>(*stored).hash() != *hash) {
// User error: did not get a file with the announced hash
auto str = fmt::format("In upload for {} received object with hash {}",
*hash,
diff --git a/src/buildtool/execution_api/execution_service/cas_server.cpp b/src/buildtool/execution_api/execution_service/cas_server.cpp
index 2c2260ac..841243fc 100644
--- a/src/buildtool/execution_api/execution_service/cas_server.cpp
+++ b/src/buildtool/execution_api/execution_service/cas_server.cpp
@@ -60,14 +60,14 @@ inline constexpr std::size_t kSHA256Length = 64;
}
[[nodiscard]] auto CheckDigestConsistency(
- bazel_re::Digest const& ref,
- bazel_re::Digest const& computed) noexcept -> std::optional<std::string> {
+ ArtifactDigest const& ref,
+ ArtifactDigest const& computed) noexcept -> std::optional<std::string> {
bool valid = ref.hash() == computed.hash();
if (valid) {
bool const check_sizes =
- Compatibility::IsCompatible() or ref.size_bytes() != 0;
+ Compatibility::IsCompatible() or ref.size() != 0;
if (check_sizes) {
- valid = ref.size_bytes() == computed.size_bytes();
+ valid = ref.size() == computed.size();
}
}
if (not valid) {
@@ -76,9 +76,9 @@ inline constexpr std::size_t kSHA256Length = 64;
"from data {}:{} do not correspond.",
ref.hash(),
ref.hash(),
- ref.size_bytes(),
+ ref.size(),
computed.hash(),
- computed.size_bytes());
+ computed.size());
}
return std::nullopt;
}
@@ -373,6 +373,7 @@ auto CASServiceImpl::SpliceBlob(::grpc::ServerContext* /*context*/,
return ::grpc::Status{grpc::StatusCode::INVALID_ARGUMENT, str};
}
- response->mutable_blob_digest()->CopyFrom(*splice_result);
+ (*response->mutable_blob_digest()) =
+ static_cast<bazel_re::Digest>(*splice_result);
return ::grpc::Status::OK;
}
diff --git a/src/buildtool/execution_api/execution_service/execution_server.cpp b/src/buildtool/execution_api/execution_service/execution_server.cpp
index c89f06fe..65e63ce9 100644
--- a/src/buildtool/execution_api/execution_service/execution_server.cpp
+++ b/src/buildtool/execution_api/execution_service/execution_server.cpp
@@ -109,7 +109,8 @@ auto ExecutionServiceImpl::ToBazelExecuteResponse(
fmt::format("Could not store stderr of action {}",
i_execution_response->ActionDigest())};
}
- action_result.mutable_stderr_digest()->CopyFrom(*cas_digest);
+ (*action_result.mutable_stderr_digest()) =
+ static_cast<bazel_re::Digest>(*cas_digest);
}
if (i_execution_response->HasStdOut()) {
@@ -121,7 +122,8 @@ auto ExecutionServiceImpl::ToBazelExecuteResponse(
fmt::format("Could not store stdout of action {}",
i_execution_response->ActionDigest())};
}
- action_result.mutable_stdout_digest()->CopyFrom(*cas_digest);
+ (*action_result.mutable_stdout_digest()) =
+ static_cast<bazel_re::Digest>(*cas_digest);
}
::bazel_re::ExecuteResponse bazel_response{};
@@ -282,11 +284,13 @@ namespace {
digest.hash());
return unexpected{std::move(error)};
}
- *(out_dir.mutable_tree_digest()) = *std::move(cas_digest);
+ (*out_dir.mutable_tree_digest()) =
+ static_cast<bazel_re::Digest>(*cas_digest);
}
else {
// In native mode: Set the directory digest directly.
- *(out_dir.mutable_tree_digest()) = digest;
+ (*out_dir.mutable_tree_digest()) =
+ static_cast<bazel_re::Digest>(digest);
}
return std::move(out_dir);
}
@@ -320,8 +324,8 @@ namespace {
Artifact::ObjectInfo const& info) noexcept
-> ::bazel_re::OutputFile {
::bazel_re::OutputFile out_file{};
- *(out_file.mutable_path()) = std::move(path);
- *(out_file.mutable_digest()) = info.digest;
+ (*out_file.mutable_path()) = std::move(path);
+ (*out_file.mutable_digest()) = static_cast<bazel_re::Digest>(info.digest);
out_file.set_is_executable(IsExecutableObject(info.type));
return out_file;
}
diff --git a/src/buildtool/execution_api/local/local_action.cpp b/src/buildtool/execution_api/local/local_action.cpp
index fd742f76..4a2dcfbc 100644
--- a/src/buildtool/execution_api/local/local_action.cpp
+++ b/src/buildtool/execution_api/local/local_action.cpp
@@ -58,7 +58,7 @@ class BuildCleanupAnchor {
[[nodiscard]] auto CreateDigestFromLocalOwnedTree(
Storage const& storage,
- std::filesystem::path const& dir_path) -> std::optional<bazel_re::Digest> {
+ std::filesystem::path const& dir_path) -> std::optional<ArtifactDigest> {
auto const& cas = storage.CAS();
auto store_blob = [&cas](std::filesystem::path const& path,
auto is_exec) -> std::optional<ArtifactDigest> {
@@ -423,8 +423,8 @@ auto LocalAction::CollectOutputDirOrSymlink(
*local_context_.storage, dir_path)) {
auto out_dir = bazel_re::OutputDirectory{};
out_dir.set_path(local_path);
- out_dir.set_allocated_tree_digest(
- gsl::owner<bazel_re::Digest*>{new bazel_re::Digest{*digest}});
+ (*out_dir.mutable_tree_digest()) =
+ static_cast<bazel_re::Digest>(*digest);
return out_dir;
}
}
diff --git a/src/buildtool/execution_api/local/local_action.hpp b/src/buildtool/execution_api/local/local_action.hpp
index 4d256302..8cc12aba 100644
--- a/src/buildtool/execution_api/local/local_action.hpp
+++ b/src/buildtool/execution_api/local/local_action.hpp
@@ -95,12 +95,13 @@ class LocalAction final : public IExecutionAction {
std::sort(output_dirs_.begin(), output_dirs_.end());
}
- [[nodiscard]] auto CreateActionDigest(bazel_re::Digest const& exec_dir,
+ [[nodiscard]] auto CreateActionDigest(ArtifactDigest const& exec_dir,
bool do_not_cache)
-> std::optional<bazel_re::Digest> {
auto const env_vars = BazelMsgFactory::CreateMessageVectorFromMap<
bazel_re::Command_EnvironmentVariable>(env_vars_);
+ auto const bazel_exec_dir = static_cast<bazel_re::Digest>(exec_dir);
BazelMsgFactory::ActionDigestRequest request{
.command_line = &cmdline_,
.cwd = &cwd_,
@@ -108,7 +109,7 @@ class LocalAction final : public IExecutionAction {
.output_dirs = &output_dirs_,
.env_vars = &env_vars,
.properties = &properties_,
- .exec_dir = &exec_dir,
+ .exec_dir = &bazel_exec_dir,
.hash_function = local_context_.storage_config->hash_function,
.timeout = timeout_,
.skip_action_cache = do_not_cache};
diff --git a/src/buildtool/execution_api/local/local_api.hpp b/src/buildtool/execution_api/local/local_api.hpp
index 6fd7456a..0c6e9a1f 100644
--- a/src/buildtool/execution_api/local/local_api.hpp
+++ b/src/buildtool/execution_api/local/local_api.hpp
@@ -266,8 +266,7 @@ class LocalApi final : public IExecutionApi {
is_tree ? local_context_.storage->CAS().StoreTree(*blob.data)
: local_context_.storage->CAS().StoreBlob(*blob.data,
blob.is_exec);
- if (not cas_digest or not std::equal_to<bazel_re::Digest>{}(
- *cas_digest, blob.digest)) {
+ if (not cas_digest or *cas_digest != blob.digest) {
return false;
}
}
diff --git a/src/buildtool/execution_api/remote/bazel/bazel_api.cpp b/src/buildtool/execution_api/remote/bazel/bazel_api.cpp
index 2f8d5d08..e1d57b9b 100644
--- a/src/buildtool/execution_api/remote/bazel/bazel_api.cpp
+++ b/src/buildtool/execution_api/remote/bazel/bazel_api.cpp
@@ -170,7 +170,9 @@ namespace {
try {
blobs.reserve(container.Size());
for (const auto& blob : container.Blobs()) {
- blobs.emplace_back(blob.digest, blob.data, blob.is_exec);
+ blobs.emplace_back(static_cast<bazel_re::Digest>(blob.digest),
+ blob.data,
+ blob.is_exec);
}
} catch (...) {
return std::nullopt;
@@ -211,14 +213,15 @@ auto BazelApi::CreateAction(
std::map<std::string, std::string> const& env_vars,
std::map<std::string, std::string> const& properties) const noexcept
-> IExecutionAction::Ptr {
- return std::unique_ptr<BazelAction>{new BazelAction{network_,
- root_digest,
- command,
- cwd,
- output_files,
- output_dirs,
- env_vars,
- properties}};
+ return std::unique_ptr<BazelAction>{
+ new BazelAction{network_,
+ static_cast<bazel_re::Digest>(root_digest),
+ command,
+ cwd,
+ output_files,
+ output_dirs,
+ env_vars,
+ properties}};
}
// NOLINTNEXTLINE(misc-no-recursion, google-default-arguments)
@@ -549,7 +552,7 @@ auto BazelApi::CreateAction(
[[nodiscard]] auto BazelApi::IsAvailable(
ArtifactDigest const& digest) const noexcept -> bool {
- return network_->IsAvailable(digest);
+ return network_->IsAvailable(static_cast<bazel_re::Digest>(digest));
}
[[nodiscard]] auto BazelApi::IsAvailable(
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 9b24bc80..09ebb662 100644
--- a/src/buildtool/execution_api/remote/bazel/bazel_network_reader.cpp
+++ b/src/buildtool/execution_api/remote/bazel/bazel_network_reader.cpp
@@ -41,8 +41,10 @@ BazelNetworkReader::BazelNetworkReader(
if (Compatibility::IsCompatible() and request_remote_tree) {
// Query full tree from remote CAS. Note that this is currently not
// supported by Buildbarn revision c3c06bbe2a.
- auto full_tree = cas_.GetTree(
- instance_name_, *request_remote_tree, kMaxBatchTransferSize);
+ auto full_tree =
+ cas_.GetTree(instance_name_,
+ static_cast<bazel_re::Digest>(*request_remote_tree),
+ kMaxBatchTransferSize);
auxiliary_map_ = MakeAuxiliaryMap(std::move(full_tree));
}
}
@@ -122,7 +124,8 @@ auto BazelNetworkReader::DumpRawTree(Artifact::ObjectInfo const& info,
auto BazelNetworkReader::DumpBlob(Artifact::ObjectInfo const& info,
DumpCallback const& dumper) const noexcept
-> bool {
- auto reader = cas_.IncrementalReadSingleBlob(instance_name_, info.digest);
+ auto reader = cas_.IncrementalReadSingleBlob(
+ instance_name_, static_cast<bazel_re::Digest>(info.digest));
auto data = reader.Next();
while (data and not data->empty()) {
try {
diff --git a/src/buildtool/serve_api/remote/target_client.cpp b/src/buildtool/serve_api/remote/target_client.cpp
index c3f636f4..85a6eefc 100644
--- a/src/buildtool/serve_api/remote/target_client.cpp
+++ b/src/buildtool/serve_api/remote/target_client.cpp
@@ -101,7 +101,8 @@ auto TargetClient::ServeTarget(const TargetCacheKey& key,
fmt::format("Failed to upload blob {} to remote cas",
dispatch_info.ToString())};
}
- request.mutable_dispatch_info()->CopyFrom(*dispatch_dgst);
+ (*request.mutable_dispatch_info()) =
+ static_cast<bazel_re::Digest>(*dispatch_dgst);
// call rpc
grpc::ClientContext context;
diff --git a/src/buildtool/serve_api/serve_service/target.cpp b/src/buildtool/serve_api/serve_service/target.cpp
index 85a01fd1..d2e66ae0 100644
--- a/src/buildtool/serve_api/serve_service/target.cpp
+++ b/src/buildtool/serve_api/serve_service/target.cpp
@@ -114,7 +114,7 @@ auto TargetService::HandleFailureLog(
return ::grpc::Status{::grpc::StatusCode::UNAVAILABLE, msg};
}
// set response with log digest
- response->mutable_log()->CopyFrom(*digest);
+ (*response->mutable_log()) = static_cast<bazel_re::Digest>(*digest);
return ::grpc::Status::OK;
}
@@ -232,7 +232,8 @@ auto TargetService::ServeTarget(
return ::grpc::Status{::grpc::StatusCode::UNAVAILABLE, msg};
}
// populate response with the target cache value
- response->mutable_target_value()->CopyFrom(target_entry->second.digest);
+ (*response->mutable_target_value()) =
+ static_cast<bazel_re::Digest>(target_entry->second.digest);
return ::grpc::Status::OK;
}
@@ -572,7 +573,8 @@ auto TargetService::ServeTarget(
return ::grpc::Status{::grpc::StatusCode::UNAVAILABLE, msg};
}
// populate response with the target cache value
- response->mutable_target_value()->CopyFrom(target_entry->second.digest);
+ (*response->mutable_target_value()) =
+ static_cast<bazel_re::Digest>(target_entry->second.digest);
return ::grpc::Status::OK;
}
@@ -928,7 +930,8 @@ auto TargetService::ServeTargetDescription(
}
// populate response
- response->mutable_description_id()->CopyFrom(*dgst);
+ (*response->mutable_description_id()) =
+ static_cast<bazel_re::Digest>(*dgst);
return ::grpc::Status::OK;
}
// failed to store blob