diff options
Diffstat (limited to 'src/other_tools/just_mr/setup.cpp')
-rw-r--r-- | src/other_tools/just_mr/setup.cpp | 154 |
1 files changed, 71 insertions, 83 deletions
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, |