From c3fdcb7d3b072f6fd62a7b64a18fb55f2e7bcdde Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Mon, 17 Mar 2025 15:34:05 +0100 Subject: just profile: include action stdout/stderr if any --- src/buildtool/profile/profile.cpp | 24 ++++++++++++++++++++++++ src/buildtool/profile/profile.hpp | 2 ++ 2 files changed, 26 insertions(+) (limited to 'src') diff --git a/src/buildtool/profile/profile.cpp b/src/buildtool/profile/profile.cpp index 66ea50d6..6d1cc34d 100644 --- a/src/buildtool/profile/profile.cpp +++ b/src/buildtool/profile/profile.cpp @@ -34,6 +34,12 @@ void Profile::Write(int exit_code) { entry["duration"] = v.duration; } entry["artifacts"] = v.artifacts; + if (v.out) { + entry["stdout"] = *v.out; + } + if (v.err) { + entry["stderr"] = *v.err; + } actions[k] = entry; } profile_["actions"] = actions; @@ -57,16 +63,34 @@ void Profile::NoteActionCompleted(std::string const& id, IExecutionResponse::Ptr const& response) { std::unique_lock lock{mutex_}; auto artifacts = response->Artifacts(); + std::optional out = std::nullopt; + std::optional err = std::nullopt; + if (response->HasStdOut()) { + auto action_out = response->StdOutDigest(); + if (action_out) { + out = action_out->hash(); + } + } + if (response->HasStdErr()) { + auto action_err = response->StdErrDigest(); + if (action_err) { + err = action_err->hash(); + } + } if (not artifacts) { actions_[id] = ActionData{ .cached = response->IsCached(), .duration = response->ExecutionDuration(), + .out = out, + .err = err, .artifacts = std::unordered_map()}; } else { actions_[id] = ActionData{ .cached = response->IsCached(), .duration = response->ExecutionDuration(), + .out = out, + .err = err, .artifacts = std::unordered_map( (*artifacts)->size())}; for (auto const& [k, v] : **artifacts) { diff --git a/src/buildtool/profile/profile.hpp b/src/buildtool/profile/profile.hpp index 7e03b0ae..71511245 100644 --- a/src/buildtool/profile/profile.hpp +++ b/src/buildtool/profile/profile.hpp @@ -42,6 +42,8 @@ class Profile { struct ActionData { bool cached; double duration; + std::optional out; + std::optional err; std::unordered_map artifacts; }; -- cgit v1.2.3