diff options
author | Klaus Aehlig <klaus.aehlig@huawei.com> | 2025-03-17 14:31:58 +0100 |
---|---|---|
committer | Klaus Aehlig <klaus.aehlig@huawei.com> | 2025-03-17 17:19:55 +0100 |
commit | b1ccb71a4bdbacd44843abfa9497576016962ed8 (patch) | |
tree | 8067a825669baf7ca2dfd98f43da9d6c70c3e23f /src | |
parent | dd02daeb0ce20780ed96c4ab2738a7f2b8b986e5 (diff) | |
download | justbuild-b1ccb71a4bdbacd44843abfa9497576016962ed8.tar.gz |
execution_api: support reading off stdout/stderr digests
Diffstat (limited to 'src')
3 files changed, 46 insertions, 0 deletions
diff --git a/src/buildtool/execution_api/common/execution_response.hpp b/src/buildtool/execution_api/common/execution_response.hpp index 9899584f..882750fe 100644 --- a/src/buildtool/execution_api/common/execution_response.hpp +++ b/src/buildtool/execution_api/common/execution_response.hpp @@ -17,12 +17,14 @@ #include <cstdint> #include <memory> +#include <optional> #include <string> #include <unordered_map> #include <unordered_set> #include "gsl/gsl" #include "src/buildtool/common/artifact.hpp" +#include "src/buildtool/common/artifact_digest.hpp" #include "src/utils/cpp/expected.hpp" /// \brief Abstract response. @@ -54,6 +56,12 @@ class IExecutionResponse { [[nodiscard]] virtual auto HasStdOut() const noexcept -> bool = 0; + [[nodiscard]] virtual auto StdErrDigest() noexcept + -> std::optional<ArtifactDigest> = 0; + + [[nodiscard]] virtual auto StdOutDigest() noexcept + -> std::optional<ArtifactDigest> = 0; + [[nodiscard]] virtual auto StdErr() noexcept -> std::string = 0; [[nodiscard]] virtual auto StdOut() noexcept -> std::string = 0; diff --git a/src/buildtool/execution_api/local/local_response.hpp b/src/buildtool/execution_api/local/local_response.hpp index 5c0dcd0a..852284b7 100644 --- a/src/buildtool/execution_api/local/local_response.hpp +++ b/src/buildtool/execution_api/local/local_response.hpp @@ -72,6 +72,24 @@ class LocalResponse final : public IExecutionResponse { Logger::Log(LogLevel::Debug, "reading stdout failed"); return {}; } + auto StdErrDigest() noexcept -> std::optional<ArtifactDigest> final { + auto digest = ArtifactDigestFactory::FromBazel( + storage_.GetHashFunction().GetType(), + output_.action.stderr_digest()); + if (digest) { + return *digest; + } + return std::nullopt; + } + auto StdOutDigest() noexcept -> std::optional<ArtifactDigest> final { + auto digest = ArtifactDigestFactory::FromBazel( + storage_.GetHashFunction().GetType(), + output_.action.stdout_digest()); + if (digest) { + return *digest; + } + return std::nullopt; + } auto ExitCode() const noexcept -> int final { return output_.action.exit_code(); } diff --git a/src/buildtool/execution_api/remote/bazel/bazel_response.hpp b/src/buildtool/execution_api/remote/bazel/bazel_response.hpp index b24763e0..df652141 100644 --- a/src/buildtool/execution_api/remote/bazel/bazel_response.hpp +++ b/src/buildtool/execution_api/remote/bazel/bazel_response.hpp @@ -25,7 +25,9 @@ #include "gsl/gsl" #include "src/buildtool/common/artifact_digest.hpp" +#include "src/buildtool/common/artifact_digest_factory.hpp" #include "src/buildtool/common/bazel_types.hpp" +#include "src/buildtool/crypto/hash_function.hpp" #include "src/buildtool/execution_api/common/execution_response.hpp" #include "src/buildtool/execution_api/remote/bazel/bazel_execution_client.hpp" #include "src/buildtool/execution_api/remote/bazel/bazel_network.hpp" @@ -52,6 +54,24 @@ class BazelResponse final : public IExecutionResponse { auto StdOut() noexcept -> std::string final { return ReadStringBlob(output_.action_result.stdout_digest()); } + auto StdErrDigest() noexcept -> std::optional<ArtifactDigest> final { + auto digest = ArtifactDigestFactory::FromBazel( + network_->GetHashFunction().GetType(), + output_.action_result.stderr_digest()); + if (digest) { + return *digest; + } + return std::nullopt; + } + auto StdOutDigest() noexcept -> std::optional<ArtifactDigest> final { + auto digest = ArtifactDigestFactory::FromBazel( + network_->GetHashFunction().GetType(), + output_.action_result.stdout_digest()); + if (digest) { + return *digest; + } + return std::nullopt; + } auto ExitCode() const noexcept -> int final { return output_.action_result.exit_code(); } |