diff options
author | Klaus Aehlig <klaus.aehlig@huawei.com> | 2024-01-16 10:57:35 +0100 |
---|---|---|
committer | Klaus Aehlig <klaus.aehlig@huawei.com> | 2024-01-16 18:50:42 +0100 |
commit | 6c456dbbd4e5aa7e54f3c51fbf7f45ea98d4abd2 (patch) | |
tree | 8e005eb4225d9298638cb860d5d71f11a74f84ec | |
parent | c472af3fabda73788ccdea8848e6072a989c2a23 (diff) | |
download | justbuild-6c456dbbd4e5aa7e54f3c51fbf7f45ea98d4abd2.tar.gz |
TargetCacheEntry: return implied targets, if serialized
-rw-r--r-- | src/buildtool/storage/target_cache_entry.cpp | 16 | ||||
-rw-r--r-- | src/buildtool/storage/target_cache_entry.hpp | 4 |
2 files changed, 20 insertions, 0 deletions
diff --git a/src/buildtool/storage/target_cache_entry.cpp b/src/buildtool/storage/target_cache_entry.cpp index e06d0caa..002b3465 100644 --- a/src/buildtool/storage/target_cache_entry.cpp +++ b/src/buildtool/storage/target_cache_entry.cpp @@ -45,6 +45,22 @@ auto TargetCacheEntry::ToResult() const noexcept return TargetResult::FromJson(desc_); } +auto TargetCacheEntry::ToImplied() const noexcept -> std::set<std::string> { + std::set<std::string> result{}; + if (desc_.contains("implied export targets")) { + try { + for (auto const& x : desc_["implied export targets"]) { + result.emplace(x); + } + } catch (std::exception const& ex) { + Logger::Log(LogLevel::Warning, + "Exception reading implied export targets: {}", + ex.what()); + } + } + return result; +} + [[nodiscard]] auto ToObjectInfo(nlohmann::json const& json) -> Artifact::ObjectInfo { auto const& desc = ArtifactDescription::FromJson(json); diff --git a/src/buildtool/storage/target_cache_entry.hpp b/src/buildtool/storage/target_cache_entry.hpp index c83d7929..a976dd8c 100644 --- a/src/buildtool/storage/target_cache_entry.hpp +++ b/src/buildtool/storage/target_cache_entry.hpp @@ -16,6 +16,7 @@ #define INCLUDED_SRC_BUILDTOOL_STORAGE_TARGET_CACHE_ENTRY_HPP #include <optional> +#include <set> #include <unordered_map> #include <utility> #include <vector> @@ -46,6 +47,9 @@ class TargetCacheEntry { // Obtain TargetResult from cache entry. [[nodiscard]] auto ToResult() const noexcept -> std::optional<TargetResult>; + // Obtain the implied export targets + [[nodiscard]] auto ToImplied() const noexcept -> std::set<std::string>; + // Obtain all artifacts from cache entry (all should be known // artifacts). [[nodiscard]] auto ToArtifacts( |