summaryrefslogtreecommitdiff
path: root/src/buildtool/execution_api/remote/bazel
diff options
context:
space:
mode:
Diffstat (limited to 'src/buildtool/execution_api/remote/bazel')
-rw-r--r--src/buildtool/execution_api/remote/bazel/bazel_action.cpp33
-rw-r--r--src/buildtool/execution_api/remote/bazel/bazel_api.cpp4
2 files changed, 30 insertions, 7 deletions
diff --git a/src/buildtool/execution_api/remote/bazel/bazel_action.cpp b/src/buildtool/execution_api/remote/bazel/bazel_action.cpp
index 15ca949f..f805c6fc 100644
--- a/src/buildtool/execution_api/remote/bazel/bazel_action.cpp
+++ b/src/buildtool/execution_api/remote/bazel/bazel_action.cpp
@@ -69,6 +69,22 @@ auto BazelAction::Execute(Logger const* logger) noexcept
action->hash());
}
+ auto create_response = [](Logger const* logger,
+ std::string const& action_hash,
+ auto&&... args) -> IExecutionResponse::Ptr {
+ try {
+ return IExecutionResponse::Ptr{new BazelResponse{
+ action_hash, std::forward<decltype(args)>(args)...}};
+ } catch (...) {
+ if (logger != nullptr) {
+ logger->Emit(LogLevel::Error,
+ "failed to create a response for {}",
+ action_hash);
+ }
+ }
+ return nullptr;
+ };
+
if (do_cache) {
if (auto result =
network_->GetCachedActionResult(*action, output_files_)) {
@@ -77,8 +93,11 @@ auto BazelAction::Execute(Logger const* logger) noexcept
*result, output_files_, output_dirs_)
) {
- return IExecutionResponse::Ptr{new BazelResponse{
- action->hash(), network_, {*result, true}}};
+ return create_response(
+ logger,
+ action->hash(),
+ network_,
+ BazelExecutionClient::ExecutionOutput{*result, true});
}
}
}
@@ -101,11 +120,13 @@ auto BazelAction::Execute(Logger const* logger) noexcept
}
output->cached_result = true;
- return IExecutionResponse::Ptr{new BazelResponse{
- action_cached->hash(), network_, std::move(*output)}};
+ return create_response(logger,
+ action_cached->hash(),
+ network_,
+ *std::move(output));
}
- return IExecutionResponse::Ptr{new BazelResponse{
- action->hash(), network_, std::move(*output)}};
+ return create_response(
+ logger, action->hash(), network_, *std::move(output));
}
}
diff --git a/src/buildtool/execution_api/remote/bazel/bazel_api.cpp b/src/buildtool/execution_api/remote/bazel/bazel_api.cpp
index 8dbd026e..1b2933af 100644
--- a/src/buildtool/execution_api/remote/bazel/bazel_api.cpp
+++ b/src/buildtool/execution_api/remote/bazel/bazel_api.cpp
@@ -19,6 +19,7 @@
#include <cstdint>
#include <iterator>
#include <mutex>
+#include <new>
#include <sstream>
#include <unordered_map>
#include <unordered_set>
@@ -218,7 +219,8 @@ auto BazelApi::CreateAction(
std::map<std::string, std::string> const& env_vars,
std::map<std::string, std::string> const& properties) const noexcept
-> IExecutionAction::Ptr {
- return std::unique_ptr<BazelAction>{new BazelAction{network_,
+ return std::unique_ptr<BazelAction>{new (std::nothrow)
+ BazelAction{network_,
root_digest,
command,
cwd,