summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKlaus Aehlig <klaus.aehlig@huawei.com>2024-02-22 12:10:28 +0100
committerKlaus Aehlig <klaus.aehlig@huawei.com>2024-02-22 12:57:41 +0100
commit48ebca011a754d152defd11b7facf152f92886c8 (patch)
treef2080aa01535d11ed02eedff6592a56d11235bba
parent5f3273fe6fa80057383ad21076dd8eb49d4ad4a8 (diff)
downloadjustbuild-48ebca011a754d152defd11b7facf152f92886c8.tar.gz
Executor: in case of a failing action also report origin
... if provided. This might help users to find the correct place in their code base causing the action to fail.
-rw-r--r--src/buildtool/execution_engine/executor/executor.hpp29
1 files changed, 22 insertions, 7 deletions
diff --git a/src/buildtool/execution_engine/executor/executor.hpp b/src/buildtool/execution_engine/executor/executor.hpp
index 454772ff..dd6ada70 100644
--- a/src/buildtool/execution_engine/executor/executor.hpp
+++ b/src/buildtool/execution_engine/executor/executor.hpp
@@ -21,6 +21,7 @@
#include <iostream>
#include <map>
#include <optional>
+#include <sstream>
#include <type_traits>
#include <utility>
#include <vector>
@@ -532,7 +533,7 @@ class ExecutorImpl {
logger.Emit(LogLevel::Error,
"action returned non-zero exit code {}",
response->ExitCode());
- PrintError(logger, action->Command());
+ PrintError(logger, action);
return false;
}
}
@@ -553,7 +554,7 @@ class ExecutorImpl {
}
return message;
});
- PrintError(logger, action->Command());
+ PrintError(logger, action);
return false;
}
@@ -596,11 +597,25 @@ class ExecutorImpl {
std::move(build_message));
}
- void static PrintError(Logger const& logger,
- std::vector<std::string> const& command) noexcept {
- logger.Emit(LogLevel::Error,
- "Failed to execute command {}",
- nlohmann::json(command).dump());
+ void static PrintError(
+ Logger const& logger,
+ gsl::not_null<DependencyGraph::ActionNode const*> const&
+ action) noexcept {
+ std::ostringstream msg{};
+ msg << "Failed to execute command ";
+ msg << nlohmann::json(action->Command()).dump();
+ auto const& origin_map = Progress::Instance().OriginMap();
+ auto origins = origin_map.find(action->Content().Id());
+ if (origins != origin_map.end() and !origins->second.empty()) {
+ msg << "\nrequested by";
+ for (auto const& origin : origins->second) {
+ msg << "\n - ";
+ msg << origin.first.ToString();
+ msg << "#";
+ msg << origin.second;
+ }
+ }
+ logger.Emit(LogLevel::Error, "{}", msg.str());
}
[[nodiscard]] static inline auto ScaleTime(std::chrono::milliseconds t,