diff options
author | Maksim Denisov <denisov.maksim@huawei.com> | 2024-12-19 11:48:54 +0100 |
---|---|---|
committer | Maksim Denisov <denisov.maksim@huawei.com> | 2024-12-20 11:36:17 +0100 |
commit | 981f44d47463ebbc3502494ad2f49173785d632b (patch) | |
tree | a777e2b69bce885728dc26605dedd63752764e55 /src/other_tools/utils | |
parent | 5e2fe74d3e5798ef73b3eef98d84577d881aad9a (diff) | |
download | justbuild-981f44d47463ebbc3502494ad2f49173785d632b.tar.gz |
TreeStructure: support parsing in just-mr
Diffstat (limited to 'src/other_tools/utils')
-rw-r--r-- | src/other_tools/utils/parse_precomputed_root.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/other_tools/utils/parse_precomputed_root.cpp b/src/other_tools/utils/parse_precomputed_root.cpp index 0b176450..a27c7989 100644 --- a/src/other_tools/utils/parse_precomputed_root.cpp +++ b/src/other_tools/utils/parse_precomputed_root.cpp @@ -60,6 +60,15 @@ namespace { ? config->ToJson() : nlohmann::json::object()}; } + +[[nodiscard]] auto ParseTreeStructureRoot(ExpressionPtr const& repository) + -> expected<TreeStructureRoot, std::string> { + auto const repo = repository->Get("repo", Expression::none_t{}); + if (not repo.IsNotNull()) { + return unexpected<std::string>{"Mandatory key \"repo\" is missing"}; + } + return TreeStructureRoot{.repository = repo->String()}; +} } // namespace auto ParsePrecomputedRoot(ExpressionPtr const& repository) @@ -85,6 +94,13 @@ auto ParsePrecomputedRoot(ExpressionPtr const& repository) } return PrecomputedRoot{*std::move(computed)}; } + if (type_marker == TreeStructureRoot::kMarker) { + auto tree_structure = ParseTreeStructureRoot(repository); + if (not tree_structure) { + return unexpected{std::move(tree_structure).error()}; + } + return PrecomputedRoot{*std::move(tree_structure)}; + } return unexpected{ fmt::format("Unknown type {} of precomputed repository", type_marker)}; } |