diff options
author | Maksim Denisov <denisov.maksim@huawei.com> | 2024-12-02 12:54:56 +0100 |
---|---|---|
committer | Maksim Denisov <denisov.maksim@huawei.com> | 2024-12-03 14:11:38 +0100 |
commit | 82ed6198795f57997bb94f0a11dbfa6835101056 (patch) | |
tree | f9a9794b2c7ed9d9e8f5c2a2ba85b81ee7dd4b3c /src/other_tools/just_mr/setup_utils.cpp | |
parent | d51dbc74c5aeb7a9380a9e18082bb2d25527ee89 (diff) | |
download | justbuild-82ed6198795f57997bb94f0a11dbfa6835101056.tar.gz |
JustMR: add computed overlay repos to reachable
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, 24 insertions, 6 deletions
diff --git a/src/other_tools/just_mr/setup_utils.cpp b/src/other_tools/just_mr/setup_utils.cpp index f469af80..417984ea 100644 --- a/src/other_tools/just_mr/setup_utils.cpp +++ b/src/other_tools/just_mr/setup_utils.cpp @@ -58,6 +58,20 @@ void WarnUnknownKeys(std::string const& name, ExpressionPtr const& repo_def) { } } +[[nodiscard]] auto GetTargetRepoIfComputed(ExpressionPtr const& repo) + -> std::optional<std::string> { + if (not repo.IsNotNull() or not repo->IsMap()) { + return std::nullopt; + } + auto const repository = repo->Get("repository", Expression::none_t{}); + if (auto const crparser = ComputedRootParser::Create(&repository)) { + if (auto target_repo = crparser->GetTargetRepository()) { + return std::move(target_repo).value(); + } + } + return std::nullopt; +} + } // namespace namespace JustMR::Utils { @@ -86,12 +100,9 @@ void ReachableRepositories( } WarnUnknownKeys(repo_name, repos_repo_name); - auto const repository = - repos_repo_name->Get("repository", Expression::none_t{}); - if (auto const crparser = ComputedRootParser::Create(&repository)) { - if (auto const target_repo = crparser->GetTargetRepository()) { - to_process.push(*target_repo); - } + // If the current repo is a computed one, process its target repo + if (auto computed_target = GetTargetRepoIfComputed(repos_repo_name)) { + to_process.push(*std::move(computed_target)); } // check bindings @@ -111,6 +122,13 @@ void ReachableRepositories( if (layer_val.IsNotNull() and layer_val->IsString()) { auto const layer_repo_name = layer_val->String(); setup_repos_set.insert(layer_repo_name); + + // If the overlay repo is a computed one, process its target + // repo + if (auto computed_target = GetTargetRepoIfComputed( + repos->Get(layer_repo_name, Expression::none_t{}))) { + to_process.push(*std::move(computed_target)); + } } } } |