diff options
author | Klaus Aehlig <klaus.aehlig@huawei.com> | 2024-03-22 10:23:12 +0100 |
---|---|---|
committer | Klaus Aehlig <klaus.aehlig@huawei.com> | 2024-03-22 18:58:22 +0100 |
commit | df07927f2837986fe7d9c6a9313fa8b759870b1b (patch) | |
tree | d4a151b5fff555ab5cb9adc71d03bf9e43c73c22 /src | |
parent | 833dc67563c01442eebb246a5f4316685d2eb17c (diff) | |
download | justbuild-df07927f2837986fe7d9c6a9313fa8b759870b1b.tar.gz |
Avoid unnecessary calls to serve for export targets
For export targets, we know ahead of time the effective configuration;
so, if the current configuration is not the effective anyway, we
can simply analyse the effective configuration and take that result.
In this way, we can avoid calls to serve if a target is analysed
in two configurations that coincide on the flexible variables.
Diffstat (limited to 'src')
-rw-r--r-- | src/buildtool/build_engine/target_map/absent_target_map.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/buildtool/build_engine/target_map/absent_target_map.cpp b/src/buildtool/build_engine/target_map/absent_target_map.cpp index 917ddd2a..7b67ced8 100644 --- a/src/buildtool/build_engine/target_map/absent_target_map.cpp +++ b/src/buildtool/build_engine/target_map/absent_target_map.cpp @@ -31,7 +31,7 @@ auto BuildMaps::Target::CreateAbsentTargetMap( auto /*ts*/, auto setter, auto logger, - auto /*subcaller*/, + auto subcaller, auto key) { // assumptions: // - target with absent targets file requested @@ -57,10 +57,22 @@ auto BuildMaps::Target::CreateAbsentTargetMap( /*fatal=*/true); return; } + auto effective_config = key.config.Prune(*flexible_vars); + if (key.config != effective_config) { + (*subcaller)( + {BuildMaps::Target::ConfiguredTarget{ + .target = key.target, .config = effective_config}}, + [setter](auto const& values) { + AnalysedTargetPtr result = *(values[0]); + (*setter)(std::move(result)); + }, + logger); + return; + } + // we know now that this target is an export target - stats->IncrementExportsFoundCounter(); // TODO(asartori): avoid code duplication in export.cpp - auto effective_config = key.config.Prune(*flexible_vars); + stats->IncrementExportsFoundCounter(); auto target_name = key.target.GetNamedTarget(); auto repo_key = repo_config->RepositoryKey(target_name.repository); if (!repo_key) { |