summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaksim Denisov <denisov.maksim@huawei.com>2024-06-25 16:14:51 +0200
committerMaksim Denisov <denisov.maksim@huawei.com>2024-06-27 11:24:20 +0200
commit4625d391cad4d04f9adca4484da687b2adb1fed6 (patch)
tree4f4a3e19e78324e6abe3a6ac1209cad3d8a50cb0 /src
parent70a854c2ce90194a943b6e007a1515dfc87314eb (diff)
downloadjustbuild-4625d391cad4d04f9adca4484da687b2adb1fed6.tar.gz
Use a raw pointer for passing optional IExecutionApi
...instead of std::optional<gsl::not_null<IExecutionApi const*>>
Diffstat (limited to 'src')
-rw-r--r--src/buildtool/execution_api/common/execution_api.hpp4
-rw-r--r--src/buildtool/execution_api/git/git_api.hpp4
-rw-r--r--src/buildtool/execution_api/local/local_api.hpp4
-rw-r--r--src/buildtool/execution_api/remote/bazel/bazel_api.cpp9
-rw-r--r--src/buildtool/execution_api/remote/bazel/bazel_api.hpp4
-rw-r--r--src/other_tools/just_mr/fetch.cpp51
-rw-r--r--src/other_tools/just_mr/setup.cpp122
-rw-r--r--src/other_tools/ops_maps/archive_fetch_map.cpp8
-rw-r--r--src/other_tools/ops_maps/archive_fetch_map.hpp2
-rw-r--r--src/other_tools/ops_maps/content_cas_map.cpp10
-rw-r--r--src/other_tools/ops_maps/content_cas_map.hpp2
-rw-r--r--src/other_tools/ops_maps/git_tree_fetch_map.cpp21
-rw-r--r--src/other_tools/ops_maps/git_tree_fetch_map.hpp2
-rw-r--r--src/other_tools/root_maps/commit_git_map.cpp14
-rw-r--r--src/other_tools/root_maps/commit_git_map.hpp2
-rw-r--r--src/other_tools/root_maps/content_git_map.cpp20
-rw-r--r--src/other_tools/root_maps/content_git_map.hpp2
-rw-r--r--src/other_tools/root_maps/distdir_git_map.cpp18
-rw-r--r--src/other_tools/root_maps/distdir_git_map.hpp2
-rw-r--r--src/other_tools/root_maps/fpath_git_map.cpp10
-rw-r--r--src/other_tools/root_maps/fpath_git_map.hpp2
-rw-r--r--src/other_tools/root_maps/root_utils.cpp6
-rw-r--r--src/other_tools/root_maps/root_utils.hpp2
-rw-r--r--src/other_tools/root_maps/tree_id_git_map.cpp31
-rw-r--r--src/other_tools/root_maps/tree_id_git_map.hpp2
25 files changed, 175 insertions, 179 deletions
diff --git a/src/buildtool/execution_api/common/execution_api.hpp b/src/buildtool/execution_api/common/execution_api.hpp
index b86ddd1f..2108c68d 100644
--- a/src/buildtool/execution_api/common/execution_api.hpp
+++ b/src/buildtool/execution_api/common/execution_api.hpp
@@ -35,7 +35,6 @@
class IExecutionApi {
public:
using Ptr = std::shared_ptr<IExecutionApi const>;
- using OptionalPtr = std::optional<gsl::not_null<IExecutionApi const*>>;
IExecutionApi() = default;
IExecutionApi(IExecutionApi const&) = delete;
@@ -71,8 +70,7 @@ class IExecutionApi {
[[nodiscard]] virtual auto RetrieveToPaths(
std::vector<Artifact::ObjectInfo> const& artifacts_info,
std::vector<std::filesystem::path> const& output_paths,
- IExecutionApi::OptionalPtr const& alternative =
- std::nullopt) const noexcept -> bool = 0;
+ IExecutionApi const* alternative = nullptr) const 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 d35000fd..a18bd71b 100644
--- a/src/buildtool/execution_api/git/git_api.hpp
+++ b/src/buildtool/execution_api/git/git_api.hpp
@@ -54,8 +54,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::OptionalPtr const& /*alternative*/
- = std::nullopt) const noexcept -> bool override {
+ IExecutionApi const* /*alternative*/ = nullptr) const 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 cbb904ef..8e1964c0 100644
--- a/src/buildtool/execution_api/local/local_api.hpp
+++ b/src/buildtool/execution_api/local/local_api.hpp
@@ -78,8 +78,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::OptionalPtr const& /*alternative*/ =
- std::nullopt) const noexcept -> bool final {
+ IExecutionApi const* /*alternative*/ = nullptr) const 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 f636c265..aea38ab4 100644
--- a/src/buildtool/execution_api/remote/bazel/bazel_api.cpp
+++ b/src/buildtool/execution_api/remote/bazel/bazel_api.cpp
@@ -221,7 +221,7 @@ auto BazelApi::CreateAction(
[[nodiscard]] auto BazelApi::RetrieveToPaths(
std::vector<Artifact::ObjectInfo> const& artifacts_info,
std::vector<std::filesystem::path> const& output_paths,
- IExecutionApi::OptionalPtr const& alternative) const noexcept -> bool {
+ IExecutionApi const* alternative) const noexcept -> bool {
if (artifacts_info.size() != output_paths.size()) {
Logger::Log(LogLevel::Warning,
"different number of digests and output paths.");
@@ -233,16 +233,15 @@ 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 and alternative.value()->IsAvailable(info.digest)) {
- if (not alternative.value()->RetrieveToPaths({info},
- {output_paths[i]})) {
+ if (alternative != nullptr and alternative->IsAvailable(info.digest)) {
+ if (not alternative->RetrieveToPaths({info}, {output_paths[i]})) {
return false;
}
}
else {
if (IsTreeObject(info.type)) {
// read object infos from sub tree and call retrieve recursively
- auto request_remote_tree = alternative.has_value()
+ auto request_remote_tree = alternative != nullptr
? std::make_optional(info.digest)
: std::nullopt;
auto reader = TreeReader<BazelNetworkReader>{
diff --git a/src/buildtool/execution_api/remote/bazel/bazel_api.hpp b/src/buildtool/execution_api/remote/bazel/bazel_api.hpp
index e5669933..289cb19c 100644
--- a/src/buildtool/execution_api/remote/bazel/bazel_api.hpp
+++ b/src/buildtool/execution_api/remote/bazel/bazel_api.hpp
@@ -62,8 +62,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::OptionalPtr const& alternative =
- std::nullopt) const noexcept -> bool final;
+ IExecutionApi const* alternative = nullptr) const noexcept
+ -> bool final;
[[nodiscard]] auto RetrieveToFds(
std::vector<Artifact::ObjectInfo> const& artifacts_info,
diff --git a/src/other_tools/just_mr/fetch.cpp b/src/other_tools/just_mr/fetch.cpp
index 47c107f3..a31368b9 100644
--- a/src/other_tools/just_mr/fetch.cpp
+++ b/src/other_tools/just_mr/fetch.cpp
@@ -439,41 +439,40 @@ auto MultiRepoFetch(std::shared_ptr<Configuration> const& config,
auto crit_git_op_ptr = std::make_shared<CriticalGitOpGuard>();
auto critical_git_op_map = CreateCriticalGitOpMap(crit_git_op_ptr);
- auto content_cas_map = CreateContentCASMap(
- common_args.just_mr_paths,
- common_args.alternative_mirrors,
- common_args.ca_info,
- &critical_git_op_map,
- serve,
+ auto content_cas_map =
+ CreateContentCASMap(common_args.just_mr_paths,
+ common_args.alternative_mirrors,
+ common_args.ca_info,
+ &critical_git_op_map,
+ serve,
+ &(*apis.local),
+ has_remote_api ? &*apis.remote : nullptr,
+ common_args.jobs);
+
+ auto archive_fetch_map = CreateArchiveFetchMap(
+ &content_cas_map,
+ *fetch_dir,
&(*apis.local),
- has_remote_api ? std::make_optional(&(*apis.remote)) : std::nullopt,
+ (fetch_args.backup_to_remote and has_remote_api) ? &*apis.remote
+ : nullptr,
common_args.jobs);
- auto archive_fetch_map =
- CreateArchiveFetchMap(&content_cas_map,
- *fetch_dir,
- &(*apis.local),
- (fetch_args.backup_to_remote and has_remote_api)
- ? std::make_optional(&(*apis.remote))
- : std::nullopt,
- common_args.jobs);
-
auto import_to_git_map =
CreateImportToGitMap(&critical_git_op_map,
common_args.git_path->string(),
*common_args.local_launcher,
common_args.jobs);
- auto git_tree_fetch_map = CreateGitTreeFetchMap(
- &critical_git_op_map,
- &import_to_git_map,
- common_args.git_path->string(),
- *common_args.local_launcher,
- serve,
- &(*apis.local),
- has_remote_api ? std::make_optional(&(*apis.remote)) : std::nullopt,
- fetch_args.backup_to_remote,
- common_args.jobs);
+ auto git_tree_fetch_map =
+ CreateGitTreeFetchMap(&critical_git_op_map,
+ &import_to_git_map,
+ common_args.git_path->string(),
+ *common_args.local_launcher,
+ serve,
+ &(*apis.local),
+ has_remote_api ? &*apis.remote : nullptr,
+ fetch_args.backup_to_remote,
+ common_args.jobs);
// set up progress observer
JustMRProgress::Instance().SetTotal(static_cast<int>(nr_a + nr_gt));
diff --git a/src/other_tools/just_mr/setup.cpp b/src/other_tools/just_mr/setup.cpp
index 8bcefead..e92d307c 100644
--- a/src/other_tools/just_mr/setup.cpp
+++ b/src/other_tools/just_mr/setup.cpp
@@ -159,15 +159,15 @@ auto MultiRepoSetup(std::shared_ptr<Configuration> const& config,
auto crit_git_op_ptr = std::make_shared<CriticalGitOpGuard>();
auto critical_git_op_map = CreateCriticalGitOpMap(crit_git_op_ptr);
- auto content_cas_map = CreateContentCASMap(
- common_args.just_mr_paths,
- common_args.alternative_mirrors,
- common_args.ca_info,
- &critical_git_op_map,
- serve,
- &(*apis.local),
- has_remote_api ? std::make_optional(&(*apis.remote)) : std::nullopt,
- common_args.jobs);
+ auto content_cas_map =
+ CreateContentCASMap(common_args.just_mr_paths,
+ common_args.alternative_mirrors,
+ common_args.ca_info,
+ &critical_git_op_map,
+ serve,
+ &(*apis.local),
+ has_remote_api ? &*apis.remote : nullptr,
+ common_args.jobs);
auto import_to_git_map =
CreateImportToGitMap(&critical_git_op_map,
@@ -175,44 +175,44 @@ auto MultiRepoSetup(std::shared_ptr<Configuration> const& config,
*common_args.local_launcher,
common_args.jobs);
- auto git_tree_fetch_map = CreateGitTreeFetchMap(
- &critical_git_op_map,
- &import_to_git_map,
- common_args.git_path->string(),
- *common_args.local_launcher,
- serve,
- &(*apis.local),
- has_remote_api ? std::make_optional(&(*apis.remote)) : std::nullopt,
- false, /* backup_to_remote */
- common_args.jobs);
+ auto git_tree_fetch_map =
+ CreateGitTreeFetchMap(&critical_git_op_map,
+ &import_to_git_map,
+ common_args.git_path->string(),
+ *common_args.local_launcher,
+ serve,
+ &(*apis.local),
+ has_remote_api ? &*apis.remote : nullptr,
+ false, /* backup_to_remote */
+ common_args.jobs);
auto resolve_symlinks_map = CreateResolveSymlinksMap();
- auto commit_git_map = CreateCommitGitMap(
- &critical_git_op_map,
- &import_to_git_map,
- common_args.just_mr_paths,
- common_args.alternative_mirrors,
- common_args.git_path->string(),
- *common_args.local_launcher,
- serve,
- &(*apis.local),
- has_remote_api ? std::make_optional(&(*apis.remote)) : std::nullopt,
- common_args.fetch_absent,
- common_args.jobs);
+ auto commit_git_map =
+ CreateCommitGitMap(&critical_git_op_map,
+ &import_to_git_map,
+ common_args.just_mr_paths,
+ common_args.alternative_mirrors,
+ common_args.git_path->string(),
+ *common_args.local_launcher,
+ serve,
+ &(*apis.local),
+ has_remote_api ? &*apis.remote : nullptr,
+ common_args.fetch_absent,
+ common_args.jobs);
- auto content_git_map = CreateContentGitMap(
- &content_cas_map,
- &import_to_git_map,
- common_args.just_mr_paths,
- common_args.alternative_mirrors,
- common_args.ca_info,
- &resolve_symlinks_map,
- &critical_git_op_map,
- serve,
- has_remote_api ? std::make_optional(&(*apis.remote)) : std::nullopt,
- common_args.fetch_absent,
- common_args.jobs);
+ auto content_git_map =
+ CreateContentGitMap(&content_cas_map,
+ &import_to_git_map,
+ common_args.just_mr_paths,
+ common_args.alternative_mirrors,
+ common_args.ca_info,
+ &resolve_symlinks_map,
+ &critical_git_op_map,
+ serve,
+ has_remote_api ? &*apis.remote : nullptr,
+ common_args.fetch_absent,
+ common_args.jobs);
auto foreign_file_git_map =
CreateForeignFileGitMap(&content_cas_map,
@@ -227,30 +227,30 @@ auto MultiRepoSetup(std::shared_ptr<Configuration> const& config,
&import_to_git_map,
&resolve_symlinks_map,
serve,
- has_remote_api ? std::make_optional(&(*apis.remote)) : std::nullopt,
+ has_remote_api ? &*apis.remote : nullptr,
common_args.jobs,
multi_repo_tool_name,
common_args.just_path ? common_args.just_path->string()
: kDefaultJustPath);
- auto distdir_git_map = CreateDistdirGitMap(
- &content_cas_map,
- &import_to_git_map,
- &critical_git_op_map,
- serve,
- &(*apis.local),
- has_remote_api ? std::make_optional(&(*apis.remote)) : std::nullopt,
- common_args.jobs);
+ auto distdir_git_map =
+ CreateDistdirGitMap(&content_cas_map,
+ &import_to_git_map,
+ &critical_git_op_map,
+ serve,
+ &(*apis.local),
+ has_remote_api ? &*apis.remote : nullptr,
+ common_args.jobs);
- auto tree_id_git_map = CreateTreeIdGitMap(
- &git_tree_fetch_map,
- &critical_git_op_map,
- &import_to_git_map,
- common_args.fetch_absent,
- serve,
- &(*apis.local),
- has_remote_api ? std::make_optional(&(*apis.remote)) : std::nullopt,
- common_args.jobs);
+ auto tree_id_git_map =
+ CreateTreeIdGitMap(&git_tree_fetch_map,
+ &critical_git_op_map,
+ &import_to_git_map,
+ common_args.fetch_absent,
+ serve,
+ &(*apis.local),
+ has_remote_api ? &*apis.remote : nullptr,
+ common_args.jobs);
auto repos_to_setup_map = CreateReposToSetupMap(config,
main,
diff --git a/src/other_tools/ops_maps/archive_fetch_map.cpp b/src/other_tools/ops_maps/archive_fetch_map.cpp
index db2fc319..e035b128 100644
--- a/src/other_tools/ops_maps/archive_fetch_map.cpp
+++ b/src/other_tools/ops_maps/archive_fetch_map.cpp
@@ -29,17 +29,17 @@ namespace {
void ProcessContent(std::filesystem::path const& content_path,
std::filesystem::path const& target_name,
gsl::not_null<IExecutionApi const*> const& local_api,
- IExecutionApi::OptionalPtr const& remote_api,
+ IExecutionApi const* remote_api,
std::string const& content,
ArchiveFetchMap::SetterPtr const& setter,
ArchiveFetchMap::LoggerPtr const& logger) {
// try to back up to remote CAS
- if (remote_api) {
+ if (remote_api != nullptr) {
if (not local_api->RetrieveToCas(
{Artifact::ObjectInfo{
.digest = ArtifactDigest{content, 0, /*is_tree=*/false},
.type = ObjectType::File}},
- **remote_api)) {
+ *remote_api)) {
// give a warning
(*logger)(fmt::format("Failed to back up content {} from local CAS "
"to remote",
@@ -70,7 +70,7 @@ void ProcessContent(std::filesystem::path const& content_path,
auto CreateArchiveFetchMap(gsl::not_null<ContentCASMap*> const& content_cas_map,
std::filesystem::path const& fetch_dir,
gsl::not_null<IExecutionApi const*> const& local_api,
- IExecutionApi::OptionalPtr const& remote_api,
+ IExecutionApi const* remote_api,
std::size_t jobs) -> ArchiveFetchMap {
auto fetch_archive = [content_cas_map, fetch_dir, local_api, remote_api](
auto ts,
diff --git a/src/other_tools/ops_maps/archive_fetch_map.hpp b/src/other_tools/ops_maps/archive_fetch_map.hpp
index 9f0b220d..6ec3e44c 100644
--- a/src/other_tools/ops_maps/archive_fetch_map.hpp
+++ b/src/other_tools/ops_maps/archive_fetch_map.hpp
@@ -30,7 +30,7 @@ using ArchiveFetchMap = AsyncMapConsumer<ArchiveContent, bool>;
gsl::not_null<ContentCASMap*> const& content_cas_map,
std::filesystem::path const& fetch_dir, // should exist!
gsl::not_null<IExecutionApi const*> const& local_api,
- IExecutionApi::OptionalPtr const& remote_api,
+ IExecutionApi const* remote_api,
std::size_t jobs) -> ArchiveFetchMap;
#endif // INCLUDED_SRC_OTHER_TOOLS_OPS_MAPS_ARCHIVE_FETCH_MAP_HPP
diff --git a/src/other_tools/ops_maps/content_cas_map.cpp b/src/other_tools/ops_maps/content_cas_map.cpp
index 3cba65ef..4e526bc7 100644
--- a/src/other_tools/ops_maps/content_cas_map.cpp
+++ b/src/other_tools/ops_maps/content_cas_map.cpp
@@ -110,7 +110,7 @@ auto CreateContentCASMap(
gsl::not_null<CriticalGitOpMap*> const& critical_git_op_map,
std::optional<ServeApi> const& serve,
gsl::not_null<IExecutionApi const*> const& local_api,
- IExecutionApi::OptionalPtr const& remote_api,
+ IExecutionApi const* remote_api,
std::size_t jobs) -> ContentCASMap {
auto ensure_in_cas = [just_mr_paths,
additional_mirrors,
@@ -215,10 +215,10 @@ auto CreateContentCASMap(
return;
}
// check if content is known to remote serve service
- if (serve and remote_api and
+ if (serve and remote_api != nullptr and
serve->ContentInRemoteCAS(key.content)) {
// try to get content from remote CAS
- if (remote_api.value()->RetrieveToCas(
+ if (remote_api->RetrieveToCas(
{Artifact::ObjectInfo{.digest = digest,
.type = ObjectType::File}},
*local_api)) {
@@ -229,8 +229,8 @@ auto CreateContentCASMap(
}
}
// check remote execution endpoint, if given
- if (remote_api and
- remote_api.value()->RetrieveToCas(
+ if (remote_api != nullptr and
+ remote_api->RetrieveToCas(
{Artifact::ObjectInfo{.digest = digest,
.type = ObjectType::File}},
*local_api)) {
diff --git a/src/other_tools/ops_maps/content_cas_map.hpp b/src/other_tools/ops_maps/content_cas_map.hpp
index df8b0103..f0d0369b 100644
--- a/src/other_tools/ops_maps/content_cas_map.hpp
+++ b/src/other_tools/ops_maps/content_cas_map.hpp
@@ -86,7 +86,7 @@ using ContentCASMap = AsyncMapConsumer<ArchiveContent, std::nullptr_t>;
gsl::not_null<CriticalGitOpMap*> const& critical_git_op_map,
std::optional<ServeApi> const& serve,
gsl::not_null<IExecutionApi const*> const& local_api,
- IExecutionApi::OptionalPtr const& remote_api,
+ IExecutionApi const* remote_api,
std::size_t jobs) -> ContentCASMap;
namespace std {
diff --git a/src/other_tools/ops_maps/git_tree_fetch_map.cpp b/src/other_tools/ops_maps/git_tree_fetch_map.cpp
index b08da28a..50433b20 100644
--- a/src/other_tools/ops_maps/git_tree_fetch_map.cpp
+++ b/src/other_tools/ops_maps/git_tree_fetch_map.cpp
@@ -35,7 +35,7 @@
namespace {
void BackupToRemote(std::string const& tree_id,
- gsl::not_null<IExecutionApi const*> const& remote_api,
+ IExecutionApi const& remote_api,
GitTreeFetchMap::LoggerPtr const& logger) {
// try to back up to remote CAS
auto repo = RepositoryConfig{};
@@ -45,7 +45,7 @@ void BackupToRemote(std::string const& tree_id,
{Artifact::ObjectInfo{
.digest = ArtifactDigest{tree_id, 0, /*is_tree=*/true},
.type = ObjectType::Tree}},
- *remote_api)) {
+ remote_api)) {
// give a warning
(*logger)(fmt::format(
"Failed to back up tree {} from local CAS to remote",
@@ -67,7 +67,7 @@ void MoveCASTreeToGit(std::string const& tree_id,
ArtifactDigest const& digest,
gsl::not_null<ImportToGitMap*> const& import_to_git_map,
gsl::not_null<IExecutionApi const*> const& local_api,
- IExecutionApi::OptionalPtr const& remote_api,
+ IExecutionApi const* remote_api,
bool backup_to_remote,
gsl::not_null<TaskSystem*> const& ts,
GitTreeFetchMap::SetterPtr const& setter,
@@ -106,7 +106,7 @@ void MoveCASTreeToGit(std::string const& tree_id,
return;
}
// backup to remote if needed and in compatibility mode
- if (backup_to_remote and remote_api) {
+ if (backup_to_remote and remote_api != nullptr) {
BackupToRemote(tree_id, *remote_api, logger);
}
(*setter)(false /*no cache hit*/);
@@ -130,7 +130,7 @@ auto CreateGitTreeFetchMap(
std::vector<std::string> const& launcher,
std::optional<ServeApi> const& serve,
gsl::not_null<IExecutionApi const*> const& local_api,
- IExecutionApi::OptionalPtr const& remote_api,
+ IExecutionApi const* remote_api,
bool backup_to_remote,
std::size_t jobs) -> GitTreeFetchMap {
auto tree_to_cache = [critical_git_op_map,
@@ -204,7 +204,7 @@ auto CreateGitTreeFetchMap(
}
if (*tree_found) {
// backup to remote if needed and in native mode
- if (backup_to_remote and remote_api) {
+ if (backup_to_remote and remote_api != nullptr) {
BackupToRemote(key.hash, *remote_api, logger);
}
// success
@@ -231,15 +231,15 @@ auto CreateGitTreeFetchMap(
JustMRProgress::Instance().TaskTracker().Start(key.origin);
// check if tree is known to remote serve service and can be
// made available in remote CAS
- if (serve and remote_api) {
+ if (serve and remote_api != nullptr) {
// as we anyway interrogate the remote execution endpoint,
// we're only interested here in the serve endpoint making
// an attempt to upload the tree, if known, to remote CAS
std::ignore = serve->TreeInRemoteCAS(key.hash);
}
// check if tree is in remote CAS, if a remote is given
- if (remote_api and
- remote_api.value()->RetrieveToCas(
+ if (remote_api != nullptr and
+ remote_api->RetrieveToCas(
{Artifact::ObjectInfo{.digest = digest,
.type = ObjectType::Tree}},
*local_api)) {
@@ -463,7 +463,8 @@ auto CreateGitTreeFetchMap(
JustMRProgress::Instance().TaskTracker().Stop(
key.origin);
// backup to remote if needed and in native mode
- if (backup_to_remote and remote_api) {
+ if (backup_to_remote and
+ remote_api != nullptr) {
BackupToRemote(
key.hash, *remote_api, logger);
}
diff --git a/src/other_tools/ops_maps/git_tree_fetch_map.hpp b/src/other_tools/ops_maps/git_tree_fetch_map.hpp
index be5a4252..342629ab 100644
--- a/src/other_tools/ops_maps/git_tree_fetch_map.hpp
+++ b/src/other_tools/ops_maps/git_tree_fetch_map.hpp
@@ -62,7 +62,7 @@ using GitTreeFetchMap = AsyncMapConsumer<GitTreeInfo, bool>;
std::vector<std::string> const& launcher,
std::optional<ServeApi> const& serve,
gsl::not_null<IExecutionApi const*> const& local_api,
- IExecutionApi::OptionalPtr const& remote_api,
+ IExecutionApi const* remote_api,
bool backup_to_remote,
std::size_t jobs) -> GitTreeFetchMap;
diff --git a/src/other_tools/root_maps/commit_git_map.cpp b/src/other_tools/root_maps/commit_git_map.cpp
index a4f2b8eb..65585afc 100644
--- a/src/other_tools/root_maps/commit_git_map.cpp
+++ b/src/other_tools/root_maps/commit_git_map.cpp
@@ -62,7 +62,7 @@ void EnsureRootAsAbsent(std::string const& tree_id,
std::filesystem::path const& repo_root,
GitRepoInfo const& repo_info,
std::optional<ServeApi> const& serve,
- IExecutionApi::OptionalPtr const& remote_api,
+ IExecutionApi const* remote_api,
CommitGitMap::SetterPtr const& ws_setter,
CommitGitMap::LoggerPtr const& logger) {
// this is an absent root
@@ -103,7 +103,7 @@ void EnsureRootAsAbsent(std::string const& tree_id,
/*fatal=*/true);
return;
}
- if (not remote_api) {
+ if (remote_api == nullptr) {
(*logger)(
fmt::format("Missing or incompatible remote-execution "
"endpoint needed to sync workspace root {} "
@@ -117,7 +117,7 @@ void EnsureRootAsAbsent(std::string const& tree_id,
if (not EnsureAbsentRootOnServe(*serve,
tree_id,
repo_root,
- &(*remote_api.value()),
+ remote_api,
logger,
true /*no_sync_is_fatal*/)) {
return;
@@ -411,7 +411,7 @@ void EnsureCommit(GitRepoInfo const& repo_info,
std::vector<std::string> const& launcher,
std::optional<ServeApi> const& serve,
gsl::not_null<IExecutionApi const*> const& local_api,
- IExecutionApi::OptionalPtr const& remote_api,
+ IExecutionApi const* remote_api,
bool fetch_absent,
gsl::not_null<TaskSystem*> const& ts,
CommitGitMap::SetterPtr const& ws_setter,
@@ -716,8 +716,8 @@ void EnsureCommit(GitRepoInfo const& repo_info,
// try to get root tree from remote CAS
auto root_digest = ArtifactDigest{
root_tree_id, 0, /*is_tree=*/true};
- if (remote_api and
- remote_api.value()->RetrieveToCas(
+ if (remote_api != nullptr and
+ remote_api->RetrieveToCas(
{Artifact::ObjectInfo{
.digest = root_digest,
.type = ObjectType::Tree}},
@@ -923,7 +923,7 @@ auto CreateCommitGitMap(
std::vector<std::string> const& launcher,
std::optional<ServeApi> const& serve,
gsl::not_null<IExecutionApi const*> const& local_api,
- IExecutionApi::OptionalPtr const& remote_api,
+ IExecutionApi const* remote_api,
bool fetch_absent,
std::size_t jobs) -> CommitGitMap {
auto commit_to_git = [critical_git_op_map,
diff --git a/src/other_tools/root_maps/commit_git_map.hpp b/src/other_tools/root_maps/commit_git_map.hpp
index b76c1888..14766018 100644
--- a/src/other_tools/root_maps/commit_git_map.hpp
+++ b/src/other_tools/root_maps/commit_git_map.hpp
@@ -83,7 +83,7 @@ using CommitGitMap =
std::vector<std::string> const& launcher,
std::optional<ServeApi> const& serve,
gsl::not_null<IExecutionApi const*> const& local_api,
- IExecutionApi::OptionalPtr const& remote_api,
+ IExecutionApi const* remote_api,
bool fetch_absent,
std::size_t jobs) -> CommitGitMap;
diff --git a/src/other_tools/root_maps/content_git_map.cpp b/src/other_tools/root_maps/content_git_map.cpp
index 440593d0..a6d0fa15 100644
--- a/src/other_tools/root_maps/content_git_map.cpp
+++ b/src/other_tools/root_maps/content_git_map.cpp
@@ -55,7 +55,7 @@ namespace {
void EnsureRootAsAbsent(std::string const& tree_id,
ArchiveRepoInfo const& key,
std::optional<ServeApi> const& serve,
- IExecutionApi::OptionalPtr const& remote_api,
+ IExecutionApi const* remote_api,
bool is_cache_hit,
ContentGitMap::SetterPtr const& ws_setter,
ContentGitMap::LoggerPtr const& logger) {
@@ -102,7 +102,7 @@ void EnsureRootAsAbsent(std::string const& tree_id,
/*fatal=*/true);
return;
}
- if (not remote_api) {
+ if (remote_api == nullptr) {
(*logger)(
fmt::format(
"Missing or incompatible remote-execution "
@@ -119,7 +119,7 @@ void EnsureRootAsAbsent(std::string const& tree_id,
*serve,
tree_id,
StorageConfig::GitRoot(),
- &(*remote_api.value()),
+ remote_api,
logger,
/*no_sync_is_fatal=*/true)) {
return;
@@ -129,7 +129,7 @@ void EnsureRootAsAbsent(std::string const& tree_id,
else {
// the tree is known locally, so we can upload it to remote CAS
// for the serve endpoint to retrieve it and set up the root
- if (not remote_api) {
+ if (remote_api == nullptr) {
(*logger)(
fmt::format("Missing or incompatible remote-execution "
"endpoint needed to sync workspace root {} "
@@ -144,7 +144,7 @@ void EnsureRootAsAbsent(std::string const& tree_id,
if (not EnsureAbsentRootOnServe(*serve,
tree_id,
StorageConfig::GitRoot(),
- &(*remote_api.value()),
+ remote_api,
logger,
/*no_sync_is_fatal=*/true)) {
return;
@@ -175,7 +175,7 @@ void ResolveContentTree(
bool is_cache_hit,
bool is_absent,
std::optional<ServeApi> const& serve,
- IExecutionApi::OptionalPtr const& remote_api,
+ IExecutionApi const* remote_api,
gsl::not_null<CriticalGitOpMap*> const& critical_git_op_map,
gsl::not_null<ResolveSymlinksMap*> const& resolve_symlinks_map,
gsl::not_null<TaskSystem*> const& ts,
@@ -364,7 +364,7 @@ void WriteIdFileAndSetWSRoot(
std::filesystem::path const& archive_tree_id_file,
bool is_absent,
std::optional<ServeApi> const& serve,
- IExecutionApi::OptionalPtr const& remote_api,
+ IExecutionApi const* remote_api,
gsl::not_null<CriticalGitOpMap*> const& critical_git_op_map,
gsl::not_null<ResolveSymlinksMap*> const& resolve_symlinks_map,
gsl::not_null<TaskSystem*> const& ts,
@@ -425,7 +425,7 @@ void ExtractAndImportToGit(
std::filesystem::path const& archive_tree_id_file,
bool is_absent,
std::optional<ServeApi> const& serve,
- IExecutionApi::OptionalPtr const& remote_api,
+ IExecutionApi const* remote_api,
gsl::not_null<CriticalGitOpMap*> const& critical_git_op_map,
gsl::not_null<ImportToGitMap*> const& import_to_git_map,
gsl::not_null<ResolveSymlinksMap*> const& resolve_symlinks_map,
@@ -509,7 +509,7 @@ auto CreateContentGitMap(
gsl::not_null<ResolveSymlinksMap*> const& resolve_symlinks_map,
gsl::not_null<CriticalGitOpMap*> const& critical_git_op_map,
std::optional<ServeApi> const& serve,
- IExecutionApi::OptionalPtr const& remote_api,
+ IExecutionApi const* remote_api,
bool fetch_absent,
std::size_t jobs) -> ContentGitMap {
auto gitify_content = [content_cas_map,
@@ -848,7 +848,7 @@ auto CreateContentGitMap(
archive_tree_id_file,
/*is_absent=*/false,
/*serve=*/std::nullopt,
- /*remote_api=*/std::nullopt,
+ /*remote_api=*/nullptr,
critical_git_op_map,
import_to_git_map,
resolve_symlinks_map,
diff --git a/src/other_tools/root_maps/content_git_map.hpp b/src/other_tools/root_maps/content_git_map.hpp
index 015895ec..4a20f98b 100644
--- a/src/other_tools/root_maps/content_git_map.hpp
+++ b/src/other_tools/root_maps/content_git_map.hpp
@@ -44,7 +44,7 @@ using ContentGitMap =
gsl::not_null<ResolveSymlinksMap*> const& resolve_symlinks_map,
gsl::not_null<CriticalGitOpMap*> const& critical_git_op_map,
std::optional<ServeApi> const& serve,
- IExecutionApi::OptionalPtr const& remote_api,
+ IExecutionApi const* remote_api,
bool fetch_absent,
std::size_t jobs) -> ContentGitMap;
diff --git a/src/other_tools/root_maps/distdir_git_map.cpp b/src/other_tools/root_maps/distdir_git_map.cpp
index f21994ba..bc9838eb 100644
--- a/src/other_tools/root_maps/distdir_git_map.cpp
+++ b/src/other_tools/root_maps/distdir_git_map.cpp
@@ -134,7 +134,7 @@ auto CreateDistdirGitMap(
gsl::not_null<CriticalGitOpMap*> const& critical_git_op_map,
std::optional<ServeApi> const& serve,
gsl::not_null<IExecutionApi const*> const& local_api,
- IExecutionApi::OptionalPtr const& remote_api,
+ IExecutionApi const* remote_api,
std::size_t jobs) -> DistdirGitMap {
auto distdir_to_git = [content_cas_map,
import_to_git_map,
@@ -236,7 +236,7 @@ auto CreateDistdirGitMap(
/*fatal=*/true);
return;
}
- if (not remote_api) {
+ if (remote_api == nullptr) {
(*logger)(
fmt::format(
"Missing or incompatible "
@@ -254,7 +254,7 @@ auto CreateDistdirGitMap(
*serve,
distdir_tree_id,
StorageConfig::GitRoot(),
- &(*remote_api.value()),
+ remote_api,
logger,
true /*no_sync_is_fatal*/)) {
return;
@@ -384,7 +384,7 @@ auto CreateDistdirGitMap(
return;
}
// we cannot continue without a suitable remote set up
- if (not remote_api) {
+ if (remote_api == nullptr) {
(*logger)(fmt::format(
"Cannot create workspace root {} as "
"absent for the provided serve endpoint.",
@@ -394,14 +394,14 @@ auto CreateDistdirGitMap(
}
// try to supply the serve endpoint with the tree via the
// remote CAS
- if (remote_api.value()->IsAvailable({digest})) {
+ if (remote_api->IsAvailable({digest})) {
// tell serve to set up the root from the remote CAS
// tree; upload can be skipped
if (EnsureAbsentRootOnServe(
*serve,
tree_id,
/*repo_path=*/"",
- /*remote_api=*/std::nullopt,
+ /*remote_api=*/nullptr,
logger,
/*no_sync_is_fatal=*/true)) {
// set workspace root as absent
@@ -425,7 +425,7 @@ auto CreateDistdirGitMap(
{Artifact::ObjectInfo{
.digest = digest,
.type = ObjectType::Tree}},
- **remote_api)) {
+ *remote_api)) {
(*logger)(fmt::format("Failed to sync tree {} from "
"local CAS with remote CAS.",
tree_id),
@@ -438,7 +438,7 @@ auto CreateDistdirGitMap(
*serve,
tree_id,
/*repo_path=*/"",
- /*remote_api=*/std::nullopt,
+ /*remote_api=*/nullptr,
logger,
/*no_sync_is_fatal=*/true)) {
// set workspace root as absent
@@ -483,7 +483,7 @@ auto CreateDistdirGitMap(
}
// now ask serve endpoint if it can set up the root; as this is for
// a present root, a corresponding remote endpoint is needed
- if (serve and remote_api) {
+ if (serve and remote_api != nullptr) {
auto serve_result =
serve->RetrieveTreeFromDistdir(key.content_list,
/*sync_tree=*/true);
diff --git a/src/other_tools/root_maps/distdir_git_map.hpp b/src/other_tools/root_maps/distdir_git_map.hpp
index 94ddbf9d..77717344 100644
--- a/src/other_tools/root_maps/distdir_git_map.hpp
+++ b/src/other_tools/root_maps/distdir_git_map.hpp
@@ -56,7 +56,7 @@ using DistdirGitMap =
gsl::not_null<CriticalGitOpMap*> const& critical_git_op_map,
std::optional<ServeApi> const& serve,
gsl::not_null<IExecutionApi const*> const& local_api,
- IExecutionApi::OptionalPtr const& remote_api,
+ IExecutionApi const* remote_api,
std::size_t jobs) -> DistdirGitMap;
namespace std {
diff --git a/src/other_tools/root_maps/fpath_git_map.cpp b/src/other_tools/root_maps/fpath_git_map.cpp
index 3f941bf5..2c918133 100644
--- a/src/other_tools/root_maps/fpath_git_map.cpp
+++ b/src/other_tools/root_maps/fpath_git_map.cpp
@@ -37,7 +37,7 @@ void CheckServeAndSetRoot(std::string const& tree_id,
std::string const& repo_root,
bool absent,
std::optional<ServeApi> const& serve,
- IExecutionApi::OptionalPtr const& remote_api,
+ IExecutionApi const* remote_api,
FilePathGitMap::SetterPtr const& ws_setter,
FilePathGitMap::LoggerPtr const& logger) {
// if serve endpoint is given, try to ensure it has this tree available to
@@ -50,7 +50,7 @@ void CheckServeAndSetRoot(std::string const& tree_id,
}
if (not *has_tree) {
// only enforce root setup on the serve endpoint if root is absent
- if (not remote_api) {
+ if (remote_api == nullptr) {
(*logger)(
fmt::format("Missing or incompatible remote-execution "
"endpoint needed to sync workspace root {} "
@@ -65,7 +65,7 @@ void CheckServeAndSetRoot(std::string const& tree_id,
if (not EnsureAbsentRootOnServe(*serve,
tree_id,
repo_root,
- &(*remote_api.value()),
+ remote_api,
logger,
/*no_sync_is_fatal=*/absent)) {
return; // fatal
@@ -101,7 +101,7 @@ void ResolveFilePathTree(
gsl::not_null<CriticalGitOpMap*> const& critical_git_op_map,
gsl::not_null<ResolveSymlinksMap*> const& resolve_symlinks_map,
std::optional<ServeApi> const& serve,
- IExecutionApi::OptionalPtr const& remote_api,
+ IExecutionApi const* remote_api,
gsl::not_null<TaskSystem*> const& ts,
FilePathGitMap::SetterPtr const& ws_setter,
FilePathGitMap::LoggerPtr const& logger) {
@@ -255,7 +255,7 @@ auto CreateFilePathGitMap(
gsl::not_null<ImportToGitMap*> const& import_to_git_map,
gsl::not_null<ResolveSymlinksMap*> const& resolve_symlinks_map,
std::optional<ServeApi> const& serve,
- IExecutionApi::OptionalPtr const& remote_api,
+ IExecutionApi const* remote_api,
std::size_t jobs,
std::string multi_repo_tool_name,
std::string build_tool_name) -> FilePathGitMap {
diff --git a/src/other_tools/root_maps/fpath_git_map.hpp b/src/other_tools/root_maps/fpath_git_map.hpp
index f66413c0..49550249 100644
--- a/src/other_tools/root_maps/fpath_git_map.hpp
+++ b/src/other_tools/root_maps/fpath_git_map.hpp
@@ -55,7 +55,7 @@ using FilePathGitMap = AsyncMapConsumer<FpathInfo, nlohmann::json>;
gsl::not_null<ImportToGitMap*> const& import_to_git_map,
gsl::not_null<ResolveSymlinksMap*> const& resolve_symlinks_map,
std::optional<ServeApi> const& serve,
- IExecutionApi::OptionalPtr const& remote_api,
+ IExecutionApi const* remote_api,
std::size_t jobs,
std::string multi_repo_tool_name,
std::string build_tool_name) -> FilePathGitMap;
diff --git a/src/other_tools/root_maps/root_utils.cpp b/src/other_tools/root_maps/root_utils.cpp
index 1b9de917..6e77cae8 100644
--- a/src/other_tools/root_maps/root_utils.cpp
+++ b/src/other_tools/root_maps/root_utils.cpp
@@ -38,10 +38,10 @@ auto CheckServeHasAbsentRoot(ServeApi const& serve,
auto EnsureAbsentRootOnServe(ServeApi const& serve,
std::string const& tree_id,
std::filesystem::path const& repo_path,
- IExecutionApi::OptionalPtr const& remote_api,
+ IExecutionApi const* remote_api,
AsyncMapConsumerLoggerPtr const& logger,
bool no_sync_is_fatal) -> bool {
- if (remote_api) {
+ if (remote_api != nullptr) {
// upload tree to remote CAS
auto repo = RepositoryConfig{};
if (not repo.SetGitCAS(repo_path)) {
@@ -55,7 +55,7 @@ auto EnsureAbsentRootOnServe(ServeApi const& serve,
{Artifact::ObjectInfo{
.digest = ArtifactDigest{tree_id, 0, /*is_tree=*/true},
.type = ObjectType::Tree}},
- **remote_api)) {
+ *remote_api)) {
(*logger)(fmt::format("Failed to sync tree {} from repository {}",
tree_id,
repo_path.string()),
diff --git a/src/other_tools/root_maps/root_utils.hpp b/src/other_tools/root_maps/root_utils.hpp
index d444176c..c055633f 100644
--- a/src/other_tools/root_maps/root_utils.hpp
+++ b/src/other_tools/root_maps/root_utils.hpp
@@ -58,7 +58,7 @@
ServeApi const& serve,
std::string const& tree_id,
std::filesystem::path const& repo_path,
- IExecutionApi::OptionalPtr const& remote_api,
+ IExecutionApi const* remote_api,
AsyncMapConsumerLoggerPtr const& logger,
bool no_sync_is_fatal) -> bool;
diff --git a/src/other_tools/root_maps/tree_id_git_map.cpp b/src/other_tools/root_maps/tree_id_git_map.cpp
index 690f756e..ecbda9c0 100644
--- a/src/other_tools/root_maps/tree_id_git_map.cpp
+++ b/src/other_tools/root_maps/tree_id_git_map.cpp
@@ -26,14 +26,13 @@ namespace {
/// \brief Guarantees it terminates by either calling the setter or calling the
/// logger with fatal.
-void UploadToServeAndSetRoot(
- ServeApi const& serve,
- std::string const& tree_id,
- ArtifactDigest const& digest,
- gsl::not_null<IExecutionApi const*> const& remote_api,
- bool ignore_special,
- TreeIdGitMap::SetterPtr const& setter,
- TreeIdGitMap::LoggerPtr const& logger) {
+void UploadToServeAndSetRoot(ServeApi const& serve,
+ std::string const& tree_id,
+ ArtifactDigest const& digest,
+ IExecutionApi const& remote_api,
+ bool ignore_special,
+ TreeIdGitMap::SetterPtr const& setter,
+ TreeIdGitMap::LoggerPtr const& logger) {
// upload to remote CAS
auto repo_config = RepositoryConfig{};
if (repo_config.SetGitCAS(StorageConfig::GitRoot())) {
@@ -41,7 +40,7 @@ void UploadToServeAndSetRoot(
if (not git_api.RetrieveToCas(
{Artifact::ObjectInfo{.digest = digest,
.type = ObjectType::Tree}},
- *remote_api)) {
+ remote_api)) {
(*logger)(fmt::format("Failed to sync tree {} from local Git cache "
"to remote CAS",
tree_id),
@@ -60,7 +59,7 @@ void UploadToServeAndSetRoot(
if (EnsureAbsentRootOnServe(serve,
tree_id,
/*repo_path=*/"",
- /*remote_api=*/std::nullopt,
+ /*remote_api=*/nullptr,
logger,
/*no_sync_is_fatal=*/true)) {
// set workspace root as absent
@@ -126,7 +125,7 @@ void MoveCASTreeToGitAndProcess(
UploadToServeAndSetRoot(serve,
tree_id,
digest,
- remote_api,
+ *remote_api,
ignore_special,
setter,
logger);
@@ -150,7 +149,7 @@ auto CreateTreeIdGitMap(
bool fetch_absent,
std::optional<ServeApi> const& serve,
gsl::not_null<IExecutionApi const*> const& local_api,
- IExecutionApi::OptionalPtr const& remote_api,
+ IExecutionApi const* remote_api,
std::size_t jobs) -> TreeIdGitMap {
auto tree_to_git = [git_tree_fetch_map,
critical_git_op_map,
@@ -187,7 +186,7 @@ auto CreateTreeIdGitMap(
return;
}
// we cannot continue without a suitable remote set up
- if (not remote_api) {
+ if (remote_api == nullptr) {
(*logger)(
fmt::format("Cannot create workspace root {} as absent "
"for the provided serve endpoint.",
@@ -198,13 +197,13 @@ auto CreateTreeIdGitMap(
// check if tree in already in remote CAS
auto digest =
ArtifactDigest{key.tree_info.hash, 0, /*is_tree=*/true};
- if (remote_api.value()->IsAvailable({digest})) {
+ if (remote_api->IsAvailable({digest})) {
// tell serve to set up the root from the remote CAS tree;
// upload can be skipped
if (EnsureAbsentRootOnServe(*serve,
key.tree_info.hash,
/*repo_path=*/"",
- /*remote_api=*/std::nullopt,
+ /*remote_api=*/nullptr,
logger,
/*no_sync_is_fatal=*/true)) {
// set workspace root as absent
@@ -307,7 +306,7 @@ auto CreateTreeIdGitMap(
digest,
import_to_git_map,
local_api,
- *remote_api,
+ remote_api,
key.ignore_special,
ts,
setter,
diff --git a/src/other_tools/root_maps/tree_id_git_map.hpp b/src/other_tools/root_maps/tree_id_git_map.hpp
index d2a1c776..d1a28351 100644
--- a/src/other_tools/root_maps/tree_id_git_map.hpp
+++ b/src/other_tools/root_maps/tree_id_git_map.hpp
@@ -71,7 +71,7 @@ using TreeIdGitMap =
bool fetch_absent,
std::optional<ServeApi> const& serve,
gsl::not_null<IExecutionApi const*> const& local_api,
- IExecutionApi::OptionalPtr const& remote_api,
+ IExecutionApi const* remote_api,
std::size_t jobs) -> TreeIdGitMap;
#endif // INCLUDED_SRC_OTHER_TOOLS_ROOT_MAPS_TREE_ID_GIT_MAP_HPP