summaryrefslogtreecommitdiff
path: root/src/other_tools
diff options
context:
space:
mode:
authorPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2024-07-08 11:28:13 +0200
committerPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2024-07-16 17:51:12 +0200
commit978de9de55d9592c258052dd52dc25c788a89d78 (patch)
treedff959d84f1d95af1f0546471d3b2c7eaa47dbc2 /src/other_tools
parentb4cd4d0c0d1b526eab3549c9cba12179dbba3a3f (diff)
downloadjustbuild-978de9de55d9592c258052dd52dc25c788a89d78.tar.gz
Remove the LocalExecutionConfig singleton
...and replace it with passed instances created early via a builder pattern.
Diffstat (limited to 'src/other_tools')
-rw-r--r--src/other_tools/just_mr/TARGETS1
-rw-r--r--src/other_tools/just_mr/fetch.cpp9
-rw-r--r--src/other_tools/just_mr/setup.cpp9
-rw-r--r--src/other_tools/just_mr/setup_utils.cpp16
-rw-r--r--src/other_tools/just_mr/setup_utils.hpp5
5 files changed, 38 insertions, 2 deletions
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<Configuration> 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<Configuration> 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> {
+
+ 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<std::string> const& remote_exec_addr,
std::optional<std::string> 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<Auth>;
+[[nodiscard]] auto CreateLocalExecutionConfig(
+ MultiRepoCommonArguments const& cargs) noexcept
+ -> std::optional<LocalExecutionConfig>;
+
void SetupRemoteConfig(
std::optional<std::string> const& remote_exec_addr,
std::optional<std::string> const& remote_serve_addr) noexcept;