diff options
author | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2024-10-21 15:37:44 +0200 |
---|---|---|
committer | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2024-10-25 13:00:43 +0200 |
commit | e6127d3cbd4fb8b3dd82bc740692877b72f977b7 (patch) | |
tree | b229db4b17c4bcfef5ea9ea8deed61f355bf151d /src/other_tools/just_mr/fetch.cpp | |
parent | 5e0fea2f02f8e721f44ea23302ade010e9f9bb97 (diff) | |
download | justbuild-e6127d3cbd4fb8b3dd82bc740692877b72f977b7.tar.gz |
Enable compatible mode for just-mr and SourceTree serve service...
...by using the new local api that can handle any remote endpoint,
irrespective of protocol.
Also ensure all tests for the serve service are now being run both
in native and compatible modes.
Diffstat (limited to 'src/other_tools/just_mr/fetch.cpp')
-rw-r--r-- | src/other_tools/just_mr/fetch.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/other_tools/just_mr/fetch.cpp b/src/other_tools/just_mr/fetch.cpp index fdea8812..99f21eb1 100644 --- a/src/other_tools/just_mr/fetch.cpp +++ b/src/other_tools/just_mr/fetch.cpp @@ -32,6 +32,7 @@ #include "src/buildtool/execution_api/remote/bazel/bazel_api.hpp" #include "src/buildtool/execution_api/remote/config.hpp" #include "src/buildtool/execution_api/remote/context.hpp" +#include "src/buildtool/execution_api/serve/mr_local_api.hpp" #include "src/buildtool/logging/log_level.hpp" #include "src/buildtool/logging/logger.hpp" #include "src/buildtool/main/retry.hpp" @@ -341,6 +342,7 @@ auto MultiRepoFetch(std::shared_ptr<Configuration> const& config, std::unique_ptr<Storage> compat_storage = nullptr; std::unique_ptr<LocalContext> compat_local_context = nullptr; std::optional<LockFile> compat_lock = std::nullopt; + IExecutionApi::Ptr compat_local_api = nullptr; if (common_args.compatible) { auto config = StorageConfig::Builder{} .SetBuildRoot(native_storage_config.build_root) @@ -366,8 +368,16 @@ auto MultiRepoFetch(std::shared_ptr<Configuration> const& config, "Failed to acquire compatible storage gc lock"); return kExitConfigError; } + compat_local_api = std::make_shared<LocalApi>(&*compat_local_context); } + // setup the overall local api, aware of compatibility + IExecutionApi::Ptr mr_local_api = std::make_shared<MRLocalApi>( + &native_local_context, + &*native_local_api, + common_args.compatible ? &*compat_local_context : nullptr, + common_args.compatible ? &*compat_local_api : nullptr); + // setup authentication config auto const auth_config = JustMR::Utils::CreateAuthConfig(auth_args); if (not auth_config) { @@ -404,8 +414,7 @@ auto MultiRepoFetch(std::shared_ptr<Configuration> const& config, config, &hash_fct); } - bool const has_remote_api = - remote_api != nullptr and not common_args.compatible; + bool const has_remote_api = remote_api != nullptr; // pack the remote context RemoteContext const remote_context{.auth = &*auth_config, @@ -420,8 +429,8 @@ auto MultiRepoFetch(std::shared_ptr<Configuration> const& config, } auto const apis = ApiBundle{.hash_function = hash_fct, - .local = native_local_api, - .remote = has_remote_api ? remote_api : native_local_api}; + .local = mr_local_api, + .remote = has_remote_api ? remote_api : mr_local_api}; auto serve = ServeApi::Create( *serve_config, compat_local_context != nullptr |