diff options
author | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2023-06-19 12:42:21 +0200 |
---|---|---|
committer | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2023-06-26 17:57:29 +0200 |
commit | 5e3cc5a7a38e93159a81b940b19ced879a2d280c (patch) | |
tree | 7c2d51f424961f14ee7de758c68b2d59a5947930 /src/buildtool/execution_api/execution_service/execution_server.cpp | |
parent | 3865c8556bde5e614dc1e8c72f83fa1ed65abcd9 (diff) | |
download | justbuild-5e3cc5a7a38e93159a81b940b19ced879a2d280c.tar.gz |
Execution response: Add output symlink paths
Diffstat (limited to 'src/buildtool/execution_api/execution_service/execution_server.cpp')
-rw-r--r-- | src/buildtool/execution_api/execution_service/execution_server.cpp | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/src/buildtool/execution_api/execution_service/execution_server.cpp b/src/buildtool/execution_api/execution_service/execution_server.cpp index c34201a1..f2436684 100644 --- a/src/buildtool/execution_api/execution_service/execution_server.cpp +++ b/src/buildtool/execution_api/execution_service/execution_server.cpp @@ -268,11 +268,15 @@ static auto CreateTreeDigestFromDirectoryDigest( static auto AddOutputPaths(::bazel_re::ExecuteResponse* response, IExecutionResponse::Ptr const& execution, Storage const& storage) noexcept -> bool { - auto const& size = static_cast<int>(execution->Artifacts().size()); + auto const& artifacts_plus = execution->ArtifactsWithDirSymlinks(); + auto const& size = static_cast<int>(artifacts_plus.first.size()); response->mutable_result()->mutable_output_files()->Reserve(size); + response->mutable_result()->mutable_output_file_symlinks()->Reserve(size); + response->mutable_result()->mutable_output_directory_symlinks()->Reserve( + size); response->mutable_result()->mutable_output_directories()->Reserve(size); - for (auto const& [path, info] : execution->Artifacts()) { + for (auto const& [path, info] : artifacts_plus.first) { auto dgst = static_cast<::bazel_re::Digest>(info.digest); if (info.type == ObjectType::Tree) { @@ -295,6 +299,32 @@ static auto AddOutputPaths(::bazel_re::ExecuteResponse* response, response->mutable_result()->mutable_output_directories()->Add( std::move(out_dir)); } + else if (info.type == ObjectType::Symlink) { + ::bazel_re::OutputSymlink out_link; + *(out_link.mutable_path()) = path; + // recover the target of the symlink + auto cas_path = + storage.CAS().BlobPath(dgst, /*is_executable=*/false); + if (not cas_path) { + return false; + } + auto const& content = FileSystemManager::ReadFile(*cas_path); + if (not content) { + return false; + } + *(out_link.mutable_target()) = *content; + if (artifacts_plus.second.contains(path)) { + // directory symlink + response->mutable_result() + ->mutable_output_directory_symlinks() + ->Add(std::move(out_link)); + } + else { + // file symlinks + response->mutable_result()->mutable_output_file_symlinks()->Add( + std::move(out_link)); + } + } else { ::bazel_re::OutputFile out_file; *(out_file.mutable_path()) = path; |