diff options
author | Klaus Aehlig <klaus.aehlig@huawei.com> | 2025-03-17 12:43:05 +0100 |
---|---|---|
committer | Klaus Aehlig <klaus.aehlig@huawei.com> | 2025-03-17 17:19:55 +0100 |
commit | dd02daeb0ce20780ed96c4ab2738a7f2b8b986e5 (patch) | |
tree | b224cac1e028059cd81e1e05e44e79fc7d7f2362 /src | |
parent | f2813218ea4ae98b6391c8ea4ec40f80586ff31d (diff) | |
download | justbuild-dd02daeb0ce20780ed96c4ab2738a7f2b8b986e5.tar.gz |
just profile: include output artifact hashes
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_; |