diff options
Diffstat (limited to 'src')
3 files changed, 25 insertions, 11 deletions
diff --git a/src/buildtool/execution_api/remote/bazel/bazel_api.cpp b/src/buildtool/execution_api/remote/bazel/bazel_api.cpp index f4fd3b1f..c4f170a3 100644 --- a/src/buildtool/execution_api/remote/bazel/bazel_api.cpp +++ b/src/buildtool/execution_api/remote/bazel/bazel_api.cpp @@ -142,7 +142,7 @@ auto BazelApi::CreateAction( [[nodiscard]] auto BazelApi::RetrieveToFds( std::vector<Artifact::ObjectInfo> const& artifacts_info, std::vector<int> const& fds, - bool /*raw_tree*/) noexcept -> bool { + bool raw_tree) noexcept -> bool { if (artifacts_info.size() != fds.size()) { Logger::Log(LogLevel::Error, "different number of digests and file descriptors."); @@ -154,7 +154,7 @@ auto BazelApi::CreateAction( auto const& info = artifacts_info[i]; if (gsl::owner<FILE*> out = fdopen(fd, "wb")) { // NOLINT - auto const success = network_->DumpToStream(info, out); + auto const success = network_->DumpToStream(info, out, raw_tree); std::fclose(out); if (not success) { Logger::Log(LogLevel::Error, diff --git a/src/buildtool/execution_api/remote/bazel/bazel_network.cpp b/src/buildtool/execution_api/remote/bazel/bazel_network.cpp index 60ed22e1..538f2633 100644 --- a/src/buildtool/execution_api/remote/bazel/bazel_network.cpp +++ b/src/buildtool/execution_api/remote/bazel/bazel_network.cpp @@ -79,7 +79,20 @@ namespace { [[nodiscard]] auto TreeToStream( gsl::not_null<BazelNetwork const*> const& network, bazel_re::Digest const& tree_digest, - gsl::not_null<FILE*> const& stream) noexcept -> bool { + gsl::not_null<FILE*> const& stream, + bool raw_tree) noexcept -> bool { + if (raw_tree) { + auto blobs = network->ReadBlobs({tree_digest}).Next(); + if (blobs.size() != 1) { + Logger::Log(LogLevel::Error, + "Object {} not found in CAS", + NativeSupport::Unprefix(tree_digest.hash())); + return false; + } + auto const& str = blobs.at(0).data; + std::fwrite(str.data(), 1, str.size(), stream); + return true; + } if (Compatibility::IsCompatible()) { if (auto dir = ReadDirectory(network, tree_digest)) { if (auto data = BazelMsgFactory::DirectoryToString(*dir)) { @@ -423,9 +436,10 @@ auto BazelNetwork::ReadObjectInfosRecursively( return false; } -auto BazelNetwork::DumpToStream( - Artifact::ObjectInfo const& info, - gsl::not_null<FILE*> const& stream) const noexcept -> bool { - return IsTreeObject(info.type) ? TreeToStream(this, info.digest, stream) - : BlobToStream(this, info.digest, stream); +auto BazelNetwork::DumpToStream(Artifact::ObjectInfo const& info, + gsl::not_null<FILE*> const& stream, + bool raw_tree) const noexcept -> bool { + return IsTreeObject(info.type) + ? TreeToStream(this, info.digest, stream, raw_tree) + : BlobToStream(this, info.digest, stream); } diff --git a/src/buildtool/execution_api/remote/bazel/bazel_network.hpp b/src/buildtool/execution_api/remote/bazel/bazel_network.hpp index c1ae34ad..e513b23e 100644 --- a/src/buildtool/execution_api/remote/bazel/bazel_network.hpp +++ b/src/buildtool/execution_api/remote/bazel/bazel_network.hpp @@ -119,9 +119,9 @@ class BazelNetwork { -> std::optional<std::pair<std::vector<std::filesystem::path>, std::vector<Artifact::ObjectInfo>>>; - [[nodiscard]] auto DumpToStream( - Artifact::ObjectInfo const& info, - gsl::not_null<FILE*> const& stream) const noexcept -> bool; + [[nodiscard]] auto DumpToStream(Artifact::ObjectInfo const& info, + gsl::not_null<FILE*> const& stream, + bool raw_tree) const noexcept -> bool; private: using DirectoryMap = |