From 978de9de55d9592c258052dd52dc25c788a89d78 Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Mon, 8 Jul 2024 11:28:13 +0200 Subject: Remove the LocalExecutionConfig singleton ...and replace it with passed instances created early via a builder pattern. --- src/other_tools/just_mr/TARGETS | 1 + src/other_tools/just_mr/fetch.cpp | 9 ++++++++- src/other_tools/just_mr/setup.cpp | 9 ++++++++- src/other_tools/just_mr/setup_utils.cpp | 16 ++++++++++++++++ src/other_tools/just_mr/setup_utils.hpp | 5 +++++ 5 files changed, 38 insertions(+), 2 deletions(-) (limited to 'src/other_tools') diff --git a/src/other_tools/just_mr/TARGETS b/src/other_tools/just_mr/TARGETS index 560a08f6..3b4a3df6 100644 --- a/src/other_tools/just_mr/TARGETS +++ b/src/other_tools/just_mr/TARGETS @@ -87,6 +87,7 @@ [ ["src/buildtool/auth", "auth"] , ["src/buildtool/build_engine/expression", "expression_ptr_interface"] , ["src/buildtool/build_engine/expression", "expression"] + , ["src/buildtool/execution_api/local", "config"] , ["src/buildtool/serve_api/remote", "config"] , "cli" ] diff --git a/src/other_tools/just_mr/fetch.cpp b/src/other_tools/just_mr/fetch.cpp index 6b247e7c..44b9bdb1 100644 --- a/src/other_tools/just_mr/fetch.cpp +++ b/src/other_tools/just_mr/fetch.cpp @@ -407,9 +407,16 @@ auto MultiRepoFetch(std::shared_ptr const& config, return kExitConfigError; } + // setup local execution + auto local_exec_config = + JustMR::Utils::CreateLocalExecutionConfig(common_args); + if (not local_exec_config) { + return kExitConfigError; + } + ApiBundle const apis{&storage_config, &storage, - &LocalExecutionConfig::Instance(), + &*local_exec_config, /*repo_config=*/nullptr, &*auth_config, RemoteExecutionConfig::RemoteAddress()}; diff --git a/src/other_tools/just_mr/setup.cpp b/src/other_tools/just_mr/setup.cpp index 10c15312..6cf5eaa6 100644 --- a/src/other_tools/just_mr/setup.cpp +++ b/src/other_tools/just_mr/setup.cpp @@ -126,9 +126,16 @@ auto MultiRepoSetup(std::shared_ptr const& config, return std::nullopt; } + // setup local execution + auto local_exec_config = + JustMR::Utils::CreateLocalExecutionConfig(common_args); + if (not local_exec_config) { + return std::nullopt; + } + ApiBundle const apis{&storage_config, &storage, - &LocalExecutionConfig::Instance(), + &*local_exec_config, /*repo_config=*/nullptr, &*auth_config, RemoteExecutionConfig::RemoteAddress()}; diff --git a/src/other_tools/just_mr/setup_utils.cpp b/src/other_tools/just_mr/setup_utils.cpp index 2c219d95..ae6f5a28 100644 --- a/src/other_tools/just_mr/setup_utils.cpp +++ b/src/other_tools/just_mr/setup_utils.cpp @@ -217,6 +217,22 @@ auto CreateAuthConfig(MultiRepoRemoteAuthArguments const& authargs) noexcept return Auth{}; } +auto CreateLocalExecutionConfig(MultiRepoCommonArguments const& cargs) noexcept + -> std::optional { + + LocalExecutionConfig::Builder builder; + if (cargs.local_launcher.has_value()) { + builder.SetLauncher(*cargs.local_launcher); + } + + auto config = builder.Build(); + if (config) { + return *std::move(config); + } + Logger::Log(LogLevel::Error, config.error()); + return std::nullopt; +} + void SetupRemoteConfig( std::optional const& remote_exec_addr, std::optional const& remote_serve_addr) noexcept { diff --git a/src/other_tools/just_mr/setup_utils.hpp b/src/other_tools/just_mr/setup_utils.hpp index 3043855c..f96ca81e 100644 --- a/src/other_tools/just_mr/setup_utils.hpp +++ b/src/other_tools/just_mr/setup_utils.hpp @@ -24,6 +24,7 @@ #include "src/buildtool/auth/authentication.hpp" #include "src/buildtool/build_engine/expression/configuration.hpp" #include "src/buildtool/build_engine/expression/expression_ptr.hpp" +#include "src/buildtool/execution_api/local/config.hpp" #include "src/buildtool/serve_api/remote/config.hpp" #include "src/other_tools/just_mr/cli.hpp" @@ -65,6 +66,10 @@ void DefaultReachableRepositories( MultiRepoRemoteAuthArguments const& authargs) noexcept -> std::optional; +[[nodiscard]] auto CreateLocalExecutionConfig( + MultiRepoCommonArguments const& cargs) noexcept + -> std::optional; + void SetupRemoteConfig( std::optional const& remote_exec_addr, std::optional const& remote_serve_addr) noexcept; -- cgit v1.2.3