summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/other_tools/repo_map/repos_to_setup_map.cpp10
-rw-r--r--src/other_tools/utils/parse_precomputed_root.cpp35
2 files changed, 44 insertions, 1 deletions
diff --git a/src/other_tools/repo_map/repos_to_setup_map.cpp b/src/other_tools/repo_map/repos_to_setup_map.cpp
index 383f763d..91a69c8b 100644
--- a/src/other_tools/repo_map/repos_to_setup_map.cpp
+++ b/src/other_tools/repo_map/repos_to_setup_map.cpp
@@ -670,6 +670,7 @@ void PrecomputedRootCheckout(ExpressionPtr const& repo_desc,
auto& ws_root = cfg["workspace_root"];
SetReposTakeOver(&cfg, repos, repo_name);
+ bool absent = false;
if (auto computed = result.AsComputed()) {
ws_root.push_back(ComputedRoot::kMarker);
ws_root.push_back(computed->repository);
@@ -680,7 +681,16 @@ void PrecomputedRootCheckout(ExpressionPtr const& repo_desc,
else if (auto tree_structure = result.AsTreeStructure()) {
ws_root.push_back(TreeStructureRoot::kMarker);
ws_root.push_back(tree_structure->repository);
+
+ absent = tree_structure->absent;
+ }
+
+ if (absent) {
+ auto pragma = nlohmann::json::object();
+ pragma["absent"] = true;
+ ws_root.push_back(pragma);
}
+
std::invoke(*setter, std::move(cfg));
},
logger);
diff --git a/src/other_tools/utils/parse_precomputed_root.cpp b/src/other_tools/utils/parse_precomputed_root.cpp
index 7b9ef519..f30316e6 100644
--- a/src/other_tools/utils/parse_precomputed_root.cpp
+++ b/src/other_tools/utils/parse_precomputed_root.cpp
@@ -21,6 +21,34 @@
#include "src/buildtool/build_engine/expression/expression.hpp"
namespace {
+[[nodiscard]] auto ParseAbsent(ExpressionPtr const& repository)
+ -> expected<bool, std::string> {
+ auto const pragma = repository->Get("pragma", Expression::none_t{});
+ if (not pragma.IsNotNull()) {
+ // Missing "pragma", absent == false
+ return false;
+ }
+
+ if (not pragma->IsMap()) {
+ return unexpected{fmt::format(
+ "Key \"pragma\", if given, should be a map, but found {}",
+ pragma->ToString())};
+ }
+
+ auto const is_absent = pragma->Get("absent", Expression::none_t{});
+ if (not is_absent.IsNotNull()) {
+ // "pragma" doesn't contain "absent", absent == false
+ return false;
+ }
+
+ if (not is_absent->IsBool()) {
+ return unexpected{fmt::format(
+ "Expected pragma \"absent\" to be boolean, but found {}",
+ is_absent->ToString())};
+ }
+ return is_absent->Bool();
+}
+
[[nodiscard]] auto ParseComputedRoot(ExpressionPtr const& repository)
-> expected<ComputedRoot, std::string> {
auto const repo = repository->Get("repo", Expression::none_t{});
@@ -67,7 +95,12 @@ namespace {
if (not repo.IsNotNull()) {
return unexpected<std::string>{"Mandatory key \"repo\" is missing"};
}
- return TreeStructureRoot{.repository = repo->String(), .absent = false};
+
+ auto absent = ParseAbsent(repository);
+ if (not absent.has_value()) {
+ return unexpected{std::move(absent).error()};
+ }
+ return TreeStructureRoot{.repository = repo->String(), .absent = *absent};
}
} // namespace