diff options
author | Klaus Aehlig <klaus.aehlig@huawei.com> | 2024-11-28 15:12:12 +0100 |
---|---|---|
committer | Klaus Aehlig <klaus.aehlig@huawei.com> | 2024-11-28 16:43:50 +0100 |
commit | 8a4fb82d7376c08b0473df3899803fc68e5578f0 (patch) | |
tree | d1546a173c13e6ae7a00597e1e48fcc91fb548a2 /src | |
parent | 7ce5c124f942be4e576b97670682d6afb12fb570 (diff) | |
download | justbuild-8a4fb82d7376c08b0473df3899803fc68e5578f0.tar.gz |
computed roots: restrict in-memory root computation to the supported cases
... and, in this way, avoid git-tree computations with invalid git
identifiers.
Diffstat (limited to 'src')
-rw-r--r-- | src/buildtool/computed_roots/TARGETS | 1 | ||||
-rw-r--r-- | src/buildtool/computed_roots/artifacts_root.cpp | 2 | ||||
-rw-r--r-- | src/buildtool/computed_roots/lookup_cache.cpp | 11 |
3 files changed, 12 insertions, 2 deletions
diff --git a/src/buildtool/computed_roots/TARGETS b/src/buildtool/computed_roots/TARGETS index 208711df..a714cfc1 100644 --- a/src/buildtool/computed_roots/TARGETS +++ b/src/buildtool/computed_roots/TARGETS @@ -70,6 +70,7 @@ , ["src/buildtool/build_engine/target_map", "configured_target"] , ["src/buildtool/common", "cli"] , ["src/buildtool/common", "common"] + , ["src/buildtool/crypto", "hash_function"] , ["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/artifacts_root.cpp b/src/buildtool/computed_roots/artifacts_root.cpp index dde240a6..8124461b 100644 --- a/src/buildtool/computed_roots/artifacts_root.cpp +++ b/src/buildtool/computed_roots/artifacts_root.cpp @@ -146,8 +146,6 @@ auto ArtifactsRoot(ExpressionPtr const& stage, true); return std::nullopt; } - // TODO(aehlig): Do re-hashing in case of compatible mode - // We obtain the entries odered by key; in particular, the entries of all // subtrees will be next to each other. So, we compute the final tree // keeping a stack of partially set up tree while walking. diff --git a/src/buildtool/computed_roots/lookup_cache.cpp b/src/buildtool/computed_roots/lookup_cache.cpp index 9021463c..000cdbee 100644 --- a/src/buildtool/computed_roots/lookup_cache.cpp +++ b/src/buildtool/computed_roots/lookup_cache.cpp @@ -27,6 +27,7 @@ #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" @@ -101,6 +102,16 @@ 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); |