summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/other_tools/just_mr/TARGETS7
-rw-r--r--src/other_tools/just_mr/fetch.cpp75
-rw-r--r--src/other_tools/just_mr/setup.cpp154
-rw-r--r--src/other_tools/just_mr/setup_utils.cpp37
-rw-r--r--src/other_tools/just_mr/setup_utils.hpp10
-rw-r--r--src/other_tools/ops_maps/TARGETS3
-rw-r--r--src/other_tools/root_maps/TARGETS4
7 files changed, 128 insertions, 162 deletions
diff --git a/src/other_tools/just_mr/TARGETS b/src/other_tools/just_mr/TARGETS
index f5f64e99..df99e7ef 100644
--- a/src/other_tools/just_mr/TARGETS
+++ b/src/other_tools/just_mr/TARGETS
@@ -84,7 +84,6 @@
, "deps":
[ ["src/buildtool/build_engine/expression", "expression_ptr_interface"]
, ["src/buildtool/build_engine/expression", "expression"]
- , ["src/buildtool/execution_api/common", "common"]
, ["src/buildtool/serve_api/remote", "config"]
, "cli"
]
@@ -96,8 +95,6 @@
, ["src/buildtool/logging", "logging"]
, "exit_codes"
, ["src/buildtool/auth", "auth"]
- , ["src/buildtool/execution_api/bazel_msg", "bazel_msg"]
- , ["src/buildtool/execution_api/remote", "bazel"]
]
}
, "fetch":
@@ -123,7 +120,7 @@
, ["src/other_tools/utils", "parse_archive"]
, "setup_utils"
, ["src/buildtool/execution_api/common", "common"]
- , ["src/buildtool/execution_api/local", "local"]
+ , ["src/buildtool/execution_api/common", "api_bundle"]
, ["src/buildtool/serve_api/remote", "config"]
, ["src/buildtool/serve_api/remote", "serve_api"]
]
@@ -177,7 +174,7 @@
, ["src/buildtool/file_system/symlinks_map", "resolve_symlinks_map"]
, "setup_utils"
, ["src/buildtool/execution_api/common", "common"]
- , ["src/buildtool/execution_api/local", "local"]
+ , ["src/buildtool/execution_api/common", "api_bundle"]
, ["src/buildtool/serve_api/remote", "config"]
, ["src/buildtool/serve_api/remote", "serve_api"]
]
diff --git a/src/other_tools/just_mr/fetch.cpp b/src/other_tools/just_mr/fetch.cpp
index 0aab2549..4b90dd61 100644
--- a/src/other_tools/just_mr/fetch.cpp
+++ b/src/other_tools/just_mr/fetch.cpp
@@ -20,8 +20,8 @@
#include "fmt/core.h"
#include "nlohmann/json.hpp"
+#include "src/buildtool/execution_api/common/api_bundle.hpp"
#include "src/buildtool/execution_api/common/execution_api.hpp"
-#include "src/buildtool/execution_api/local/local_api.hpp"
#include "src/buildtool/logging/log_level.hpp"
#include "src/buildtool/logging/logger.hpp"
#include "src/buildtool/multithreading/task_system.hpp"
@@ -393,12 +393,13 @@ auto MultiRepoFetch(std::shared_ptr<Configuration> const& config,
}
// setup the APIs for archive fetches; only happens if in native mode
- auto remote_api =
- JustMR::Utils::GetRemoteApi(common_args.remote_execution_address,
- common_args.remote_serve_address,
- auth_args);
- IExecutionApi::Ptr local_api{std::make_unique<LocalApi>()};
- bool remote_compatible{common_args.compatible};
+ JustMR::Utils::SetupRemoteConfig(common_args.remote_execution_address,
+ common_args.remote_serve_address,
+ auth_args);
+
+ ApiBundle const apis{std::nullopt, RemoteExecutionConfig::RemoteAddress()};
+ bool const has_remote_api =
+ apis.local != apis.remote and not common_args.compatible;
// setup the API for serving roots
auto serve_config = JustMR::Utils::CreateServeConfig(
@@ -412,7 +413,7 @@ auto MultiRepoFetch(std::shared_ptr<Configuration> const& config,
if (serve) {
// if we have a remote endpoint explicitly given by the user, it must
// match what the serve endpoint expects
- if (remote_api and common_args.remote_execution_address and
+ if (common_args.remote_execution_address and
not serve->CheckServeRemoteExecution()) {
return kExitFetchError; // this check logs error on failure
}
@@ -438,45 +439,41 @@ 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,
- &(*local_api),
- (remote_api and not remote_compatible)
- ? std::make_optional(&(*remote_api))
- : std::nullopt,
- common_args.jobs);
-
- auto archive_fetch_map = CreateArchiveFetchMap(
- &content_cas_map,
- *fetch_dir,
- &(*local_api),
- (fetch_args.backup_to_remote and remote_api and not remote_compatible)
- ? std::make_optional(&(*remote_api))
- : std::nullopt,
+ 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 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,
- &(*local_api),
- (remote_api and not remote_compatible)
- ? std::make_optional(&(*remote_api))
- : 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 ? std::make_optional(&(*apis.remote)) : std::nullopt,
+ 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 9e271467..0900c4fa 100644
--- a/src/other_tools/just_mr/setup.cpp
+++ b/src/other_tools/just_mr/setup.cpp
@@ -21,8 +21,8 @@
#include <thread>
#include "nlohmann/json.hpp"
+#include "src/buildtool/execution_api/common/api_bundle.hpp"
#include "src/buildtool/execution_api/common/execution_api.hpp"
-#include "src/buildtool/execution_api/local/local_api.hpp"
#include "src/buildtool/file_system/symlinks_map/resolve_symlinks_map.hpp"
#include "src/buildtool/logging/log_level.hpp"
#include "src/buildtool/logging/logger.hpp"
@@ -111,12 +111,14 @@ auto MultiRepoSetup(std::shared_ptr<Configuration> const& config,
}
// setup the APIs for archive fetches; only happens if in native mode
- auto remote_api =
- JustMR::Utils::GetRemoteApi(common_args.remote_execution_address,
- common_args.remote_serve_address,
- auth_args);
- IExecutionApi::Ptr local_api{std::make_unique<LocalApi>()};
- bool remote_compatible{common_args.compatible};
+ // setup the APIs for archive fetches; only happens if in native mode
+ JustMR::Utils::SetupRemoteConfig(common_args.remote_execution_address,
+ common_args.remote_serve_address,
+ auth_args);
+
+ ApiBundle const apis{std::nullopt, RemoteExecutionConfig::RemoteAddress()};
+ bool const has_remote_api =
+ apis.local != apis.remote and not common_args.compatible;
// setup the API for serving roots
auto serve_config = JustMR::Utils::CreateServeConfig(
@@ -131,7 +133,7 @@ auto MultiRepoSetup(std::shared_ptr<Configuration> const& config,
if (serve) {
// if we have a remote endpoint explicitly given by the user, it must
// match what the serve endpoint expects
- if (remote_api and common_args.remote_execution_address and
+ if (common_args.remote_execution_address and
not serve->CheckServeRemoteExecution()) {
return std::nullopt; // this check logs error on failure
}
@@ -157,17 +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,
- &(*local_api),
- (remote_api and not remote_compatible)
- ? std::make_optional(&(*remote_api))
- : 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 ? std::make_optional(&(*apis.remote)) : std::nullopt,
+ common_args.jobs);
auto import_to_git_map =
CreateImportToGitMap(&critical_git_op_map,
@@ -175,50 +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,
- &(*local_api),
- (remote_api and not remote_compatible)
- ? std::make_optional(&(*remote_api))
- : 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 ? std::make_optional(&(*apis.remote)) : std::nullopt,
+ 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,
- &(*local_api),
- (remote_api and not remote_compatible)
- ? std::make_optional(&(*remote_api))
- : 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 ? 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,
- (remote_api and not remote_compatible)
- ? std::make_optional(&(*remote_api))
- : 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 ? std::make_optional(&(*apis.remote)) : std::nullopt,
+ common_args.fetch_absent,
+ common_args.jobs);
auto foreign_file_git_map =
CreateForeignFileGitMap(&content_cas_map,
@@ -233,36 +227,30 @@ auto MultiRepoSetup(std::shared_ptr<Configuration> const& config,
&import_to_git_map,
&resolve_symlinks_map,
serve,
- (remote_api and not remote_compatible)
- ? std::make_optional(&(*remote_api))
- : std::nullopt,
+ has_remote_api ? std::make_optional(&(*apis.remote)) : std::nullopt,
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,
- &(*local_api),
- (remote_api and not remote_compatible)
- ? std::make_optional(&(*remote_api))
- : 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 ? 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,
- &(*local_api),
- (remote_api and not remote_compatible)
- ? std::make_optional(&(*remote_api))
- : 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 ? std::make_optional(&(*apis.remote)) : std::nullopt,
+ common_args.jobs);
auto repos_to_setup_map = CreateReposToSetupMap(config,
main,
diff --git a/src/other_tools/just_mr/setup_utils.cpp b/src/other_tools/just_mr/setup_utils.cpp
index 7c09b580..4ed6f94d 100644
--- a/src/other_tools/just_mr/setup_utils.cpp
+++ b/src/other_tools/just_mr/setup_utils.cpp
@@ -21,8 +21,6 @@
#include "nlohmann/json.hpp"
#include "src/buildtool/auth/authentication.hpp"
#include "src/buildtool/build_engine/expression/expression.hpp"
-#include "src/buildtool/execution_api/bazel_msg/bazel_common.hpp"
-#include "src/buildtool/execution_api/remote/bazel/bazel_api.hpp"
#include "src/buildtool/file_system/file_system_manager.hpp"
#include "src/buildtool/logging/log_level.hpp"
#include "src/buildtool/logging/logger.hpp"
@@ -236,30 +234,25 @@ auto ReadConfiguration(
}
}
-auto GetRemoteApi(std::optional<std::string> const& remote_exec_addr,
- std::optional<std::string> const& remote_serve_addr,
- MultiRepoRemoteAuthArguments const& auth) noexcept
- -> IExecutionApi::Ptr {
+void SetupRemoteConfig(std::optional<std::string> const& remote_exec_addr,
+ std::optional<std::string> const& remote_serve_addr,
+ MultiRepoRemoteAuthArguments const& auth) noexcept {
// if only a serve endpoint address is given, we assume it is one that acts
// also as remote-execution
auto remote_addr = remote_exec_addr ? remote_exec_addr : remote_serve_addr;
- if (remote_addr) {
- // setup authentication
- SetupAuthConfig(auth);
- // setup remote
- if (not RemoteExecutionConfig::SetRemoteAddress(*remote_addr)) {
- Logger::Log(LogLevel::Error,
- "setting remote execution address '{}' failed.",
- *remote_addr);
- std::exit(kExitConfigError);
- }
- auto address = RemoteExecutionConfig::RemoteAddress();
- ExecutionConfiguration config;
- config.skip_cache_lookup = false;
- return std::make_unique<BazelApi>(
- "remote-execution", address->host, address->port, config);
+ if (not remote_addr) {
+ return;
+ }
+
+ // setup authentication
+ SetupAuthConfig(auth);
+ // setup remote
+ if (not RemoteExecutionConfig::SetRemoteAddress(*remote_addr)) {
+ Logger::Log(LogLevel::Error,
+ "setting remote execution address '{}' failed.",
+ *remote_addr);
+ std::exit(kExitConfigError);
}
- return nullptr;
}
auto CreateServeConfig(std::optional<std::string> const& remote_serve_addr,
diff --git a/src/other_tools/just_mr/setup_utils.hpp b/src/other_tools/just_mr/setup_utils.hpp
index cc3ab86a..f29dbef1 100644
--- a/src/other_tools/just_mr/setup_utils.hpp
+++ b/src/other_tools/just_mr/setup_utils.hpp
@@ -23,7 +23,6 @@
#include "src/buildtool/build_engine/expression/configuration.hpp"
#include "src/buildtool/build_engine/expression/expression_ptr.hpp"
-#include "src/buildtool/execution_api/common/execution_api.hpp"
#include "src/buildtool/serve_api/remote/config.hpp"
#include "src/other_tools/just_mr/cli.hpp"
@@ -61,12 +60,9 @@ void DefaultReachableRepositories(
std::optional<std::filesystem::path> const& absent_file_opt) noexcept
-> std::shared_ptr<Configuration>;
-/// \brief Get a remote API instance based on just-mr arguments.
-/// \returns Pointer to a configured remote API, or nullptr.
-[[nodiscard]] auto GetRemoteApi(
- std::optional<std::string> const& remote_exec_addr,
- std::optional<std::string> const& remote_serve_addr,
- MultiRepoRemoteAuthArguments const& auth) noexcept -> IExecutionApi::Ptr;
+void SetupRemoteConfig(std::optional<std::string> const& remote_exec_addr,
+ std::optional<std::string> const& remote_serve_addr,
+ MultiRepoRemoteAuthArguments const& auth) noexcept;
/// \brief Setup of a 'just serve' remote API based on just-mr arguments.
/// \returns RemoteServeConfig if initialization was successfull or std::nullopt
diff --git a/src/other_tools/ops_maps/TARGETS b/src/other_tools/ops_maps/TARGETS
index dcf58392..5bfd9093 100644
--- a/src/other_tools/ops_maps/TARGETS
+++ b/src/other_tools/ops_maps/TARGETS
@@ -72,7 +72,6 @@
, "private-deps":
[ ["@", "fmt", "", "fmt"]
, ["src/other_tools/utils", "content"]
- , ["src/buildtool/execution_api/local", "local"]
, ["src/buildtool/file_system", "file_storage"]
, ["src/buildtool/storage", "config"]
, ["src/buildtool/storage", "fs_utils"]
@@ -96,7 +95,6 @@
, "private-deps":
[ ["@", "fmt", "", "fmt"]
, ["src/other_tools/just_mr", "utils"]
- , ["src/buildtool/execution_api/local", "local"]
, ["src/buildtool/file_system", "file_storage"]
, ["src/buildtool/file_system", "file_system_manager"]
, ["src/other_tools/just_mr/progress_reporting", "statistics"]
@@ -120,7 +118,6 @@
[ ["src/other_tools/ops_maps", "critical_git_op_map"]
, ["src/buildtool/common", "config"]
, ["src/buildtool/compatibility", "compatibility"]
- , ["src/buildtool/execution_api/common", "common"]
, ["src/buildtool/file_system", "file_system_manager"]
, ["src/buildtool/multithreading", "task_system"]
, ["src/buildtool/storage", "config"]
diff --git a/src/other_tools/root_maps/TARGETS b/src/other_tools/root_maps/TARGETS
index d88f09f8..77623d14 100644
--- a/src/other_tools/root_maps/TARGETS
+++ b/src/other_tools/root_maps/TARGETS
@@ -7,6 +7,7 @@
[ ["@", "gsl", "", "gsl"]
, ["@", "json", "", "json"]
, ["src/other_tools/ops_maps", "import_to_git_map"]
+ , ["src/buildtool/execution_api/common", "common"]
, ["src/other_tools/ops_maps", "content_cas_map"]
, ["src/buildtool/serve_api/remote", "serve_api"]
]
@@ -15,9 +16,7 @@
[ ["@", "fmt", "", "fmt"]
, "root_utils"
, ["src/buildtool/common", "common"]
- , ["src/buildtool/execution_api/common", "common"]
, ["src/buildtool/execution_api/local", "config"]
- , ["src/buildtool/execution_api/local", "local"]
, ["src/buildtool/file_system", "file_root"]
, ["src/buildtool/file_system", "file_storage"]
, ["src/buildtool/file_system", "git_repo"]
@@ -116,7 +115,6 @@
, "private-deps":
[ ["@", "fmt", "", "fmt"]
, "root_utils"
- , ["src/buildtool/execution_api/local", "local"]
, ["src/buildtool/file_system", "file_root"]
, ["src/buildtool/file_system", "file_storage"]
, ["src/buildtool/file_system", "git_repo"]