diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/buildtool/execution_api/common/api_bundle.cpp | 5 | ||||
-rw-r--r-- | src/buildtool/execution_api/common/api_bundle.hpp | 6 | ||||
-rw-r--r-- | src/buildtool/execution_api/local/local_api.hpp | 26 | ||||
-rw-r--r-- | src/buildtool/main/main.cpp | 4 | ||||
-rw-r--r-- | src/other_tools/just_mr/fetch.cpp | 2 | ||||
-rw-r--r-- | src/other_tools/just_mr/setup.cpp | 2 |
6 files changed, 20 insertions, 25 deletions
diff --git a/src/buildtool/execution_api/common/api_bundle.cpp b/src/buildtool/execution_api/common/api_bundle.cpp index bbcaa3b5..488fc25d 100644 --- a/src/buildtool/execution_api/common/api_bundle.cpp +++ b/src/buildtool/execution_api/common/api_bundle.cpp @@ -18,9 +18,8 @@ #include "src/buildtool/execution_api/local/local_api.hpp" #include "src/buildtool/execution_api/remote/bazel/bazel_api.hpp" -ApiBundle::ApiBundle( - std::optional<gsl::not_null<const RepositoryConfig*>> const& repo_config, - std::optional<ServerAddress> const& remote_address) +ApiBundle::ApiBundle(RepositoryConfig const* repo_config, + std::optional<ServerAddress> const& remote_address) : local{std::make_shared<LocalApi>(repo_config)}, remote{CreateRemote(remote_address)} {} diff --git a/src/buildtool/execution_api/common/api_bundle.hpp b/src/buildtool/execution_api/common/api_bundle.hpp index 58a80677..53e59de2 100644 --- a/src/buildtool/execution_api/common/api_bundle.hpp +++ b/src/buildtool/execution_api/common/api_bundle.hpp @@ -27,10 +27,8 @@ /// same time. If the remote api cannot be instantiated, it falls back to /// exactly the same instance that local api is (&*remote == & *local). struct ApiBundle final { - explicit ApiBundle( - std::optional<gsl::not_null<const RepositoryConfig*>> const& - repo_config, - std::optional<ServerAddress> const& remote_address); + explicit ApiBundle(RepositoryConfig const* repo_config, + std::optional<ServerAddress> const& remote_address); [[nodiscard]] auto CreateRemote(std::optional<ServerAddress> const& address) const -> gsl::not_null<IExecutionApi::Ptr>; diff --git a/src/buildtool/execution_api/local/local_api.hpp b/src/buildtool/execution_api/local/local_api.hpp index 8e1964c0..85547de1 100644 --- a/src/buildtool/execution_api/local/local_api.hpp +++ b/src/buildtool/execution_api/local/local_api.hpp @@ -53,9 +53,8 @@ /// \brief API for local execution. class LocalApi final : public IExecutionApi { public: - explicit LocalApi(std::optional<gsl::not_null<const RepositoryConfig*>> - repo_config = std::nullopt) - : repo_config_{std::move(repo_config)} {} + explicit LocalApi(RepositoryConfig const* repo_config = nullptr) noexcept + : repo_config_{repo_config} {} [[nodiscard]] auto CreateAction( ArtifactDigest const& root_digest, @@ -99,8 +98,8 @@ class LocalApi final : public IExecutionApi { // fall back to git return false; } - if (repo_config_ and - not GitApi(repo_config_.value()) + if (repo_config_ != nullptr and + not GitApi(repo_config_) .RetrieveToPaths({info}, {output_paths[i]})) { return false; } @@ -118,8 +117,8 @@ class LocalApi final : public IExecutionApi { // fall back to git return false; } - if (repo_config_ and - not GitApi(repo_config_.value()) + if (repo_config_ != nullptr and + not GitApi(repo_config_) .RetrieveToPaths({info}, {output_paths[i]})) { return false; } @@ -152,15 +151,15 @@ class LocalApi final : public IExecutionApi { gsl::not_null<FILE*> const& out) { return dumper.DumpToStream(info, out, raw_tree); }, - [&repo_config = repo_config_, &raw_tree]( + [repo_config = repo_config_, &raw_tree]( Artifact::ObjectInfo const& info, int fd) { if (Compatibility::IsCompatible()) { // infos not available, and in compatible mode cannot // fall back to git return false; } - if (repo_config and - not GitApi(repo_config.value()) + if (repo_config != nullptr and + not GitApi(repo_config) .RetrieveToFds({info}, {fd}, raw_tree)) { return false; } @@ -262,9 +261,8 @@ class LocalApi final : public IExecutionApi { if (location) { content = FileSystemManager::ReadFile(*location); } - if ((not content) and repo_config_) { - content = - GitApi(repo_config_.value()).RetrieveToMemory(artifact_info); + if ((not content) and repo_config_ != nullptr) { + content = GitApi(repo_config_).RetrieveToMemory(artifact_info); } return content; } @@ -409,7 +407,7 @@ class LocalApi final : public IExecutionApi { } private: - std::optional<gsl::not_null<const RepositoryConfig*>> repo_config_{}; + RepositoryConfig const* const repo_config_ = nullptr; gsl::not_null<Storage const*> storage_ = &Storage::Instance(); }; diff --git a/src/buildtool/main/main.cpp b/src/buildtool/main/main.cpp index 5a8b0bcf..457bfcd1 100644 --- a/src/buildtool/main/main.cpp +++ b/src/buildtool/main/main.cpp @@ -826,7 +826,7 @@ auto main(int argc, char* argv[]) -> int { if (arguments.cmd == SubCommand::kExecute) { SetupExecutionServiceConfig(arguments.service); - ApiBundle const exec_apis{std::nullopt, + ApiBundle const exec_apis{nullptr, RemoteExecutionConfig::RemoteAddress()}; if (!ServerImpl::Instance().Run(exec_apis)) { return kExitFailure; @@ -842,7 +842,7 @@ auto main(int argc, char* argv[]) -> int { arguments.service.pid_file); if (serve_server) { ApiBundle const serve_apis{ - std::nullopt, RemoteExecutionConfig::RemoteAddress()}; + nullptr, RemoteExecutionConfig::RemoteAddress()}; auto serve = ServeApi::Create(*serve_config, &serve_apis); bool with_execute = not RemoteExecutionConfig::RemoteAddress(); return serve_server->Run( diff --git a/src/other_tools/just_mr/fetch.cpp b/src/other_tools/just_mr/fetch.cpp index a31368b9..ab6e593b 100644 --- a/src/other_tools/just_mr/fetch.cpp +++ b/src/other_tools/just_mr/fetch.cpp @@ -397,7 +397,7 @@ auto MultiRepoFetch(std::shared_ptr<Configuration> const& config, common_args.remote_serve_address, auth_args); - ApiBundle const apis{std::nullopt, RemoteExecutionConfig::RemoteAddress()}; + ApiBundle const apis{nullptr, RemoteExecutionConfig::RemoteAddress()}; bool const has_remote_api = apis.local != apis.remote and not common_args.compatible; diff --git a/src/other_tools/just_mr/setup.cpp b/src/other_tools/just_mr/setup.cpp index e92d307c..a383734a 100644 --- a/src/other_tools/just_mr/setup.cpp +++ b/src/other_tools/just_mr/setup.cpp @@ -116,7 +116,7 @@ auto MultiRepoSetup(std::shared_ptr<Configuration> const& config, common_args.remote_serve_address, auth_args); - ApiBundle const apis{std::nullopt, RemoteExecutionConfig::RemoteAddress()}; + ApiBundle const apis{nullptr, RemoteExecutionConfig::RemoteAddress()}; bool const has_remote_api = apis.local != apis.remote and not common_args.compatible; |