summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/buildtool/execution_engine/executor/executor.hpp7
-rw-r--r--src/buildtool/profile/TARGETS1
-rw-r--r--src/buildtool/profile/profile.cpp17
-rw-r--r--src/buildtool/profile/profile.hpp3
4 files changed, 22 insertions, 6 deletions
diff --git a/src/buildtool/execution_engine/executor/executor.hpp b/src/buildtool/execution_engine/executor/executor.hpp
index 7015f559..d47397f0 100644
--- a/src/buildtool/execution_engine/executor/executor.hpp
+++ b/src/buildtool/execution_engine/executor/executor.hpp
@@ -928,7 +928,9 @@ class Executor {
context_.progress);
if (context_.profile) {
(*context_.profile)
- ->NoteActionCompleted(action->Content().Id(), *response);
+ ->NoteActionCompleted(action->Content().Id(),
+ *response,
+ action->Content().Cwd());
}
return result;
}
@@ -956,7 +958,8 @@ class Executor {
logger, *response, action, context_.statistics, context_.progress);
if (context_.profile) {
(*context_.profile)
- ->NoteActionCompleted(action->Content().Id(), *response);
+ ->NoteActionCompleted(
+ action->Content().Id(), *response, action->Content().Cwd());
}
return result;
}
diff --git a/src/buildtool/profile/TARGETS b/src/buildtool/profile/TARGETS
index 318ed075..7906c2b4 100644
--- a/src/buildtool/profile/TARGETS
+++ b/src/buildtool/profile/TARGETS
@@ -13,6 +13,7 @@
, ["src/buildtool/common", "cli"]
, ["src/buildtool/common", "common"]
, ["src/utils/cpp", "expected"]
+ , ["src/utils/cpp", "path_rebase"]
]
, "stage": ["src", "buildtool", "profile"]
}
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());
+ }
}
}
}
diff --git a/src/buildtool/profile/profile.hpp b/src/buildtool/profile/profile.hpp
index 82a23a94..9067a309 100644
--- a/src/buildtool/profile/profile.hpp
+++ b/src/buildtool/profile/profile.hpp
@@ -38,7 +38,8 @@ class Profile {
void SetTarget(nlohmann::json target);
void SetConfiguration(nlohmann::json configuration);
void NoteActionCompleted(std::string const& id,
- IExecutionResponse::Ptr const& response);
+ IExecutionResponse::Ptr const& response,
+ std::string const& cwd);
private:
struct ActionData {