From d4955ca35cf160d32a68d262904cf2806e3a5910 Mon Sep 17 00:00:00 2001 From: Maksim Denisov Date: Mon, 16 Dec 2024 17:58:52 +0100 Subject: Support PrecomputedRoots in FileRoot --- src/buildtool/file_system/file_root.hpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'src/buildtool/file_system/file_root.hpp') diff --git a/src/buildtool/file_system/file_root.hpp b/src/buildtool/file_system/file_root.hpp index 4e65e7fe..ce92ab1e 100644 --- a/src/buildtool/file_system/file_root.hpp +++ b/src/buildtool/file_system/file_root.hpp @@ -42,6 +42,7 @@ #include "src/buildtool/file_system/git_cas.hpp" #include "src/buildtool/file_system/git_tree.hpp" #include "src/buildtool/file_system/object_type.hpp" +#include "src/buildtool/file_system/precomputed_root.hpp" #include "src/buildtool/logging/log_level.hpp" #include "src/buildtool/logging/logger.hpp" #include "src/utils/cpp/concepts.hpp" @@ -154,8 +155,11 @@ class FileRoot { private: // absent roots are defined by a tree hash with no witnessing repository using absent_root_t = std::string; - using root_t = - std::variant; + using root_t = std::variant; public: static constexpr auto kGitTreeMarker = "git tree"; @@ -387,6 +391,8 @@ class FileRoot { std::move(target_module), std::move(target_name), std::move(config)}} {} + explicit FileRoot(PrecomputedRoot precomputed) + : root_{std::move(precomputed)} {} [[nodiscard]] static auto FromGit(std::filesystem::path const& repo_path, std::string const& git_tree_id, @@ -687,6 +693,18 @@ class FileRoot { return std::nullopt; } + [[nodiscard]] auto IsPrecomputed() const noexcept -> bool { + return std::holds_alternative(root_); + } + + [[nodiscard]] auto GetPrecomputedDescription() const noexcept + -> std::optional { + if (auto const* precomputed = std::get_if(&root_)) { + return *precomputed; + } + return std::nullopt; + } + [[nodiscard]] auto IsComputed() const noexcept -> bool { return std::holds_alternative(root_); } -- cgit v1.2.3