diff options
Diffstat (limited to 'src/buildtool/execution_api/common')
-rw-r--r-- | src/buildtool/execution_api/common/common_api.cpp | 27 | ||||
-rw-r--r-- | src/buildtool/execution_api/common/common_api.hpp | 14 | ||||
-rw-r--r-- | src/buildtool/execution_api/common/execution_api.hpp | 6 |
3 files changed, 23 insertions, 24 deletions
diff --git a/src/buildtool/execution_api/common/common_api.cpp b/src/buildtool/execution_api/common/common_api.cpp index ce124a67..74e52c19 100644 --- a/src/buildtool/execution_api/common/common_api.cpp +++ b/src/buildtool/execution_api/common/common_api.cpp @@ -82,9 +82,8 @@ auto CommonRetrieveToFds( } /// NOLINTNEXTLINE(misc-no-recursion) -auto CommonUploadBlobTree( - BlobTreePtr const& blob_tree, - gsl::not_null<const IExecutionApi*> const& api) noexcept -> bool { +auto CommonUploadBlobTree(BlobTreePtr const& blob_tree, + IExecutionApi const& api) noexcept -> bool { // Create digest list from blobs for batch availability check. auto missing_blobs_info = GetMissingArtifactsInfo<BlobTreePtr>( api, blob_tree->begin(), blob_tree->end(), [](BlobTreePtr const& node) { @@ -115,19 +114,19 @@ auto CommonUploadBlobTree( std::move(node->Blob()), /*exception_is_fatal=*/false, [&api](ArtifactBlobContainer&& blobs) -> bool { - return api->Upload(std::move(blobs), - /*skip_find_missing=*/true); + return api.Upload(std::move(blobs), + /*skip_find_missing=*/true); })) { return false; } } } // Transfer any remaining blobs. - return api->Upload(std::move(container), /*skip_find_missing=*/true); + return api.Upload(std::move(container), /*skip_find_missing=*/true); } auto CommonUploadTreeCompatible( - gsl::not_null<const IExecutionApi*> const& api, + IExecutionApi const& api, DirectoryTreePtr const& build_root, BazelMsgFactory::LinkDigestResolveFunc const& resolve_links) noexcept -> std::optional<ArtifactDigest> { @@ -141,8 +140,8 @@ auto CommonUploadTreeCompatible( ArtifactDigest{blob.digest}, blob.data, blob.is_exec}), /*exception_is_fatal=*/false, [&api](ArtifactBlobContainer&& container) -> bool { - return api->Upload(std::move(container), - /*skip_find_missing=*/false); + return api.Upload(std::move(container), + /*skip_find_missing=*/false); }); }); if (not digest) { @@ -156,14 +155,14 @@ auto CommonUploadTreeCompatible( return oss.str(); }); // Upload remaining blobs. - if (not api->Upload(std::move(blobs), /*skip_find_missing=*/false)) { + if (not api.Upload(std::move(blobs), /*skip_find_missing=*/false)) { Logger::Log(LogLevel::Debug, "failed to upload blobs for build root."); return std::nullopt; } return ArtifactDigest{*digest}; } -auto CommonUploadTreeNative(gsl::not_null<const IExecutionApi*> const& api, +auto CommonUploadTreeNative(IExecutionApi const& api, DirectoryTreePtr const& build_root) noexcept -> std::optional<ArtifactDigest> { auto blob_tree = BlobTree::FromDirectoryTree(build_root); @@ -175,14 +174,14 @@ auto CommonUploadTreeNative(gsl::not_null<const IExecutionApi*> const& api, auto tree_blob = (*blob_tree)->Blob(); // Upload blob tree if tree is not available at the remote side (content // first). - if (not api->IsAvailable(tree_blob.digest)) { + if (not api.IsAvailable(tree_blob.digest)) { if (not CommonUploadBlobTree(*blob_tree, api)) { Logger::Log(LogLevel::Debug, "failed to upload blob tree for build root."); return std::nullopt; } - if (not api->Upload(ArtifactBlobContainer{{tree_blob}}, - /*skip_find_missing=*/true)) { + if (not api.Upload(ArtifactBlobContainer{{tree_blob}}, + /*skip_find_missing=*/true)) { Logger::Log(LogLevel::Debug, "failed to upload tree blob for build root."); return std::nullopt; diff --git a/src/buildtool/execution_api/common/common_api.hpp b/src/buildtool/execution_api/common/common_api.hpp index e35be206..c11180da 100644 --- a/src/buildtool/execution_api/common/common_api.hpp +++ b/src/buildtool/execution_api/common/common_api.hpp @@ -61,7 +61,7 @@ struct MissingArtifactsInfo { /// original given type, or nullopt in case of exceptions. template <typename T> [[nodiscard]] auto GetMissingArtifactsInfo( - gsl::not_null<const IExecutionApi*> const& api, + IExecutionApi const& api, typename std::vector<T>::const_iterator const& begin, typename std::vector<T>::const_iterator const& end, typename std::function<ArtifactDigest(T const&)> const& converter) noexcept @@ -78,25 +78,25 @@ template <typename T> return std::nullopt; } } - res.digests = api->IsAvailable(digests); + res.digests = api.IsAvailable(digests); return res; } /// \brief Upload missing blobs from a given BlobTree. -[[nodiscard]] auto CommonUploadBlobTree( - BlobTreePtr const& blob_tree, - gsl::not_null<const IExecutionApi*> const& api) noexcept -> bool; +[[nodiscard]] auto CommonUploadBlobTree(BlobTreePtr const& blob_tree, + IExecutionApi const& api) noexcept + -> bool; /// \brief Runs the compatible branch of local/bazel UploadTree API. [[nodiscard]] auto CommonUploadTreeCompatible( - gsl::not_null<const IExecutionApi*> const& api, + IExecutionApi const& api, DirectoryTreePtr const& build_root, BazelMsgFactory::LinkDigestResolveFunc const& resolve_links) noexcept -> std::optional<ArtifactDigest>; /// \brief Runs the native branch of local/bazel UploadTree API. [[nodiscard]] auto CommonUploadTreeNative( - gsl::not_null<const IExecutionApi*> const& api, + IExecutionApi const& api, DirectoryTreePtr const& build_root) noexcept -> std::optional<ArtifactDigest>; diff --git a/src/buildtool/execution_api/common/execution_api.hpp b/src/buildtool/execution_api/common/execution_api.hpp index 1a8ee578..5b6743e3 100644 --- a/src/buildtool/execution_api/common/execution_api.hpp +++ b/src/buildtool/execution_api/common/execution_api.hpp @@ -70,7 +70,7 @@ class IExecutionApi { [[nodiscard]] virtual auto RetrieveToPaths( std::vector<Artifact::ObjectInfo> const& artifacts_info, std::vector<std::filesystem::path> const& output_paths, - std::optional<gsl::not_null<IExecutionApi*>> const& alternative = + std::optional<gsl::not_null<const IExecutionApi*>> const& alternative = std::nullopt) const noexcept -> bool = 0; /// \brief Retrieve artifacts from CAS and write to file descriptors. @@ -88,7 +88,7 @@ class IExecutionApi { /// resolved and its containing file artifacts are recursively retrieved. [[nodiscard]] virtual auto RetrieveToCas( std::vector<Artifact::ObjectInfo> const& artifacts_info, - gsl::not_null<IExecutionApi*> const& api) const noexcept -> bool = 0; + IExecutionApi const& api) const noexcept -> bool = 0; /// \brief A variant of RetrieveToCas that is allowed to internally use /// the specified number of threads to carry out the task in parallel. @@ -98,7 +98,7 @@ class IExecutionApi { /// the remote blobs. [[nodiscard]] virtual auto ParallelRetrieveToCas( std::vector<Artifact::ObjectInfo> const& artifacts_info, - gsl::not_null<IExecutionApi*> const& api, + IExecutionApi const& api, std::size_t /* jobs */, bool /* use_blob_splitting */) const noexcept -> bool { return RetrieveToCas(artifacts_info, api); |