diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/buildtool/profile/TARGETS | 5 | ||||
-rw-r--r-- | src/buildtool/profile/profile.cpp | 24 | ||||
-rw-r--r-- | src/buildtool/profile/profile.hpp | 1 |
3 files changed, 28 insertions, 2 deletions
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 <fstream> +#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<std::string, std::string>()}; + } + else { + actions_[id] = ActionData{ + .cached = response->IsCached(), + .duration = response->ExecutionDuration(), + .artifacts = std::unordered_map<std::string, std::string>( + (*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<std::string, std::string> artifacts; }; std::optional<std::string> output_file_; |