summaryrefslogtreecommitdiff
path: root/src/buildtool/execution_api/remote/bazel/bazel_action.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_action.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_action.hpp')
-rw-r--r--src/buildtool/execution_api/remote/bazel/bazel_action.hpp54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/buildtool/execution_api/remote/bazel/bazel_action.hpp b/src/buildtool/execution_api/remote/bazel/bazel_action.hpp
new file mode 100644
index 00000000..7eb9a9e0
--- /dev/null
+++ b/src/buildtool/execution_api/remote/bazel/bazel_action.hpp
@@ -0,0 +1,54 @@
+#ifndef INCLUDED_SRC_BUILDTOOL_EXECUTION_API_REMOTE_BAZEL_BAZEL_ACTION_HPP
+#define INCLUDED_SRC_BUILDTOOL_EXECUTION_API_REMOTE_BAZEL_BAZEL_ACTION_HPP
+
+#include <map>
+#include <memory>
+#include <string>
+#include <vector>
+
+#include "src/buildtool/common/bazel_types.hpp"
+#include "src/buildtool/execution_api/remote/bazel/bazel_network.hpp"
+
+class BazelApi;
+
+/// \brief Bazel implementation of the abstract Execution Action.
+/// Uploads all dependencies, creates a Bazel Action and executes it.
+class BazelAction final : public IExecutionAction {
+ friend class BazelApi;
+
+ public:
+ auto Execute(Logger const* logger) noexcept
+ -> IExecutionResponse::Ptr final;
+ void SetCacheFlag(CacheFlag flag) noexcept final { cache_flag_ = flag; }
+ void SetTimeout(std::chrono::milliseconds timeout) noexcept final {
+ timeout_ = timeout;
+ }
+
+ private:
+ std::shared_ptr<BazelNetwork> network_;
+ std::shared_ptr<LocalTreeMap> tree_map_;
+ bazel_re::Digest const root_digest_;
+ std::vector<std::string> const cmdline_;
+ std::vector<std::string> output_files_;
+ std::vector<std::string> output_dirs_;
+ std::vector<bazel_re::Command_EnvironmentVariable> env_vars_;
+ std::vector<bazel_re::Platform_Property> properties_;
+ CacheFlag cache_flag_{CacheFlag::CacheOutput};
+ std::chrono::milliseconds timeout_{kDefaultTimeout};
+
+ BazelAction(std::shared_ptr<BazelNetwork> network,
+ std::shared_ptr<LocalTreeMap> tree_map,
+ bazel_re::Digest root_digest,
+ std::vector<std::string> command,
+ std::vector<std::string> output_files,
+ std::vector<std::string> output_dirs,
+ std::map<std::string, std::string> const& env_vars,
+ std::map<std::string, std::string> const& properties) noexcept;
+
+ [[nodiscard]] auto CreateBundlesForAction(BlobContainer* blobs,
+ bazel_re::Digest const& exec_dir,
+ bool do_not_cache) const noexcept
+ -> bazel_re::Digest;
+};
+
+#endif // INCLUDED_SRC_BUILDTOOL_EXECUTION_API_REMOTE_BAZEL_BAZEL_ACTION_HPP