summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaksim Denisov <denisov.maksim@huawei.com>2025-02-21 12:52:19 +0100
committerMaksim Denisov <denisov.maksim@huawei.com>2025-03-24 09:25:05 +0100
commitfc0c842eb2e938c7de405e365ff320eb28e04bc7 (patch)
tree2fd4e62cec95b94b77643e89e8ff5a47e8ae7263 /src
parent82bfeff1389446f8743bd551f9833998eb7a1424 (diff)
downloadjustbuild-fc0c842eb2e938c7de405e365ff320eb28e04bc7.tar.gz
Pass TmpDir to BazelNetwork and BazelCasClient
Diffstat (limited to 'src')
-rw-r--r--src/buildtool/execution_api/remote/TARGETS1
-rw-r--r--src/buildtool/execution_api/remote/bazel/bazel_api.cpp3
-rw-r--r--src/buildtool/execution_api/remote/bazel/bazel_cas_client.cpp6
-rw-r--r--src/buildtool/execution_api/remote/bazel/bazel_cas_client.hpp10
-rw-r--r--src/buildtool/execution_api/remote/bazel/bazel_network.cpp6
-rw-r--r--src/buildtool/execution_api/remote/bazel/bazel_network.hpp8
6 files changed, 26 insertions, 8 deletions
diff --git a/src/buildtool/execution_api/remote/TARGETS b/src/buildtool/execution_api/remote/TARGETS
index e275dead..c6a8c4c4 100644
--- a/src/buildtool/execution_api/remote/TARGETS
+++ b/src/buildtool/execution_api/remote/TARGETS
@@ -38,6 +38,7 @@
, ["src/buildtool/logging", "logging"]
, ["src/utils/cpp", "expected"]
, ["src/utils/cpp", "incremental_reader"]
+ , ["src/utils/cpp", "tmp_dir"]
]
, "proto":
[ ["@", "bazel_remote_apis", "", "remote_execution_proto"]
diff --git a/src/buildtool/execution_api/remote/bazel/bazel_api.cpp b/src/buildtool/execution_api/remote/bazel/bazel_api.cpp
index eb140b3c..b2f145b0 100644
--- a/src/buildtool/execution_api/remote/bazel/bazel_api.cpp
+++ b/src/buildtool/execution_api/remote/bazel/bazel_api.cpp
@@ -151,7 +151,8 @@ BazelApi::BazelApi(std::string const& instance_name,
auth,
retry_config,
exec_config,
- hash_function);
+ hash_function,
+ /*temp_space=*/nullptr);
}
// implement move constructor in cpp, where all members are complete types
diff --git a/src/buildtool/execution_api/remote/bazel/bazel_cas_client.cpp b/src/buildtool/execution_api/remote/bazel/bazel_cas_client.cpp
index a02b8d4c..6f07d322 100644
--- a/src/buildtool/execution_api/remote/bazel/bazel_cas_client.cpp
+++ b/src/buildtool/execution_api/remote/bazel/bazel_cas_client.cpp
@@ -220,10 +220,12 @@ BazelCasClient::BazelCasClient(
Port port,
gsl::not_null<Auth const*> const& auth,
gsl::not_null<RetryConfig const*> const& retry_config,
- gsl::not_null<BazelCapabilitiesClient const*> const& capabilities) noexcept
+ gsl::not_null<BazelCapabilitiesClient const*> const& capabilities,
+ TmpDir::Ptr temp_space) noexcept
: stream_{std::make_unique<ByteStreamClient>(server, port, auth)},
retry_config_{*retry_config},
- capabilities_{*capabilities} {
+ capabilities_{*capabilities},
+ temp_space_{std::move(temp_space)} {
stub_ = bazel_re::ContentAddressableStorage::NewStub(
CreateChannelWithCredentials(server, port, auth));
}
diff --git a/src/buildtool/execution_api/remote/bazel/bazel_cas_client.hpp b/src/buildtool/execution_api/remote/bazel/bazel_cas_client.hpp
index 7275a352..3f83d712 100644
--- a/src/buildtool/execution_api/remote/bazel/bazel_cas_client.hpp
+++ b/src/buildtool/execution_api/remote/bazel/bazel_cas_client.hpp
@@ -39,6 +39,7 @@
#include "src/buildtool/execution_api/remote/bazel/bazel_capabilities_client.hpp"
#include "src/buildtool/execution_api/remote/bazel/bytestream_client.hpp"
#include "src/buildtool/logging/logger.hpp"
+#include "src/utils/cpp/tmp_dir.hpp"
/// Implements client side for serivce defined here:
/// https://github.com/bazelbuild/remote-apis/blob/e1fe21be4c9ae76269a5a63215bb3c72ed9ab3f0/build/bazel/remote/execution/v2/remote_execution.proto#L317
@@ -49,8 +50,8 @@ class BazelCasClient {
Port port,
gsl::not_null<Auth const*> const& auth,
gsl::not_null<RetryConfig const*> const& retry_config,
- gsl::not_null<BazelCapabilitiesClient const*> const&
- capabilities) noexcept;
+ gsl::not_null<BazelCapabilitiesClient const*> const& capabilities,
+ TmpDir::Ptr temp_space) noexcept;
/// \brief Find missing blobs
/// \param[in] instance_name Name of the CAS instance
@@ -146,10 +147,15 @@ class BazelCasClient {
[[nodiscard]] auto GetMaxBatchTransferSize(
std::string const& instance_name) const noexcept -> std::size_t;
+ [[nodiscard]] auto GetTempSpace() const noexcept -> TmpDir::Ptr {
+ return temp_space_;
+ }
+
private:
std::unique_ptr<ByteStreamClient> stream_;
RetryConfig const& retry_config_;
BazelCapabilitiesClient const& capabilities_;
+ TmpDir::Ptr temp_space_;
std::unique_ptr<bazel_re::ContentAddressableStorage::Stub> stub_;
Logger logger_{"RemoteCasClient"};
diff --git a/src/buildtool/execution_api/remote/bazel/bazel_network.cpp b/src/buildtool/execution_api/remote/bazel/bazel_network.cpp
index 1a8e6d8f..f8b31871 100644
--- a/src/buildtool/execution_api/remote/bazel/bazel_network.cpp
+++ b/src/buildtool/execution_api/remote/bazel/bazel_network.cpp
@@ -29,7 +29,8 @@ BazelNetwork::BazelNetwork(
gsl::not_null<Auth const*> const& auth,
gsl::not_null<RetryConfig const*> const& retry_config,
ExecutionConfiguration const& exec_config,
- HashFunction hash_function) noexcept
+ HashFunction hash_function,
+ TmpDir::Ptr temp_space) noexcept
: instance_name_{std::move(instance_name)},
capabilities_{std::make_unique<BazelCapabilitiesClient>(host,
port,
@@ -39,7 +40,8 @@ BazelNetwork::BazelNetwork(
port,
auth,
retry_config,
- capabilities_.get())},
+ capabilities_.get(),
+ std::move(temp_space))},
ac_{std::make_unique<BazelAcClient>(host, port, auth, retry_config)},
exec_{std::make_unique<BazelExecutionClient>(host,
port,
diff --git a/src/buildtool/execution_api/remote/bazel/bazel_network.hpp b/src/buildtool/execution_api/remote/bazel/bazel_network.hpp
index 3af4bccd..4dbf1467 100644
--- a/src/buildtool/execution_api/remote/bazel/bazel_network.hpp
+++ b/src/buildtool/execution_api/remote/bazel/bazel_network.hpp
@@ -35,6 +35,7 @@
#include "src/buildtool/execution_api/remote/bazel/bazel_cas_client.hpp"
#include "src/buildtool/execution_api/remote/bazel/bazel_execution_client.hpp"
#include "src/buildtool/execution_api/remote/bazel/bazel_network_reader.hpp"
+#include "src/utils/cpp/tmp_dir.hpp"
/// \brief Contains all network clients and is responsible for all network IO.
class BazelNetwork {
@@ -45,7 +46,8 @@ class BazelNetwork {
gsl::not_null<Auth const*> const& auth,
gsl::not_null<RetryConfig const*> const& retry_config,
ExecutionConfiguration const& exec_config,
- HashFunction hash_function) noexcept;
+ HashFunction hash_function,
+ TmpDir::Ptr temp_space) noexcept;
/// \brief Check if digest exists in CAS
/// \param[in] digest The digest to look up
@@ -86,6 +88,10 @@ class BazelNetwork {
return hash_function_;
}
+ [[nodiscard]] auto GetTempSpace() const noexcept -> TmpDir::Ptr {
+ return cas_->GetTempSpace();
+ }
+
[[nodiscard]] auto GetCachedActionResult(
bazel_re::Digest const& action,
std::vector<std::string> const& output_files) const noexcept