diff options
author | Klaus Aehlig <klaus.aehlig@huawei.com> | 2024-01-16 18:11:18 +0100 |
---|---|---|
committer | Klaus Aehlig <klaus.aehlig@huawei.com> | 2024-01-16 18:59:41 +0100 |
commit | d33ee60d94b4d228d006b4a9f067489ac4ff32e0 (patch) | |
tree | 3ae872404d46186d064b8eb575c9102596170d12 /src | |
parent | 665b1b04f255ef27403d67d4a4ca8582c179307b (diff) | |
download | justbuild-d33ee60d94b4d228d006b4a9f067489ac4ff32e0.tar.gz |
Keep implied target-cache values alive
... by uplinking them appropriately.
Diffstat (limited to 'src')
-rw-r--r-- | src/buildtool/storage/target_cache.hpp | 5 | ||||
-rw-r--r-- | src/buildtool/storage/target_cache.tpp | 19 |
2 files changed, 23 insertions, 1 deletions
diff --git a/src/buildtool/storage/target_cache.hpp b/src/buildtool/storage/target_cache.hpp index f263fdf9..385d1cd0 100644 --- a/src/buildtool/storage/target_cache.hpp +++ b/src/buildtool/storage/target_cache.hpp @@ -123,6 +123,11 @@ class TargetCache { /*kSetEpochTime=*/false> file_store_; + template <bool kIsLocalGeneration = not kDoGlobalUplink> + requires(kIsLocalGeneration) [[nodiscard]] auto LocalUplinkEntry( + LocalGenerationTC const& latest, + std::string const& key_digest) const noexcept -> bool; + [[nodiscard]] static auto ComputeShard() noexcept -> std::string { return ArtifactDigest::Create<ObjectType::File>( StorageConfig::ExecutionBackendDescription()) diff --git a/src/buildtool/storage/target_cache.tpp b/src/buildtool/storage/target_cache.tpp index d1c9d01c..cd56ef59 100644 --- a/src/buildtool/storage/target_cache.tpp +++ b/src/buildtool/storage/target_cache.tpp @@ -87,8 +87,15 @@ requires(kIsLocalGeneration) auto TargetCache< kDoGlobalUplink>::LocalUplinkEntry(LocalGenerationTC const& latest, TargetCacheKey const& key) const noexcept -> bool { + return LocalUplinkEntry(latest, key.Id().digest.hash()); +} + +template <bool kDoGlobalUplink> +template <bool kIsLocalGeneration> +requires(kIsLocalGeneration) auto TargetCache<kDoGlobalUplink>:: + LocalUplinkEntry(LocalGenerationTC const& latest, + std::string const& key_digest) const noexcept -> bool { // Determine target cache key path of given generation. - auto key_digest = key.Id().digest.hash(); if (FileSystemManager::IsFile(latest.file_store_.GetPath(key_digest))) { return true; } @@ -125,6 +132,16 @@ requires(kIsLocalGeneration) auto TargetCache< return false; } auto entry = TargetCacheEntry::FromJson(json_desc); + + // Uplink the implied export targets first + for (auto const& implied_digest : entry.ToImplied()) { + if (implied_digest != key_digest) { + if (not LocalUplinkEntry(latest, implied_digest)) { + return false; + } + } + } + std::vector<Artifact::ObjectInfo> artifacts_info; if (not entry.ToArtifacts(&artifacts_info)) { return false; |