summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/buildtool/main/TARGETS16
-rw-r--r--src/buildtool/main/add_to_cas.cpp7
-rw-r--r--src/buildtool/main/add_to_cas.hpp8
-rw-r--r--src/buildtool/main/build_utils.cpp30
-rw-r--r--src/buildtool/main/build_utils.hpp8
-rw-r--r--src/buildtool/main/install_cas.cpp21
-rw-r--r--src/buildtool/main/install_cas.hpp9
-rw-r--r--src/buildtool/main/main.cpp8
-rw-r--r--src/buildtool/serve_api/serve_service/target.cpp3
9 files changed, 44 insertions, 66 deletions
diff --git a/src/buildtool/main/TARGETS b/src/buildtool/main/TARGETS
index 39a97664..66388afa 100644
--- a/src/buildtool/main/TARGETS
+++ b/src/buildtool/main/TARGETS
@@ -120,7 +120,7 @@
, "deps":
[ ["src/buildtool/common", "cli"]
, ["src/buildtool/common", "common"]
- , ["src/buildtool/execution_api/common", "common"]
+ , ["src/buildtool/execution_api/common", "api_bundle"]
, ["@", "gsl", "", "gsl"]
]
, "stage": ["src", "buildtool", "main"]
@@ -131,6 +131,7 @@
, ["src/buildtool/logging", "log_level"]
, ["src/buildtool/logging", "logging"]
, ["src/buildtool/execution_api/utils", "subobject"]
+ , ["src/buildtool/execution_api/common", "common"]
, "archive"
]
}
@@ -140,14 +141,13 @@
, "hdrs": ["add_to_cas.hpp"]
, "srcs": ["add_to_cas.cpp"]
, "deps":
- [ ["@", "gsl", "", "gsl"]
- , ["src/buildtool/common", "cli"]
- , ["src/buildtool/execution_api/common", "common"]
+ [ ["src/buildtool/common", "cli"]
+ , ["src/buildtool/execution_api/common", "api_bundle"]
]
, "private-deps":
[ ["src/buildtool/compatibility", "compatibility"]
, ["src/buildtool/execution_api/bazel_msg", "bazel_msg_factory"]
- , ["src/buildtool/execution_api/local", "local"]
+ , ["src/buildtool/execution_api/common", "common"]
, ["src/buildtool/file_system", "file_system_manager"]
, ["src/buildtool/logging", "log_level"]
, ["src/buildtool/logging", "logging"]
@@ -295,12 +295,11 @@
, "hdrs": ["build_utils.hpp"]
, "srcs": ["build_utils.cpp"]
, "deps":
- [ ["@", "gsl", "", "gsl"]
- , ["src/buildtool/build_engine/analysed_target", "target"]
+ [ ["src/buildtool/build_engine/analysed_target", "target"]
, ["src/buildtool/common", "artifact_description"]
, ["src/buildtool/common", "common"]
, ["src/buildtool/common", "config"]
- , ["src/buildtool/execution_api/common", "common"]
+ , ["src/buildtool/execution_api/common", "api_bundle"]
, ["src/buildtool/logging", "logging"]
, ["src/buildtool/multithreading", "async_map_consumer"]
, ["src/buildtool/storage", "storage"]
@@ -308,6 +307,7 @@
, "stage": ["src", "buildtool", "main"]
, "private-deps":
[ ["src/buildtool/multithreading", "async_map_utils"]
+ , ["src/buildtool/execution_api/common", "common"]
, ["src/buildtool/logging", "log_level"]
]
}
diff --git a/src/buildtool/main/add_to_cas.cpp b/src/buildtool/main/add_to_cas.cpp
index 711a31bf..984c2007 100644
--- a/src/buildtool/main/add_to_cas.cpp
+++ b/src/buildtool/main/add_to_cas.cpp
@@ -23,14 +23,13 @@
#include "src/buildtool/compatibility/native_support.hpp"
#include "src/buildtool/execution_api/bazel_msg/bazel_msg_factory.hpp"
-#include "src/buildtool/execution_api/local/local_api.hpp"
+#include "src/buildtool/execution_api/common/execution_api.hpp"
#include "src/buildtool/file_system/file_system_manager.hpp"
#include "src/buildtool/logging/log_level.hpp"
#include "src/buildtool/logging/logger.hpp"
#include "src/buildtool/storage/storage.hpp"
-auto AddArtifactsToCas(ToAddArguments const& clargs,
- gsl::not_null<IExecutionApi*> const& remote_api)
+auto AddArtifactsToCas(ToAddArguments const& clargs, ApiBundle const& apis)
-> bool {
auto const& cas = Storage::Instance().CAS();
@@ -108,7 +107,7 @@ auto AddArtifactsToCas(ToAddArguments const& clargs,
auto object = std::vector<Artifact::ObjectInfo>{
Artifact::ObjectInfo{ArtifactDigest(*digest), *object_type, false}};
- if (not LocalApi().RetrieveToCas(object, remote_api)) {
+ if (not apis.local->RetrieveToCas(object, &*apis.remote)) {
Logger::Log(LogLevel::Error,
"Failed to upload artifact to remote endpoint");
return false;
diff --git a/src/buildtool/main/add_to_cas.hpp b/src/buildtool/main/add_to_cas.hpp
index 3a2cafce..6dd20236 100644
--- a/src/buildtool/main/add_to_cas.hpp
+++ b/src/buildtool/main/add_to_cas.hpp
@@ -16,13 +16,11 @@
#define INCLUDED_SRC_BUILDTOOL_MAIN_ADD_TO_CAS_HPP
#ifndef BOOTSTRAP_BUILD_TOOL
-#include "gsl/gsl"
#include "src/buildtool/common/cli.hpp"
-#include "src/buildtool/execution_api/common/execution_api.hpp"
+#include "src/buildtool/execution_api/common/api_bundle.hpp"
-[[nodiscard]] auto AddArtifactsToCas(
- ToAddArguments const& clargs,
- gsl::not_null<IExecutionApi*> const& remote_api) -> bool;
+[[nodiscard]] auto AddArtifactsToCas(ToAddArguments const& clargs,
+ ApiBundle const& apis) -> bool;
#endif
#endif
diff --git a/src/buildtool/main/build_utils.cpp b/src/buildtool/main/build_utils.cpp
index fb60ea15..2f7549b7 100644
--- a/src/buildtool/main/build_utils.cpp
+++ b/src/buildtool/main/build_utils.cpp
@@ -68,12 +68,11 @@ auto CreateTargetCacheWriterMap(
std::unordered_map<ArtifactDescription, Artifact::ObjectInfo> const&
extra_infos,
std::size_t jobs,
- gsl::not_null<IExecutionApi*> const& local_api,
- gsl::not_null<IExecutionApi*> const& remote_api,
+ gsl::not_null<ApiBundle const*> const& apis,
TargetCacheWriteStrategy strategy,
TargetCache<true> const& tc) -> TargetCacheWriterMap {
auto write_tc_entry =
- [cache_targets, extra_infos, jobs, local_api, remote_api, strategy, tc](
+ [cache_targets, extra_infos, jobs, apis, strategy, tc](
auto /*ts*/,
auto setter,
auto logger,
@@ -107,23 +106,13 @@ auto CreateTargetCacheWriterMap(
if (auto implied_targets = entry->ToImpliedIds(key.digest.hash())) {
(*subcaller)(
*implied_targets,
- [tc_key,
- entry,
- jobs,
- local_api,
- remote_api,
- strategy,
- tc,
- setter,
- logger]([[maybe_unused]] auto const& values) {
+ [tc_key, entry, jobs, apis, strategy, tc, setter, logger](
+ [[maybe_unused]] auto const& values) {
// create parallel artifacts downloader
- auto downloader = [&local_api,
- &remote_api,
- &jobs,
- strategy](auto infos) {
- return remote_api->ParallelRetrieveToCas(
+ auto downloader = [apis, &jobs, strategy](auto infos) {
+ return apis->remote->ParallelRetrieveToCas(
infos,
- local_api,
+ &*apis->local,
jobs,
strategy == TargetCacheWriteStrategy::Split);
};
@@ -155,8 +144,7 @@ void WriteTargetCacheEntries(
std::unordered_map<ArtifactDescription, Artifact::ObjectInfo> const&
extra_infos,
std::size_t jobs,
- gsl::not_null<IExecutionApi*> const& local_api,
- gsl::not_null<IExecutionApi*> const& remote_api,
+ ApiBundle const& apis,
TargetCacheWriteStrategy strategy,
TargetCache<true> const& tc,
Logger const* logger,
@@ -172,7 +160,7 @@ void WriteTargetCacheEntries(
}
// set up writer map
auto tc_writer_map = CreateTargetCacheWriterMap(
- cache_targets, extra_infos, jobs, local_api, remote_api, strategy, tc);
+ cache_targets, extra_infos, jobs, &apis, strategy, tc);
std::vector<Artifact::ObjectInfo> cache_targets_ids;
cache_targets_ids.reserve(cache_targets.size());
for (auto const& [k, _] : cache_targets) {
diff --git a/src/buildtool/main/build_utils.hpp b/src/buildtool/main/build_utils.hpp
index af99d6a0..961b5c09 100644
--- a/src/buildtool/main/build_utils.hpp
+++ b/src/buildtool/main/build_utils.hpp
@@ -27,9 +27,9 @@
#include "src/buildtool/common/repository_config.hpp"
#include "src/buildtool/storage/target_cache_key.hpp"
#ifndef BOOTSTRAP_BUILD_TOOL
-#include "gsl/gsl"
#include "src/buildtool/common/artifact.hpp"
#include "src/buildtool/common/artifact_digest.hpp"
+#include "src/buildtool/execution_api/common/api_bundle.hpp"
#include "src/buildtool/execution_api/common/execution_api.hpp"
#include "src/buildtool/logging/log_level.hpp"
#include "src/buildtool/logging/logger.hpp"
@@ -70,8 +70,7 @@ using TargetCacheWriterMap =
std::unordered_map<ArtifactDescription, Artifact::ObjectInfo> const&
extra_infos,
std::size_t jobs,
- gsl::not_null<IExecutionApi*> const& local_api,
- gsl::not_null<IExecutionApi*> const& remote_api,
+ gsl::not_null<ApiBundle const*> const& apis,
TargetCacheWriteStrategy strategy = TargetCacheWriteStrategy::Sync,
TargetCache<true> const& tc = Storage::Instance().TargetCache())
-> TargetCacheWriterMap;
@@ -89,8 +88,7 @@ void WriteTargetCacheEntries(
std::unordered_map<ArtifactDescription, Artifact::ObjectInfo> const&
extra_infos,
std::size_t jobs,
- gsl::not_null<IExecutionApi*> const& local_api,
- gsl::not_null<IExecutionApi*> const& remote_api,
+ ApiBundle const& apis,
TargetCacheWriteStrategy strategy = TargetCacheWriteStrategy::Sync,
TargetCache<true> const& tc = Storage::Instance().TargetCache(),
Logger const* logger = nullptr,
diff --git a/src/buildtool/main/install_cas.cpp b/src/buildtool/main/install_cas.cpp
index e5c2a2a0..5c213925 100644
--- a/src/buildtool/main/install_cas.cpp
+++ b/src/buildtool/main/install_cas.cpp
@@ -22,6 +22,7 @@
#include "src/buildtool/logging/log_level.hpp"
#include "src/buildtool/logging/logger.hpp"
#ifndef BOOTSTRAP_BUILD_TOOL
+#include "src/buildtool/execution_api/common/execution_api.hpp"
#include "src/buildtool/execution_api/utils/subobject.hpp"
#include "src/buildtool/main/archive.hpp"
#endif
@@ -70,15 +71,13 @@ namespace {
}
#ifndef BOOTSTRAP_BUILD_TOOL
-auto FetchAndInstallArtifacts(
- gsl::not_null<IExecutionApi*> const& api,
- gsl::not_null<IExecutionApi*> const& alternative_api,
- FetchArguments const& clargs) -> bool {
+auto FetchAndInstallArtifacts(ApiBundle const& apis,
+ FetchArguments const& clargs) -> bool {
auto object_info = ObjectInfoFromLiberalString(clargs.object_id);
if (clargs.remember) {
- if (not api->ParallelRetrieveToCas(
- {object_info}, alternative_api, 1, true)) {
+ if (not apis.remote->ParallelRetrieveToCas(
+ {object_info}, &*apis.local, 1, true)) {
Logger::Log(LogLevel::Warning,
"Failed to copy artifact {} to local CAS",
object_info.ToString());
@@ -88,7 +87,7 @@ auto FetchAndInstallArtifacts(
if (clargs.sub_path) {
std::filesystem::path sofar{};
auto new_object_info =
- RetrieveSubPathId(object_info, api, *clargs.sub_path);
+ RetrieveSubPathId(object_info, &*apis.remote, *clargs.sub_path);
if (new_object_info) {
object_info = *new_object_info;
}
@@ -121,12 +120,12 @@ auto FetchAndInstallArtifacts(
object_info.ToString());
return false;
}
- return GenerateArchive(api, object_info, out);
+ return GenerateArchive(&*apis.remote, object_info, out);
}
if (out) {
- if (not api->RetrieveToPaths(
- {object_info}, {*out}, &(*alternative_api))) {
+ if (not apis.remote->RetrieveToPaths(
+ {object_info}, {*out}, &*apis.local)) {
Logger::Log(LogLevel::Error, "failed to retrieve artifact.");
return false;
}
@@ -137,7 +136,7 @@ auto FetchAndInstallArtifacts(
out->string());
}
else { // dump to stdout
- if (not api->RetrieveToFds(
+ if (not apis.remote->RetrieveToFds(
{object_info}, {dup(fileno(stdout))}, clargs.raw_tree)) {
Logger::Log(LogLevel::Error, "failed to dump artifact.");
return false;
diff --git a/src/buildtool/main/install_cas.hpp b/src/buildtool/main/install_cas.hpp
index fe2742b7..3bfdde86 100644
--- a/src/buildtool/main/install_cas.hpp
+++ b/src/buildtool/main/install_cas.hpp
@@ -21,17 +21,16 @@
#include "src/buildtool/common/artifact.hpp"
#include "src/buildtool/common/cli.hpp"
#ifndef BOOTSTRAP_BUILD_TOOL
-#include "src/buildtool/execution_api/common/execution_api.hpp"
+#include "src/buildtool/execution_api/common/api_bundle.hpp"
#endif
[[nodiscard]] auto ObjectInfoFromLiberalString(std::string const& s) noexcept
-> Artifact::ObjectInfo;
#ifndef BOOTSTRAP_BUILD_TOOL
-[[nodiscard]] auto FetchAndInstallArtifacts(
- gsl::not_null<IExecutionApi*> const& api,
- gsl::not_null<IExecutionApi*> const& alternative_api,
- FetchArguments const& clargs) -> bool;
+[[nodiscard]] auto FetchAndInstallArtifacts(ApiBundle const& apis,
+ FetchArguments const& clargs)
+ -> bool;
#endif
#endif // INCLUDED_SRC_BUILDTOOL_MAIN_INSTALL_CAS_HPP
diff --git a/src/buildtool/main/main.cpp b/src/buildtool/main/main.cpp
index 6f9c68ad..294405e3 100644
--- a/src/buildtool/main/main.cpp
+++ b/src/buildtool/main/main.cpp
@@ -912,13 +912,12 @@ auto main(int argc, char* argv[]) -> int {
"Failed set Git CAS {}.",
StorageConfig::GitRoot().string());
}
- return FetchAndInstallArtifacts(
- &*main_apis.remote, &*main_apis.local, arguments.fetch)
+ return FetchAndInstallArtifacts(main_apis, arguments.fetch)
? kExitSuccess
: kExitFailure;
}
if (arguments.cmd == SubCommand::kAddToCas) {
- return AddArtifactsToCas(arguments.to_add, &*main_apis.remote)
+ return AddArtifactsToCas(arguments.to_add, main_apis)
? kExitSuccess
: kExitFailure;
}
@@ -1105,8 +1104,7 @@ auto main(int argc, char* argv[]) -> int {
cache_targets,
build_result->extra_infos,
jobs,
- &*main_apis.local,
- &*main_apis.remote,
+ main_apis,
arguments.tc.target_cache_write_strategy,
Storage::Instance().TargetCache(),
nullptr,
diff --git a/src/buildtool/serve_api/serve_service/target.cpp b/src/buildtool/serve_api/serve_service/target.cpp
index bd88804f..dda3a975 100644
--- a/src/buildtool/serve_api/serve_service/target.cpp
+++ b/src/buildtool/serve_api/serve_service/target.cpp
@@ -536,8 +536,7 @@ auto TargetService::ServeTarget(
WriteTargetCacheEntries(cache_targets,
build_result->extra_infos,
jobs,
- &*local_apis.local,
- &*local_apis.remote,
+ local_apis,
serve_config_.tc_strategy,
tc,
&logger,