diff options
Diffstat (limited to 'src/buildtool/common/repository_config.cpp')
-rw-r--r-- | src/buildtool/common/repository_config.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/buildtool/common/repository_config.cpp b/src/buildtool/common/repository_config.cpp index 78f7b8a4..933d48b2 100644 --- a/src/buildtool/common/repository_config.cpp +++ b/src/buildtool/common/repository_config.cpp @@ -150,3 +150,28 @@ auto RepositoryConfig::AddToGraphAndGetId( } return std::nullopt; } + +void RepositoryConfig::SetComputedRoot(FileRoot::ComputedRoot const& root, + FileRoot const& value) { + for (auto const& [name, desc] : repos_) { + auto new_info = desc.info; + bool changed = false; + auto set_root_if_matching = + [&changed, &root, &value](auto* candidate_root) { + auto croot = candidate_root->GetComputedDescription(); + if (croot) { + if (*croot == root) { + *candidate_root = value; + changed = true; + } + } + }; + set_root_if_matching(&new_info.workspace_root); + set_root_if_matching(&new_info.target_root); + set_root_if_matching(&new_info.rule_root); + set_root_if_matching(&new_info.expression_root); + if (changed) { + SetInfo(name, std::move(new_info)); + } + } +} |