diff options
author | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2023-11-24 11:31:42 +0100 |
---|---|---|
committer | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2023-11-27 15:03:20 +0100 |
commit | cf04253130030bc28866d10aa1f8fe1353643d42 (patch) | |
tree | ef7049624771866455105a8dab7b001840139701 /src/buildtool/build_engine/target_map/export.cpp | |
parent | bc09302c2772c979c45ecc716c36e4a70bb484ac (diff) | |
download | justbuild-cf04253130030bc28866d10aa1f8fe1353643d42.tar.gz |
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.
Diffstat (limited to 'src/buildtool/build_engine/target_map/export.cpp')
-rw-r--r-- | src/buildtool/build_engine/target_map/export.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
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<RepositoryConfig*> const& repo_config, Configuration const& target_config) -> std::optional<TargetCacheKey> { - 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<RepositoryConfig*>& 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(), |