diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/buildtool/computed_roots/TARGETS | 1 | ||||
-rw-r--r-- | src/buildtool/computed_roots/lookup_cache.cpp | 16 | ||||
-rw-r--r-- | src/buildtool/computed_roots/lookup_cache.hpp | 11 |
3 files changed, 11 insertions, 17 deletions
diff --git a/src/buildtool/computed_roots/TARGETS b/src/buildtool/computed_roots/TARGETS index e1d9bd79..4ff979b0 100644 --- a/src/buildtool/computed_roots/TARGETS +++ b/src/buildtool/computed_roots/TARGETS @@ -72,6 +72,7 @@ , ["src/buildtool/common", "cli"] , ["src/buildtool/common", "common"] , ["src/buildtool/crypto", "hash_function"] + , ["src/buildtool/execution_api/utils", "rehash_utils"] , ["src/buildtool/file_system", "file_root"] , ["src/buildtool/file_system", "file_system_manager"] , ["src/buildtool/file_system", "git_cas"] diff --git a/src/buildtool/computed_roots/lookup_cache.cpp b/src/buildtool/computed_roots/lookup_cache.cpp index 000cdbee..0555c74b 100644 --- a/src/buildtool/computed_roots/lookup_cache.cpp +++ b/src/buildtool/computed_roots/lookup_cache.cpp @@ -27,7 +27,6 @@ #include "src/buildtool/build_engine/expression/configuration.hpp" #include "src/buildtool/build_engine/expression/target_result.hpp" #include "src/buildtool/computed_roots/artifacts_root.hpp" -#include "src/buildtool/crypto/hash_function.hpp" #include "src/buildtool/file_system/file_root.hpp" #include "src/buildtool/multithreading/task_system.hpp" #include "src/buildtool/storage/target_cache_entry.hpp" @@ -36,7 +35,8 @@ auto LookupCache(BuildMaps::Target::ConfiguredTarget const& ctarget, gsl::not_null<RepositoryConfig*> const& repository_config, Storage const& storage, - AsyncMapConsumerLoggerPtr const& logger) + AsyncMapConsumerLoggerPtr const& logger, + std::optional<RehashUtils::Rehasher> const& rehash) -> expected<std::optional<std::string>, std::monostate> { auto const* target_root = repository_config->TargetRoot(ctarget.target.ToModule().repository); @@ -102,16 +102,6 @@ auto LookupCache(BuildMaps::Target::ConfiguredTarget const& ctarget, if (not flexible_vars) { return unexpected(std::monostate{}); } - // TODO(aehlig): Support re-hashing in case of compatible mode, so that - // cache lookups can be used in this case as well. - if (storage.GetHashFunction().GetType() != HashFunction::Type::GitSHA1) { - // So far, transforming the result of a cache hit in memory into - // a git root is only implemented for GitSHA1. Therefore, do not - // try to look up cache hits, and simply pretend a non hit. - return expected<std::optional<std::string>, std::monostate>( - std::nullopt); - } - auto effective_config = ctarget.config.Prune(*flexible_vars); auto cache_key = storage.TargetCache().ComputeKey( *repo_key, ctarget.target.GetNamedTarget(), effective_config); @@ -141,7 +131,7 @@ auto LookupCache(BuildMaps::Target::ConfiguredTarget const& ctarget, msg), fatal); }); - auto root = ArtifactsRoot(result->artifact_stage, wrapped_logger); + auto root = ArtifactsRoot(result->artifact_stage, wrapped_logger, rehash); if (not root) { return unexpected(std::monostate{}); } diff --git a/src/buildtool/computed_roots/lookup_cache.hpp b/src/buildtool/computed_roots/lookup_cache.hpp index 0f8096d1..a613313e 100644 --- a/src/buildtool/computed_roots/lookup_cache.hpp +++ b/src/buildtool/computed_roots/lookup_cache.hpp @@ -22,14 +22,17 @@ #include "gsl/gsl" #include "src/buildtool/build_engine/target_map/configured_target.hpp" #include "src/buildtool/common/repository_config.hpp" +#include "src/buildtool/execution_api/utils/rehash_utils.hpp" #include "src/buildtool/multithreading/async_map_consumer.hpp" #include "src/buildtool/storage/storage.hpp" #include "src/utils/cpp/expected.hpp" -auto LookupCache(BuildMaps::Target::ConfiguredTarget const& ctarget, - gsl::not_null<RepositoryConfig*> const& repository_config, - Storage const& storage, - AsyncMapConsumerLoggerPtr const& logger) +auto LookupCache( + BuildMaps::Target::ConfiguredTarget const& ctarget, + gsl::not_null<RepositoryConfig*> const& repository_config, + Storage const& storage, + AsyncMapConsumerLoggerPtr const& logger, + std::optional<RehashUtils::Rehasher> const& rehash = std::nullopt) -> expected<std::optional<std::string>, std::monostate>; #endif |