summaryrefslogtreecommitdiff
path: root/src/buildtool/execution_api/remote/bazel/bazel_api.hpp
diff options
context:
space:
mode:
authorKlaus Aehlig <klaus.aehlig@huawei.com>2022-02-22 17:03:21 +0100
committerKlaus Aehlig <klaus.aehlig@huawei.com>2022-02-22 17:03:21 +0100
commit619def44c1cca9f3cdf63544d5f24f2c7a7d9b77 (patch)
tree01868de723cb82c86842f33743fa7b14e24c1fa3 /src/buildtool/execution_api/remote/bazel/bazel_api.hpp
downloadjustbuild-619def44c1cca9f3cdf63544d5f24f2c7a7d9b77.tar.gz
Initial self-hosting commit
This is the initial version of our tool that is able to build itself. In can be bootstrapped by ./bin/bootstrap.py Co-authored-by: Oliver Reiche <oliver.reiche@huawei.com> Co-authored-by: Victor Moreno <victor.moreno1@huawei.com>
Diffstat (limited to 'src/buildtool/execution_api/remote/bazel/bazel_api.hpp')
-rw-r--r--src/buildtool/execution_api/remote/bazel/bazel_api.hpp65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/buildtool/execution_api/remote/bazel/bazel_api.hpp b/src/buildtool/execution_api/remote/bazel/bazel_api.hpp
new file mode 100644
index 00000000..1405737b
--- /dev/null
+++ b/src/buildtool/execution_api/remote/bazel/bazel_api.hpp
@@ -0,0 +1,65 @@
+#ifndef INCLUDED_SRC_BUILDTOOL_EXECUTION_API_REMOTE_BAZEL_BAZEL_API_HPP
+#define INCLUDED_SRC_BUILDTOOL_EXECUTION_API_REMOTE_BAZEL_BAZEL_API_HPP
+
+#include <memory>
+#include <string>
+#include <utility>
+#include <vector>
+
+#include "gsl-lite/gsl-lite.hpp"
+#include "src/buildtool/common/artifact_digest.hpp"
+#include "src/buildtool/execution_api/bazel_msg/bazel_common.hpp"
+#include "src/buildtool/execution_api/common/execution_api.hpp"
+#include "src/buildtool/execution_api/common/local_tree_map.hpp"
+
+// forward declaration for actual implementations
+class BazelNetwork;
+struct ExecutionConfiguration;
+
+/// \brief Bazel implementation of the abstract Execution API.
+class BazelApi final : public IExecutionApi {
+ public:
+ BazelApi(std::string const& instance_name,
+ std::string const& host,
+ Port port,
+ ExecutionConfiguration const& exec_config) noexcept;
+ BazelApi(BazelApi const&) = delete;
+ BazelApi(BazelApi&& other) noexcept;
+ auto operator=(BazelApi const&) -> BazelApi& = delete;
+ auto operator=(BazelApi &&) -> BazelApi& = delete;
+ ~BazelApi() final;
+
+ auto CreateAction(
+ ArtifactDigest const& root_digest,
+ std::vector<std::string> const& command,
+ std::vector<std::string> const& output_files,
+ std::vector<std::string> const& output_dirs,
+ std::map<std::string, std::string> const& env_vars,
+ std::map<std::string, std::string> const& properties) noexcept
+ -> IExecutionAction::Ptr final;
+
+ [[nodiscard]] auto RetrieveToPaths(
+ std::vector<Artifact::ObjectInfo> const& artifacts_info,
+ std::vector<std::filesystem::path> const& output_paths) noexcept
+ -> bool final;
+
+ [[nodiscard]] auto RetrieveToFds(
+ std::vector<Artifact::ObjectInfo> const& artifacts_info,
+ std::vector<int> const& fds) noexcept -> bool final;
+
+ [[nodiscard]] auto Upload(BlobContainer const& blobs,
+ bool skip_find_missing) noexcept -> bool final;
+
+ [[nodiscard]] auto UploadTree(
+ std::vector<DependencyGraph::NamedArtifactNodePtr> const&
+ artifacts) noexcept -> std::optional<ArtifactDigest> final;
+
+ [[nodiscard]] auto IsAvailable(ArtifactDigest const& digest) const noexcept
+ -> bool final;
+
+ private:
+ std::shared_ptr<BazelNetwork> network_;
+ std::shared_ptr<LocalTreeMap> tree_map_;
+};
+
+#endif // INCLUDED_SRC_BUILDTOOL_EXECUTION_API_REMOTE_BAZEL_BAZEL_API_HPP