diff options
author | Klaus Aehlig <klaus.aehlig@huawei.com> | 2022-12-20 16:00:00 +0100 |
---|---|---|
committer | Klaus Aehlig <klaus.aehlig@huawei.com> | 2022-12-22 14:00:39 +0100 |
commit | d078a42ad24a6e45b7f4f48ef675355a9883e2ad (patch) | |
tree | 04f8618b3c21e65aa924f9e43ebedac9db545512 /src | |
parent | c314e2f549805c3ed37c8511d426a66283dbd17e (diff) | |
download | justbuild-d078a42ad24a6e45b7f4f48ef675355a9883e2ad.tar.gz |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/buildtool/build_engine/target_map/result_map.hpp | 31 |
1 files changed, 26 insertions, 5 deletions
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 <optional> #include <string> #include <thread> +#include <unordered_set> #include <vector> #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<AnalysedTargetPtr> result, - std::optional<TargetCache::Key> target_cache_key = - std::nullopt) -> AnalysedTargetPtr { + [[nodiscard]] auto Add( + BuildMaps::Base::EntityName name, + Configuration conf, + gsl::not_null<AnalysedTargetPtr> result, + std::optional<TargetCache::Key> target_cache_key = std::nullopt, + bool is_export_target = false) -> AnalysedTargetPtr { auto part = std::hash<BuildMaps::Base::EntityName>{}(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<ConfiguredTarget> { + std::vector<ConfiguredTarget> 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<TargetCache::Key, gsl::not_null<AnalysedTargetPtr>>> cache_targets_{width_}; + std::vector<std::unordered_set<ConfiguredTarget>> export_targets_{width_}; std::vector<std::size_t> num_actions_{std::vector<std::size_t>(width_)}; std::vector<std::size_t> num_blobs_{std::vector<std::size_t>(width_)}; std::vector<std::size_t> num_trees_{std::vector<std::size_t>(width_)}; |