From 619def44c1cca9f3cdf63544d5f24f2c7a7d9b77 Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Tue, 22 Feb 2022 17:03:21 +0100 Subject: 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 Co-authored-by: Victor Moreno --- .../execution_api/bazel_msg/bazel_blob.hpp | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/buildtool/execution_api/bazel_msg/bazel_blob.hpp (limited to 'src/buildtool/execution_api/bazel_msg/bazel_blob.hpp') diff --git a/src/buildtool/execution_api/bazel_msg/bazel_blob.hpp b/src/buildtool/execution_api/bazel_msg/bazel_blob.hpp new file mode 100644 index 00000000..115c4018 --- /dev/null +++ b/src/buildtool/execution_api/bazel_msg/bazel_blob.hpp @@ -0,0 +1,31 @@ +#ifndef INCLUDED_SRC_BUILDTOOL_EXECUTION_API_BAZEL_MSG_BAZEL_BLOB_HPP +#define INCLUDED_SRC_BUILDTOOL_EXECUTION_API_BAZEL_MSG_BAZEL_BLOB_HPP + +#include +#include +#include +#include + +#include "src/buildtool/common/artifact_digest.hpp" +#include "src/buildtool/common/bazel_types.hpp" +#include "src/buildtool/file_system/file_system_manager.hpp" + +struct BazelBlob { + BazelBlob(bazel_re::Digest mydigest, std::string mydata) + : digest{std::move(mydigest)}, data{std::move(mydata)} {} + + bazel_re::Digest digest{}; + std::string data{}; +}; + +[[nodiscard]] static inline auto CreateBlobFromFile( + std::filesystem::path const& file_path) noexcept + -> std::optional { + auto const content = FileSystemManager::ReadFile(file_path); + if (not content.has_value()) { + return std::nullopt; + } + return BazelBlob{ArtifactDigest::Create(*content), *content}; +} + +#endif // INCLUDED_SRC_BUILDTOOL_EXECUTION_API_BAZEL_MSG_BAZEL_BLOB_HPP -- cgit v1.2.3