From dd02daeb0ce20780ed96c4ab2738a7f2b8b986e5 Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Mon, 17 Mar 2025 12:43:05 +0100 Subject: just profile: include output artifact hashes --- src/buildtool/profile/TARGETS | 5 +++++ src/buildtool/profile/profile.cpp | 24 ++++++++++++++++++++++-- src/buildtool/profile/profile.hpp | 1 + 3 files changed, 28 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/buildtool/profile/TARGETS b/src/buildtool/profile/TARGETS index 657758ba..9f4db4d8 100644 --- a/src/buildtool/profile/TARGETS +++ b/src/buildtool/profile/TARGETS @@ -7,6 +7,11 @@ [ ["@", "json", "", "json"] , ["src/buildtool/execution_api/common", "common"] ] + , "private-deps": + [ ["@", "gsl", "", "gsl"] + , ["src/buildtool/common", "common"] + , ["src/utils/cpp", "expected"] + ] , "stage": ["src", "buildtool", "profile"] } } diff --git a/src/buildtool/profile/profile.cpp b/src/buildtool/profile/profile.cpp index 9a7eaf7d..66ea50d6 100644 --- a/src/buildtool/profile/profile.cpp +++ b/src/buildtool/profile/profile.cpp @@ -16,6 +16,10 @@ #include +#include "gsl/gsl" +#include "src/buildtool/common/artifact_digest.hpp" +#include "src/utils/cpp/expected.hpp" + void Profile::Write(int exit_code) { if (not output_file_) { return; @@ -29,6 +33,7 @@ void Profile::Write(int exit_code) { if (not v.cached) { entry["duration"] = v.duration; } + entry["artifacts"] = v.artifacts; actions[k] = entry; } profile_["actions"] = actions; @@ -51,6 +56,21 @@ void Profile::SetConfiguration(nlohmann::json configuration) { void Profile::NoteActionCompleted(std::string const& id, IExecutionResponse::Ptr const& response) { std::unique_lock lock{mutex_}; - actions_[id] = ActionData{.cached = response->IsCached(), - .duration = response->ExecutionDuration()}; + auto artifacts = response->Artifacts(); + if (not artifacts) { + actions_[id] = ActionData{ + .cached = response->IsCached(), + .duration = response->ExecutionDuration(), + .artifacts = std::unordered_map()}; + } + else { + actions_[id] = ActionData{ + .cached = response->IsCached(), + .duration = response->ExecutionDuration(), + .artifacts = std::unordered_map( + (*artifacts)->size())}; + for (auto const& [k, v] : **artifacts) { + actions_[id].artifacts.emplace(k, v.digest.hash()); + } + } } diff --git a/src/buildtool/profile/profile.hpp b/src/buildtool/profile/profile.hpp index 60f8f007..7e03b0ae 100644 --- a/src/buildtool/profile/profile.hpp +++ b/src/buildtool/profile/profile.hpp @@ -42,6 +42,7 @@ class Profile { struct ActionData { bool cached; double duration; + std::unordered_map artifacts; }; std::optional output_file_; -- cgit v1.2.3