diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/buildtool/common/repository_config.cpp | 25 | ||||
-rw-r--r-- | src/buildtool/common/repository_config.hpp | 3 |
2 files changed, 28 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)); + } + } +} diff --git a/src/buildtool/common/repository_config.hpp b/src/buildtool/common/repository_config.hpp index cffd4971..0060152d 100644 --- a/src/buildtool/common/repository_config.hpp +++ b/src/buildtool/common/repository_config.hpp @@ -66,6 +66,9 @@ class RepositoryConfig { return static_cast<bool>(git_cas_); } + void SetComputedRoot(FileRoot::ComputedRoot const& root, + FileRoot const& value); + [[nodiscard]] auto Info(std::string const& repo) const noexcept -> RepositoryInfo const* { if (auto const* data = Data(repo)) { |