From cf04253130030bc28866d10aa1f8fe1353643d42 Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Fri, 24 Nov 2023 11:31:42 +0100 Subject: Refactoring RepositoryConfig With the introduction of 'just serve', export targets can now be built also independently from one another based on their corresponding minimal repository configuration, as stored in the target cache key. In this context, this commit changes the RepositoryConfig usage from one global (static) instance to pointers passed as necessary throughout the code. --- src/buildtool/build_engine/target_map/export.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/buildtool/build_engine/target_map/export.cpp') diff --git a/src/buildtool/build_engine/target_map/export.cpp b/src/buildtool/build_engine/target_map/export.cpp index d832b2ee..06b80c26 100644 --- a/src/buildtool/build_engine/target_map/export.cpp +++ b/src/buildtool/build_engine/target_map/export.cpp @@ -81,10 +81,10 @@ void FinalizeExport( [[nodiscard]] auto ComputeTargetCacheKey( BuildMaps::Base::EntityName const& export_target, + gsl::not_null const& repo_config, Configuration const& target_config) -> std::optional { - static auto const& repos = RepositoryConfig::Instance(); auto const& target_name = export_target.GetNamedTarget(); - if (auto repo_key = repos.RepositoryKey(target_name.repository)) { + if (auto repo_key = repo_config->RepositoryKey(target_name.repository)) { return TargetCacheKey::Create(*repo_key, target_name, target_config); } return std::nullopt; @@ -95,6 +95,7 @@ void FinalizeExport( void ExportRule( const nlohmann::json& desc_json, const BuildMaps::Target::ConfiguredTarget& key, + const gsl::not_null& repo_config, const BuildMaps::Target::TargetMap::SubCallerPtr& subcaller, const BuildMaps::Target::TargetMap::SetterPtr& setter, const BuildMaps::Target::TargetMap::LoggerPtr& logger, @@ -106,7 +107,8 @@ void ExportRule( return; } auto effective_config = key.config.Prune(*flexible_vars); - auto target_cache_key = ComputeTargetCacheKey(key.target, effective_config); + auto target_cache_key = + ComputeTargetCacheKey(key.target, repo_config, effective_config); if (target_cache_key) { if (auto target_cache_value = @@ -174,6 +176,7 @@ void ExportRule( auto exported_target = BuildMaps::Base::ParseEntityNameFromExpression( exported_target_name, key.target, + repo_config, [&logger, &exported_target_name](std::string const& parse_err) { (*logger)(fmt::format("Parsing target name {} failed with:\n{}", exported_target_name->ToString(), -- cgit v1.2.3