diff options
author | Maksim Denisov <denisov.maksim@huawei.com> | 2024-12-16 17:58:52 +0100 |
---|---|---|
committer | Maksim Denisov <denisov.maksim@huawei.com> | 2024-12-19 16:37:59 +0100 |
commit | d4955ca35cf160d32a68d262904cf2806e3a5910 (patch) | |
tree | 2dc80923416d45ab744bfee3539a99cd66e5e4a4 | |
parent | 2659b4f8df73a9c91215cccb01a323ae7bdc818a (diff) | |
download | justbuild-d4955ca35cf160d32a68d262904cf2806e3a5910.tar.gz |
Support PrecomputedRoots in FileRoot
-rw-r--r-- | src/buildtool/file_system/TARGETS | 1 | ||||
-rw-r--r-- | src/buildtool/file_system/file_root.hpp | 22 |
2 files changed, 21 insertions, 2 deletions
diff --git a/src/buildtool/file_system/TARGETS b/src/buildtool/file_system/TARGETS index 3f604393..ffd6af53 100644 --- a/src/buildtool/file_system/TARGETS +++ b/src/buildtool/file_system/TARGETS @@ -180,6 +180,7 @@ , "git_cas" , "git_tree" , "object_type" + , "precomputed_root" , ["@", "fmt", "", "fmt"] , ["@", "gsl", "", "gsl"] , ["@", "json", "", "json"] 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<fs_root_t, RootGit, absent_root_t, ComputedRoot>; + using root_t = std::variant<fs_root_t, + RootGit, + absent_root_t, + ComputedRoot, + PrecomputedRoot>; 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<PrecomputedRoot>(root_); + } + + [[nodiscard]] auto GetPrecomputedDescription() const noexcept + -> std::optional<PrecomputedRoot> { + if (auto const* precomputed = std::get_if<PrecomputedRoot>(&root_)) { + return *precomputed; + } + return std::nullopt; + } + [[nodiscard]] auto IsComputed() const noexcept -> bool { return std::holds_alternative<ComputedRoot>(root_); } |