diff options
author | Maksim Denisov <denisov.maksim@huawei.com> | 2025-01-07 16:33:32 +0100 |
---|---|---|
committer | Maksim Denisov <denisov.maksim@huawei.com> | 2025-01-08 10:41:34 +0100 |
commit | 2308d90360216f81f0aa9b640aa9789c00d42053 (patch) | |
tree | 4c2c11b506a56f02b3ee06b7910ca413687be984 /src/other_tools/just_mr/setup_utils.cpp | |
parent | c5ae4d71e83f99c4c1b830e4d77ab18f5625fa31 (diff) | |
download | justbuild-2308d90360216f81f0aa9b640aa9789c00d42053.tar.gz |
Fix indirection of workspace roots in precomputed roots
Diffstat (limited to 'src/other_tools/just_mr/setup_utils.cpp')
-rw-r--r-- | src/other_tools/just_mr/setup_utils.cpp | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/src/other_tools/just_mr/setup_utils.cpp b/src/other_tools/just_mr/setup_utils.cpp index 63f555d8..07498441 100644 --- a/src/other_tools/just_mr/setup_utils.cpp +++ b/src/other_tools/just_mr/setup_utils.cpp @@ -59,13 +59,22 @@ void WarnUnknownKeys(std::string const& name, ExpressionPtr const& repo_def) { } } -[[nodiscard]] auto GetTargetRepoIfPrecomputed(ExpressionPtr const& repo) +[[nodiscard]] auto GetTargetRepoIfPrecomputed(ExpressionPtr const& repos, + std::string const& name) -> std::optional<std::string> { - if (not repo.IsNotNull() or not repo->IsMap()) { - return std::nullopt; + // Resolve indirections while the root's workspace root is declared + // implicitly: + ExpressionPtr root{name}; + while (root.IsNotNull() and root->IsString()) { + auto const repo = repos->Get(root->String(), Expression::none_t{}); + if (not repo.IsNotNull() or not repo->IsMap()) { + return std::nullopt; + } + root = repo->Get("repository", Expression::none_t{}); } - auto const repository = repo->Get("repository", Expression::none_t{}); - if (auto const precomputed = ParsePrecomputedRoot(repository)) { + + // Check the root is a precomputed root: + if (auto const precomputed = ParsePrecomputedRoot(root)) { return precomputed->GetReferencedRepository(); } return std::nullopt; @@ -100,9 +109,8 @@ void ReachableRepositories( WarnUnknownKeys(repo_name, repos_repo_name); // If the current repo is a computed one, process its target repo - if (auto computed_target = - GetTargetRepoIfPrecomputed(repos_repo_name)) { - to_process.push(*std::move(computed_target)); + if (auto precomputed = GetTargetRepoIfPrecomputed(repos, repo_name)) { + to_process.push(*std::move(precomputed)); } // check bindings @@ -125,9 +133,9 @@ void ReachableRepositories( // If the overlay repo is a computed one, process its target // repo - if (auto computed_target = GetTargetRepoIfPrecomputed( - repos->Get(layer_repo_name, Expression::none_t{}))) { - to_process.push(*std::move(computed_target)); + if (auto precomputed = + GetTargetRepoIfPrecomputed(repos, layer_repo_name)) { + to_process.push(*std::move(precomputed)); } } } |