From d078a42ad24a6e45b7f4f48ef675355a9883e2ad Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Tue, 20 Dec 2022 16:00:00 +0100 Subject: result_map: also keep track of export targets Allow in the addition of a target to the result map to indicate that it was an export target; in this way, the information is available as a result of the analysis. --- .../build_engine/target_map/result_map.hpp | 31 ++++++++++++++++++---- 1 file changed, 26 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/buildtool/build_engine/target_map/result_map.hpp b/src/buildtool/build_engine/target_map/result_map.hpp index b61ac2d0..700cf7bb 100644 --- a/src/buildtool/build_engine/target_map/result_map.hpp +++ b/src/buildtool/build_engine/target_map/result_map.hpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include "gsl-lite/gsl-lite.hpp" @@ -63,11 +64,12 @@ class ResultTargetMap { // configuration, if no entry is present for the given // target-configuration pair. \returns the analysed target that is // element of the map after insertion. - [[nodiscard]] auto Add(BuildMaps::Base::EntityName name, - Configuration conf, - gsl::not_null result, - std::optional target_cache_key = - std::nullopt) -> AnalysedTargetPtr { + [[nodiscard]] auto Add( + BuildMaps::Base::EntityName name, + Configuration conf, + gsl::not_null result, + std::optional target_cache_key = std::nullopt, + bool is_export_target = false) -> AnalysedTargetPtr { auto part = std::hash{}(name) % width_; std::unique_lock lock{m_[part]}; auto [entry, inserted] = targets_[part].emplace( @@ -76,6 +78,9 @@ class ResultTargetMap { if (target_cache_key) { cache_targets_[part].emplace(*target_cache_key, entry->second); } + if (is_export_target) { + export_targets_[part].emplace(entry->first); + } if (inserted) { num_actions_[part] += entry->second->Actions().size(); num_blobs_[part] += entry->second->Blobs().size(); @@ -106,6 +111,21 @@ class ResultTargetMap { return targets; } + [[nodiscard]] auto ExportTargets() const noexcept + -> std::vector { + std::vector all_exports{}; + for (auto const& exports : export_targets_) { + all_exports.insert( + all_exports.end(), exports.begin(), exports.end()); + } + std::sort(all_exports.begin(), + all_exports.end(), + [](auto const& lhs, auto const& rhs) { + return lhs.ToString() < rhs.ToString(); + }); + return all_exports; + } + [[nodiscard]] auto ConfiguredTargetsGraph() const noexcept -> nlohmann::json { auto result = nlohmann::json::object(); @@ -343,6 +363,7 @@ class ResultTargetMap { std::vector< std::unordered_map>> cache_targets_{width_}; + std::vector> export_targets_{width_}; std::vector num_actions_{std::vector(width_)}; std::vector num_blobs_{std::vector(width_)}; std::vector num_trees_{std::vector(width_)}; -- cgit v1.2.3