diff options
author | Oliver Reiche <oliver.reiche@huawei.com> | 2025-06-23 12:19:43 +0200 |
---|---|---|
committer | Oliver Reiche <oliver.reiche@huawei.com> | 2025-06-24 12:56:57 +0200 |
commit | c498bf564fa5d781c176f65c7a9a2d43376a81f1 (patch) | |
tree | eb6a1378fc2ded735fd3bb24e8c52152f448029b /src/buildtool/execution_api/remote/bazel | |
parent | 95f230b3a755f66183ce5c27e929ed6ae3838977 (diff) | |
download | justbuild-c498bf564fa5d781c176f65c7a9a2d43376a81f1.tar.gz |
ExecutionAPI: Support output_symlinks in response
Diffstat (limited to 'src/buildtool/execution_api/remote/bazel')
-rw-r--r-- | src/buildtool/execution_api/remote/bazel/bazel_response.cpp | 30 | ||||
-rw-r--r-- | src/buildtool/execution_api/remote/bazel/bazel_response.hpp | 1 |
2 files changed, 23 insertions, 8 deletions
diff --git a/src/buildtool/execution_api/remote/bazel/bazel_response.cpp b/src/buildtool/execution_api/remote/bazel/bazel_response.cpp index 5d826a1b..060239f7 100644 --- a/src/buildtool/execution_api/remote/bazel/bazel_response.cpp +++ b/src/buildtool/execution_api/remote/bazel/bazel_response.cpp @@ -111,10 +111,6 @@ auto BazelResponse::Populate() noexcept -> std::optional<std::string> { action_result.output_directory_symlinks_size()) + static_cast<std::size_t>(action_result.output_directories_size())); - DirSymlinks dir_symlinks{}; - dir_symlinks.reserve(static_cast<std::size_t>( - action_result.output_directory_symlinks_size())); - auto const hash_type = network_->GetHashFunction().GetType(); // collect files and store them for (auto const& file : action_result.output_files()) { @@ -142,7 +138,29 @@ auto BazelResponse::Populate() noexcept -> std::optional<std::string> { } // collect all symlinks and store them + for (auto const& link : action_result.output_symlinks()) { + try { + // in compatible mode: track upwards symlinks + has_upwards_symlinks_ = has_upwards_symlinks_ or + (not ProtocolTraits::IsNative(hash_type) and + not PathIsNonUpwards(link.target())); + artifacts.emplace( + link.path(), + Artifact::ObjectInfo{ + .digest = + ArtifactDigestFactory::HashDataAs<ObjectType::File>( + network_->GetHashFunction(), link.target()), + .type = ObjectType::Symlink}); + } catch (std::exception const& ex) { + return fmt::format( + "BazelResponse: unexpected failure gathering digest for " + "{}:\n{}", + link.path(), + ex.what()); + } + } for (auto const& link : action_result.output_file_symlinks()) { + // DEPRECATED as of v2.1 try { // in compatible mode: track upwards symlinks has_upwards_symlinks_ = has_upwards_symlinks_ or @@ -164,6 +182,7 @@ auto BazelResponse::Populate() noexcept -> std::optional<std::string> { } } for (auto const& link : action_result.output_directory_symlinks()) { + // DEPRECATED as of v2.1 try { // in compatible mode: track upwards symlinks has_upwards_symlinks_ = has_upwards_symlinks_ or @@ -176,7 +195,6 @@ auto BazelResponse::Populate() noexcept -> std::optional<std::string> { ArtifactDigestFactory::HashDataAs<ObjectType::File>( network_->GetHashFunction(), link.target()), .type = ObjectType::Symlink}); - dir_symlinks.emplace(link.path()); // add it to set } catch (std::exception const& ex) { return fmt::format( "BazelResponse: unexpected failure gathering digest for " @@ -211,7 +229,6 @@ auto BazelResponse::Populate() noexcept -> std::optional<std::string> { } } artifacts_ = std::move(artifacts); - dir_symlinks_ = std::move(dir_symlinks); populated_ = true; return std::nullopt; } @@ -273,7 +290,6 @@ auto BazelResponse::Populate() noexcept -> std::optional<std::string> { ++pos; } artifacts_ = std::move(artifacts); - dir_symlinks_ = std::move(dir_symlinks); populated_ = true; return std::nullopt; } diff --git a/src/buildtool/execution_api/remote/bazel/bazel_response.hpp b/src/buildtool/execution_api/remote/bazel/bazel_response.hpp index 8504ae59..2b890da6 100644 --- a/src/buildtool/execution_api/remote/bazel/bazel_response.hpp +++ b/src/buildtool/execution_api/remote/bazel/bazel_response.hpp @@ -96,7 +96,6 @@ class BazelResponse final : public IExecutionResponse { std::shared_ptr<BazelNetwork> const network_; BazelExecutionClient::ExecutionOutput output_{}; ArtifactInfos artifacts_; - DirSymlinks dir_symlinks_; bool has_upwards_symlinks_ = false; // only tracked in compatible mode bool populated_ = false; |