diff options
author | Klaus Aehlig <klaus.aehlig@huawei.com> | 2025-04-17 13:18:37 +0200 |
---|---|---|
committer | Klaus Aehlig <klaus.aehlig@huawei.com> | 2025-04-17 13:45:30 +0200 |
commit | d65d711f844224dcf9215c52be8f69fd2885adfc (patch) | |
tree | c366659430d12c15ef8dd114b8893bde34b034e4 /src/buildtool/profile/profile.cpp | |
parent | 1af9c8c55f1543ffe2622e1057bdbf50d0983535 (diff) | |
download | justbuild-d65d711f844224dcf9215c52be8f69fd2885adfc.tar.gz |
profile: also honor action cwd
In all presentations of actions to the user, we use output paths
relative to the root of the action directory. Therefore, we should
do the same in the profile. However, when noting the completion of
an action, we get paths as in the wire protocol, i.e., relative to
the working directory of the action. Therefore, rebase appropriately.
Diffstat (limited to 'src/buildtool/profile/profile.cpp')
-rw-r--r-- | src/buildtool/profile/profile.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/buildtool/profile/profile.cpp b/src/buildtool/profile/profile.cpp index 4655ccf4..bc0560cf 100644 --- a/src/buildtool/profile/profile.cpp +++ b/src/buildtool/profile/profile.cpp @@ -20,6 +20,7 @@ #include "src/buildtool/common/artifact_digest.hpp" #include "src/buildtool/common/cli.hpp" #include "src/utils/cpp/expected.hpp" +#include "src/utils/cpp/path_rebase.hpp" void Profile::Write(int exit_code) { if (not actions_.empty()) { @@ -96,7 +97,8 @@ void Profile::SetCLI(CommandLineArguments const& cli) { } void Profile::NoteActionCompleted(std::string const& id, - IExecutionResponse::Ptr const& response) { + IExecutionResponse::Ptr const& response, + std::string const& cwd) { std::unique_lock lock{mutex_}; auto artifacts = response->Artifacts(); std::optional<std::string> out = std::nullopt; @@ -131,8 +133,17 @@ void Profile::NoteActionCompleted(std::string const& id, .err = err, .artifacts = std::unordered_map<std::string, std::string>( (*artifacts)->size())}; - for (auto const& [k, v] : **artifacts) { - actions_[id].artifacts.emplace(k, v.digest.hash()); + if (cwd.empty()) { + // the typical case of empty cwd, avoid unnecessary calls + for (auto const& [k, v] : **artifacts) { + actions_[id].artifacts.emplace(k, v.digest.hash()); + } + } + else { + for (auto const& [k, v] : **artifacts) { + actions_[id].artifacts.emplace( + RebasePathStringRelativeTo(cwd, k), v.digest.hash()); + } } } } |