summaryrefslogtreecommitdiff
path: root/src/buildtool/build_engine/target_map/utils.cpp
diff options
context:
space:
mode:
authorMaksim Denisov <denisov.maksim@huawei.com>2024-07-12 12:11:02 +0200
committerMaksim Denisov <denisov.maksim@huawei.com>2024-07-22 17:01:13 +0200
commitb9e70662dfba7a9b5a674a6ad3c5194e2aec3a09 (patch)
tree38416a4621ce49df61a06921c0741768226cb5c7 /src/buildtool/build_engine/target_map/utils.cpp
parent82731197213dc591bf65f08fd644ec3882690120 (diff)
downloadjustbuild-b9e70662dfba7a9b5a674a6ad3c5194e2aec3a09.tar.gz
Use a fixed HashFunction in ActionDescription
Diffstat (limited to 'src/buildtool/build_engine/target_map/utils.cpp')
-rw-r--r--src/buildtool/build_engine/target_map/utils.cpp22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/buildtool/build_engine/target_map/utils.cpp b/src/buildtool/build_engine/target_map/utils.cpp
index 79d48ed0..cb7ad42d 100644
--- a/src/buildtool/build_engine/target_map/utils.cpp
+++ b/src/buildtool/build_engine/target_map/utils.cpp
@@ -185,10 +185,11 @@ auto BuildMaps::Target::Utils::getTainted(
}
namespace {
-auto hash_vector(std::vector<std::string> const& vec) -> std::string {
- auto hasher = HashFunction::Instance().Hasher();
+auto hash_vector(HashFunction hash_function,
+ std::vector<std::string> const& vec) -> std::string {
+ auto hasher = hash_function.Hasher();
for (auto const& s : vec) {
- hasher.Update(HashFunction::Instance().ComputeHash(s).Bytes());
+ hasher.Update(hash_function.ComputeHash(s).Bytes());
}
return std::move(hasher).Finalize().Bytes();
}
@@ -204,12 +205,17 @@ auto BuildMaps::Target::Utils::createAction(
double timeout_scale,
const ExpressionPtr& execution_properties_exp,
const ExpressionPtr& inputs_exp) -> ActionDescription::Ptr {
- auto hasher = HashFunction::Instance().Hasher();
- hasher.Update(hash_vector(output_files));
- hasher.Update(hash_vector(output_dirs));
- hasher.Update(hash_vector(command));
+ // The type of HashFunction is irrelevant here. It is used for
+ // identification and quick comparison of descriptions. SHA256 is used.
+ HashFunction hash_function{HashFunction::JustHash::Compatible};
+ auto hasher = hash_function.Hasher();
+
+ hasher.Update(hash_vector(hash_function, output_files));
+ hasher.Update(hash_vector(hash_function, output_dirs));
+ hasher.Update(hash_vector(hash_function, command));
hasher.Update(env->ToHash());
- hasher.Update(hash_vector(may_fail ? std::vector<std::string>{*may_fail}
+ hasher.Update(hash_vector(hash_function,
+ may_fail ? std::vector<std::string>{*may_fail}
: std::vector<std::string>{}));
hasher.Update(no_cache ? std::string{"N"} : std::string{"Y"});
hasher.Update(fmt::format("{:+24a}", timeout_scale));