summaryrefslogtreecommitdiff
path: root/src/buildtool/file_system/precomputed_root.hpp
diff options
context:
space:
mode:
authorMaksim Denisov <denisov.maksim@huawei.com>2024-12-18 12:08:36 +0100
committerMaksim Denisov <denisov.maksim@huawei.com>2024-12-19 16:37:59 +0100
commit17d7bbde834a6575ece9c71bdf8ae91b69bc9204 (patch)
tree47fc2d60c9c5a38506aabfd317be2e5cbc3565ac /src/buildtool/file_system/precomputed_root.hpp
parent0000839adc5805997d5afdda924fb6f5e45e0a90 (diff)
downloadjustbuild-17d7bbde834a6575ece9c71bdf8ae91b69bc9204.tar.gz
Implement TreeStructureRoot
Diffstat (limited to 'src/buildtool/file_system/precomputed_root.hpp')
-rw-r--r--src/buildtool/file_system/precomputed_root.hpp32
1 files changed, 30 insertions, 2 deletions
diff --git a/src/buildtool/file_system/precomputed_root.hpp b/src/buildtool/file_system/precomputed_root.hpp
index 8261b94c..6df59bc9 100644
--- a/src/buildtool/file_system/precomputed_root.hpp
+++ b/src/buildtool/file_system/precomputed_root.hpp
@@ -42,6 +42,22 @@ struct ComputedRoot final {
[[nodiscard]] auto ComputeHash() const -> std::size_t;
};
+struct TreeStructureRoot final {
+ static constexpr auto kMarker = "tree structure";
+ static constexpr std::size_t kSchemeLength = 2;
+
+ std::string repository;
+
+ [[nodiscard]] auto operator==(TreeStructureRoot const& other) const noexcept
+ -> bool;
+
+ [[nodiscard]] auto operator<(TreeStructureRoot const& other) const noexcept
+ -> bool;
+
+ [[nodiscard]] auto ToString() const -> std::string;
+ [[nodiscard]] auto ComputeHash() const -> std::size_t;
+};
+
namespace std {
template <typename>
struct hash;
@@ -51,7 +67,7 @@ struct hash;
/// real build starts.
class PrecomputedRoot final {
public:
- using root_t = std::variant<ComputedRoot>;
+ using root_t = std::variant<ComputedRoot, TreeStructureRoot>;
explicit PrecomputedRoot() : PrecomputedRoot(ComputedRoot{}) {}
explicit PrecomputedRoot(root_t root)
: root_{std::move(root)}, hash_{ComputeHash(root_)} {}
@@ -61,7 +77,8 @@ class PrecomputedRoot final {
[[nodiscard]] static auto IsPrecomputedMarker(
std::string const& marker) noexcept -> bool {
- return marker == ComputedRoot::kMarker;
+ return marker == ComputedRoot::kMarker or
+ marker == TreeStructureRoot::kMarker;
}
[[nodiscard]] auto operator==(PrecomputedRoot const& other) const noexcept
@@ -86,6 +103,17 @@ class PrecomputedRoot final {
return std::nullopt;
}
+ [[nodiscard]] auto IsTreeStructure() const noexcept -> bool {
+ return std::holds_alternative<TreeStructureRoot>(root_);
+ }
+ [[nodiscard]] auto AsTreeStructure() const noexcept
+ -> std::optional<TreeStructureRoot> {
+ if (auto const* root = std::get_if<TreeStructureRoot>(&root_)) {
+ return *root;
+ }
+ return std::nullopt;
+ }
+
private:
root_t root_;
std::size_t hash_;