diff options
author | Maksim Denisov <denisov.maksim@huawei.com> | 2024-12-17 16:26:01 +0100 |
---|---|---|
committer | Maksim Denisov <denisov.maksim@huawei.com> | 2024-12-19 16:37:59 +0100 |
commit | 75abf567afd7a130e9fbc90c6b7ac03ac40651c1 (patch) | |
tree | 0331c8ff237524b6e1cfd32fe88e82e138b13f7e /src/buildtool/file_system/file_root.hpp | |
parent | bd606d1355afe1276675ac1c0077d44bb484b363 (diff) | |
download | justbuild-75abf567afd7a130e9fbc90c6b7ac03ac40651c1.tar.gz |
Use PrecomputedRoots during evaluation
Diffstat (limited to 'src/buildtool/file_system/file_root.hpp')
-rw-r--r-- | src/buildtool/file_system/file_root.hpp | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/src/buildtool/file_system/file_root.hpp b/src/buildtool/file_system/file_root.hpp index ce92ab1e..e47b68f5 100644 --- a/src/buildtool/file_system/file_root.hpp +++ b/src/buildtool/file_system/file_root.hpp @@ -827,25 +827,17 @@ class FileRoot { FileRoot{std::string{root[1]}, /*ignore_special=*/true}, std::nullopt}; } - if (root[0] == FileRoot::kComputedMarker) { - // NOLINTNEXTLINE(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers) - if (root.size() != 5 or (not root[1].is_string()) or - (not root[2].is_string()) or (not root[3].is_string()) or - (not root[4].is_object())) { - return unexpected{fmt::format( - "{} scheme requires, in this order, the arugments root, " - "module, name, config. However found {} for {} of " - "repository {}", - kComputedMarker, - root.dump(), - keyword, - repo)}; - } - return ResultType{FileRoot{std::string{root[1]}, - std::string{root[2]}, - std::string{root[3]}, - root[4]}, - std::nullopt}; + if (PrecomputedRoot::IsPrecomputedMarker(root[0])) { + auto precomputed = PrecomputedRoot::Parse(root); + if (not precomputed) { + return unexpected{ + fmt::format("While parsing {} for {} of repository{}:\n{}", + root.dump(), + keyword, + repo, + std::move(precomputed).error())}; + } + return ResultType{FileRoot{*std::move(precomputed)}, std::nullopt}; } return unexpected{fmt::format( "Unknown scheme in the specification {} of {} of repository {}", |