summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/buildtool/execution_api/common/execution_api.hpp3
-rw-r--r--src/buildtool/execution_api/git/git_api.hpp3
-rw-r--r--src/buildtool/execution_api/local/local_api.hpp3
-rw-r--r--src/buildtool/execution_api/remote/bazel/bazel_api.cpp11
-rw-r--r--src/buildtool/execution_api/remote/bazel/bazel_api.hpp3
-rw-r--r--src/buildtool/execution_engine/executor/executor.hpp14
-rw-r--r--test/buildtool/execution_engine/executor/executor.test.cpp9
7 files changed, 27 insertions, 19 deletions
diff --git a/src/buildtool/execution_api/common/execution_api.hpp b/src/buildtool/execution_api/common/execution_api.hpp
index d6ec49fb..43e16783 100644
--- a/src/buildtool/execution_api/common/execution_api.hpp
+++ b/src/buildtool/execution_api/common/execution_api.hpp
@@ -70,7 +70,8 @@ class IExecutionApi {
[[nodiscard]] virtual auto RetrieveToPaths(
std::vector<Artifact::ObjectInfo> const& artifacts_info,
std::vector<std::filesystem::path> const& output_paths,
- IExecutionApi* alternative = nullptr) noexcept -> bool = 0;
+ std::optional<gsl::not_null<IExecutionApi*>> const& alternative =
+ std::nullopt) noexcept -> bool = 0;
/// \brief Retrieve artifacts from CAS and write to file descriptors.
/// Tree artifacts are not resolved and instead the tree object will be
diff --git a/src/buildtool/execution_api/git/git_api.hpp b/src/buildtool/execution_api/git/git_api.hpp
index dcab8335..5d222c32 100644
--- a/src/buildtool/execution_api/git/git_api.hpp
+++ b/src/buildtool/execution_api/git/git_api.hpp
@@ -45,7 +45,8 @@ class GitApi final : public IExecutionApi {
[[nodiscard]] auto RetrieveToPaths(
std::vector<Artifact::ObjectInfo> const& artifacts_info,
std::vector<std::filesystem::path> const& output_paths,
- IExecutionApi* /*alternative*/ = nullptr) noexcept -> bool override {
+ std::optional<gsl::not_null<IExecutionApi*>> const& /*alternative*/ =
+ std::nullopt) noexcept -> bool override {
if (artifacts_info.size() != output_paths.size()) {
Logger::Log(LogLevel::Error,
"different number of digests and output paths.");
diff --git a/src/buildtool/execution_api/local/local_api.hpp b/src/buildtool/execution_api/local/local_api.hpp
index a5596350..dfe8be21 100644
--- a/src/buildtool/execution_api/local/local_api.hpp
+++ b/src/buildtool/execution_api/local/local_api.hpp
@@ -64,7 +64,8 @@ class LocalApi final : public IExecutionApi {
[[nodiscard]] auto RetrieveToPaths(
std::vector<Artifact::ObjectInfo> const& artifacts_info,
std::vector<std::filesystem::path> const& output_paths,
- IExecutionApi* /*alternative*/ = nullptr) noexcept -> bool final {
+ std::optional<gsl::not_null<IExecutionApi*>> const& /*alternative*/ =
+ std::nullopt) noexcept -> bool final {
if (artifacts_info.size() != output_paths.size()) {
Logger::Log(LogLevel::Error,
"different number of digests and output paths.");
diff --git a/src/buildtool/execution_api/remote/bazel/bazel_api.cpp b/src/buildtool/execution_api/remote/bazel/bazel_api.cpp
index 7539771e..48cf3133 100644
--- a/src/buildtool/execution_api/remote/bazel/bazel_api.cpp
+++ b/src/buildtool/execution_api/remote/bazel/bazel_api.cpp
@@ -212,7 +212,8 @@ auto BazelApi::CreateAction(
[[nodiscard]] auto BazelApi::RetrieveToPaths(
std::vector<Artifact::ObjectInfo> const& artifacts_info,
std::vector<std::filesystem::path> const& output_paths,
- IExecutionApi* alternative) noexcept -> bool {
+ std::optional<gsl::not_null<IExecutionApi*>> const& alternative) noexcept
+ -> bool {
if (artifacts_info.size() != output_paths.size()) {
Logger::Log(LogLevel::Error,
"different number of digests and output paths.");
@@ -224,9 +225,9 @@ auto BazelApi::CreateAction(
std::vector<std::size_t> artifact_pos{};
for (std::size_t i{}; i < artifacts_info.size(); ++i) {
auto const& info = artifacts_info[i];
- if ((alternative != nullptr) and
- alternative->IsAvailable(info.digest)) {
- if (not alternative->RetrieveToPaths({info}, {output_paths[i]})) {
+ if (alternative and alternative.value()->IsAvailable(info.digest)) {
+ if (not alternative.value()->RetrieveToPaths({info},
+ {output_paths[i]})) {
return false;
}
}
@@ -234,7 +235,7 @@ auto BazelApi::CreateAction(
if (IsTreeObject(info.type)) {
// read object infos from sub tree and call retrieve recursively
auto const infos = network_->RecursivelyReadTreeLeafs(
- info.digest, output_paths[i], alternative != nullptr);
+ info.digest, output_paths[i], alternative.has_value());
if (not infos or
not RetrieveToPaths(infos->second, infos->first)) {
return false;
diff --git a/src/buildtool/execution_api/remote/bazel/bazel_api.hpp b/src/buildtool/execution_api/remote/bazel/bazel_api.hpp
index d0b38d32..aae90907 100644
--- a/src/buildtool/execution_api/remote/bazel/bazel_api.hpp
+++ b/src/buildtool/execution_api/remote/bazel/bazel_api.hpp
@@ -61,7 +61,8 @@ class BazelApi final : public IExecutionApi {
[[nodiscard]] auto RetrieveToPaths(
std::vector<Artifact::ObjectInfo> const& artifacts_info,
std::vector<std::filesystem::path> const& output_paths,
- IExecutionApi* alternative = nullptr) noexcept -> bool final;
+ std::optional<gsl::not_null<IExecutionApi*>> const& alternative =
+ std::nullopt) noexcept -> bool final;
[[nodiscard]] auto RetrieveToFds(
std::vector<Artifact::ObjectInfo> const& artifacts_info,
diff --git a/src/buildtool/execution_engine/executor/executor.hpp b/src/buildtool/execution_engine/executor/executor.hpp
index 4e33060c..454772ff 100644
--- a/src/buildtool/execution_engine/executor/executor.hpp
+++ b/src/buildtool/execution_engine/executor/executor.hpp
@@ -657,9 +657,9 @@ class Executor {
public:
explicit Executor(
- gsl::not_null<RepositoryConfig*> repo_config,
- IExecutionApi* local_api,
- IExecutionApi* remote_api,
+ gsl::not_null<RepositoryConfig*> const& repo_config,
+ gsl::not_null<IExecutionApi*> const& local_api,
+ gsl::not_null<IExecutionApi*> const& remote_api,
std::map<std::string, std::string> properties,
std::vector<std::pair<std::map<std::string, std::string>,
ServerAddress>> dispatch_list,
@@ -727,10 +727,10 @@ class Rebuilder {
/// \param properties Platform properties for execution.
/// \param timeout Timeout for action execution.
Rebuilder(
- gsl::not_null<RepositoryConfig*> repo_config,
- IExecutionApi* local_api,
- IExecutionApi* remote_api,
- IExecutionApi* api_cached,
+ gsl::not_null<RepositoryConfig*> const& repo_config,
+ gsl::not_null<IExecutionApi*> const& local_api,
+ gsl::not_null<IExecutionApi*> const& remote_api,
+ gsl::not_null<IExecutionApi*> const& api_cached,
std::map<std::string, std::string> properties,
std::vector<std::pair<std::map<std::string, std::string>,
ServerAddress>> dispatch_list,
diff --git a/test/buildtool/execution_engine/executor/executor.test.cpp b/test/buildtool/execution_engine/executor/executor.test.cpp
index c60326c1..0b4561e0 100644
--- a/test/buildtool/execution_engine/executor/executor.test.cpp
+++ b/test/buildtool/execution_engine/executor/executor.test.cpp
@@ -138,9 +138,12 @@ class TestApi : public IExecutionApi {
-> IExecutionAction::Ptr final {
return IExecutionAction::Ptr{new TestAction(config_)};
}
- auto RetrieveToPaths(std::vector<Artifact::ObjectInfo> const& /*unused*/,
- std::vector<std::filesystem::path> const& /*unused*/,
- IExecutionApi* /* unused */) noexcept -> bool final {
+ auto RetrieveToPaths(
+ std::vector<Artifact::ObjectInfo> const& /*unused*/,
+ std::vector<std::filesystem::path> const& /*unused*/,
+ std::optional<
+ gsl::not_null<IExecutionApi*>> const& /* unused */) noexcept
+ -> bool final {
return false; // not needed by Executor
}
auto RetrieveToFds(std::vector<Artifact::ObjectInfo> const& /*unused*/,