diff options
author | Maksim Denisov <denisov.maksim@huawei.com> | 2024-11-26 12:47:56 +0100 |
---|---|---|
committer | Maksim Denisov <denisov.maksim@huawei.com> | 2024-11-27 10:58:41 +0100 |
commit | 3a01cc4df91286fa0a3c762a5fa500aa5ed261a5 (patch) | |
tree | e23890b991cf350366e955ce2cae863f576080f4 | |
parent | 99484594466469820ef8f2c4ceee25420b90dd6f (diff) | |
download | justbuild-3a01cc4df91286fa0a3c762a5fa500aa5ed261a5.tar.gz |
JustMR: Add computed repos and their targets to reachable
-rw-r--r-- | src/other_tools/just_mr/TARGETS | 1 | ||||
-rw-r--r-- | src/other_tools/just_mr/setup_utils.cpp | 37 |
2 files changed, 30 insertions, 8 deletions
diff --git a/src/other_tools/just_mr/TARGETS b/src/other_tools/just_mr/TARGETS index 9ce20bf5..2bb5db5b 100644 --- a/src/other_tools/just_mr/TARGETS +++ b/src/other_tools/just_mr/TARGETS @@ -104,6 +104,7 @@ , ["src/buildtool/file_system", "file_system_manager"] , ["src/buildtool/logging", "log_level"] , ["src/buildtool/logging", "logging"] + , ["src/other_tools/utils", "parse_computed_root"] , ["src/utils/cpp", "expected"] ] } diff --git a/src/other_tools/just_mr/setup_utils.cpp b/src/other_tools/just_mr/setup_utils.cpp index d7dc6e5d..b1c1584d 100644 --- a/src/other_tools/just_mr/setup_utils.cpp +++ b/src/other_tools/just_mr/setup_utils.cpp @@ -30,6 +30,7 @@ #include "src/buildtool/logging/log_level.hpp" #include "src/buildtool/logging/logger.hpp" #include "src/other_tools/just_mr/exit_codes.hpp" +#include "src/other_tools/utils/parse_computed_root.hpp" #include "src/utils/cpp/expected.hpp" namespace { @@ -65,19 +66,35 @@ void ReachableRepositories( std::shared_ptr<JustMR::SetupRepos> const& setup_repos) { // use temporary sets to avoid duplicates std::unordered_set<std::string> include_repos_set{}; + // computed must not contain overlay repos, so they are collected separately + std::unordered_set<std::string> computed_repos_set{}; // traversal of bindings std::function<void(std::string const&)> traverse = [&](std::string const& repo_name) { - if (not include_repos_set.contains(repo_name)) { - // if not found, add it and repeat for its bindings + if (include_repos_set.contains(repo_name) or + computed_repos_set.contains(repo_name)) { + return; + } + auto const repos_repo_name = + repos->Get(repo_name, Expression::none_t{}); + if (not repos_repo_name.IsNotNull()) { include_repos_set.insert(repo_name); - // check bindings - auto repos_repo_name = - repos->Get(repo_name, Expression::none_t{}); - if (not repos_repo_name.IsNotNull()) { - return; + return; + } + WarnUnknownKeys(repo_name, repos_repo_name); + + auto const repository = + repos_repo_name->Get("repository", Expression::none_t{}); + if (auto const crparser = ComputedRootParser::Create(&repository)) { + computed_repos_set.insert(repo_name); + if (auto const target_repo = crparser->GetTargetRepository()) { + traverse(*target_repo); } - WarnUnknownKeys(repo_name, repos_repo_name); + } + else { + // if not computed, add it and repeat for its bindings + include_repos_set.insert(repo_name); + // check bindings auto bindings = repos_repo_name->Get("bindings", Expression::none_t{}); if (bindings.IsNotNull() and bindings->IsMap()) { @@ -107,6 +124,10 @@ void ReachableRepositories( } } + setup_repos_set.insert(computed_repos_set.begin(), + computed_repos_set.end()); + include_repos_set.merge(std::move(computed_repos_set)); + // copy to vectors setup_repos->to_setup.clear(); setup_repos->to_setup.reserve(setup_repos_set.size()); |