summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/buildtool/build_engine/expression/expression.cpp6
-rw-r--r--src/buildtool/build_engine/target_map/utils.cpp4
-rw-r--r--src/buildtool/common/artifact_description.cpp4
-rw-r--r--src/buildtool/common/artifact_digest.hpp4
-rw-r--r--src/buildtool/common/repository_config.cpp2
-rw-r--r--src/buildtool/common/tree.hpp4
-rw-r--r--src/buildtool/compatibility/compatibility.hpp4
-rw-r--r--src/buildtool/crypto/hash_function.cpp10
-rw-r--r--src/buildtool/crypto/hash_function.hpp24
-rw-r--r--src/buildtool/execution_api/bazel_msg/bazel_msg_factory.cpp2
-rw-r--r--src/buildtool/execution_api/common/execution_common.hpp4
-rw-r--r--src/buildtool/execution_api/common/tree_reader_utils.cpp2
-rw-r--r--src/buildtool/execution_api/git/git_api.hpp2
-rw-r--r--src/buildtool/execution_api/local/local_cas_reader.cpp4
-rw-r--r--src/buildtool/execution_api/remote/bazel/bazel_cas_client.cpp12
-rw-r--r--src/buildtool/execution_api/remote/bazel/bazel_network_reader.cpp15
-rw-r--r--src/buildtool/execution_api/utils/subobject.cpp4
-rw-r--r--src/buildtool/main/install_cas.cpp2
-rw-r--r--src/buildtool/main/main.cpp4
-rw-r--r--src/buildtool/serve_api/serve_service/source_tree.cpp4
-rw-r--r--src/buildtool/storage/config.hpp6
-rw-r--r--src/buildtool/storage/fs_utils.cpp2
-rw-r--r--src/buildtool/storage/garbage_collector.cpp22
-rw-r--r--src/other_tools/just_mr/main.cpp4
-rw-r--r--src/other_tools/repo_map/repos_to_setup_map.cpp4
25 files changed, 75 insertions, 80 deletions
diff --git a/src/buildtool/build_engine/expression/expression.cpp b/src/buildtool/build_engine/expression/expression.cpp
index 9f901708..7d0f55b5 100644
--- a/src/buildtool/build_engine/expression/expression.cpp
+++ b/src/buildtool/build_engine/expression/expression.cpp
@@ -241,7 +241,7 @@ auto Expression::ComputeHash() const noexcept -> std::string {
// The type of HashFunction is irrelevant here. It is used for
// identification and quick comparison of expressions. SHA256 is used.
- HashFunction const hash_function{HashFunction::JustHash::Compatible};
+ HashFunction const hash_function{HashFunction::Type::PlainSHA256};
if (IsNone() or IsBool() or IsNumber() or IsString() or IsArtifact() or
IsResult() or IsNode() or IsName()) {
// just hash the JSON representation, but prepend "@" for artifact,
@@ -251,7 +251,7 @@ auto Expression::ComputeHash() const noexcept -> std::string {
: IsNode() ? "#"
: IsName() ? "$"
: ""};
- hash = hash_function.ComputeHash(prefix + ToString()).Bytes();
+ hash = hash_function.PlainHashData(prefix + ToString()).Bytes();
}
else {
auto hasher = hash_function.MakeHasher();
@@ -266,7 +266,7 @@ auto Expression::ComputeHash() const noexcept -> std::string {
auto map = Value<Expression::map_t>();
hasher.Update("{");
for (auto const& el : map->get()) {
- hasher.Update(hash_function.ComputeHash(el.first).Bytes());
+ hasher.Update(hash_function.PlainHashData(el.first).Bytes());
hasher.Update(el.second->ToHash());
}
}
diff --git a/src/buildtool/build_engine/target_map/utils.cpp b/src/buildtool/build_engine/target_map/utils.cpp
index 742a5e2f..56f996ca 100644
--- a/src/buildtool/build_engine/target_map/utils.cpp
+++ b/src/buildtool/build_engine/target_map/utils.cpp
@@ -189,7 +189,7 @@ auto hash_vector(HashFunction hash_function,
std::vector<std::string> const& vec) -> std::string {
auto hasher = hash_function.MakeHasher();
for (auto const& s : vec) {
- hasher.Update(hash_function.ComputeHash(s).Bytes());
+ hasher.Update(hash_function.PlainHashData(s).Bytes());
}
return std::move(hasher).Finalize().Bytes();
}
@@ -207,7 +207,7 @@ auto BuildMaps::Target::Utils::createAction(
const ExpressionPtr& inputs_exp) -> ActionDescription::Ptr {
// 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};
+ HashFunction hash_function{HashFunction::Type::PlainSHA256};
auto hasher = hash_function.MakeHasher();
hasher.Update(hash_vector(hash_function, output_files));
diff --git a/src/buildtool/common/artifact_description.cpp b/src/buildtool/common/artifact_description.cpp
index 49a3afc7..6a0bf7de 100644
--- a/src/buildtool/common/artifact_description.cpp
+++ b/src/buildtool/common/artifact_description.cpp
@@ -196,8 +196,8 @@ auto ArtifactDescription::ComputeId(nlohmann::json const& desc) noexcept
try {
// The type of HashFunction is irrelevant here. It is used for
// identification and quick comparison of descriptions. SHA256 is used.
- return HashFunction{HashFunction::JustHash::Compatible}
- .ComputeHash(desc.dump())
+ return HashFunction{HashFunction::Type::PlainSHA256}
+ .PlainHashData(desc.dump())
.Bytes();
} catch (std::exception const& ex) {
Logger::Log(LogLevel::Error,
diff --git a/src/buildtool/common/artifact_digest.hpp b/src/buildtool/common/artifact_digest.hpp
index 1a620793..6b9ecb88 100644
--- a/src/buildtool/common/artifact_digest.hpp
+++ b/src/buildtool/common/artifact_digest.hpp
@@ -79,13 +79,13 @@ class ArtifactDigest {
-> ArtifactDigest {
if constexpr (kType == ObjectType::Tree) {
return ArtifactDigest{
- hash_function.ComputeTreeHash(content).HexString(),
+ hash_function.HashTreeData(content).HexString(),
content.size(),
/*is_tree=*/true};
}
else {
return ArtifactDigest{
- hash_function.ComputeBlobHash(content).HexString(),
+ hash_function.HashBlobData(content).HexString(),
content.size(),
/*is_tree=*/false};
}
diff --git a/src/buildtool/common/repository_config.cpp b/src/buildtool/common/repository_config.cpp
index 735e2c01..caf0d2bf 100644
--- a/src/buildtool/common/repository_config.cpp
+++ b/src/buildtool/common/repository_config.cpp
@@ -78,7 +78,7 @@ auto RepositoryConfig::DeduplicateRepo(std::string const& repo,
if (data.base_desc) {
// Use hash of content-fixed base description as content id
auto hash =
- hash_function.ComputeHash(data.base_desc->dump()).Bytes();
+ hash_function.PlainHashData(data.base_desc->dump()).Bytes();
// Add state with name, transitions, and content id
minimizer.AddState(repo, data.info.name_mapping, hash);
}
diff --git a/src/buildtool/common/tree.hpp b/src/buildtool/common/tree.hpp
index 2f33bfe0..53333901 100644
--- a/src/buildtool/common/tree.hpp
+++ b/src/buildtool/common/tree.hpp
@@ -87,8 +87,8 @@ class Tree {
static auto ComputeId(inputs_t const& inputs) -> std::string {
// The type of HashFunction is irrelevant here. It is used for
// identification of trees. SHA256 is used.
- HashFunction const hash_function{HashFunction::JustHash::Compatible};
- return hash_function.ComputeHash(ComputeDescription(inputs).dump())
+ HashFunction const hash_function{HashFunction::Type::PlainSHA256};
+ return hash_function.PlainHashData(ComputeDescription(inputs).dump())
.HexString();
}
};
diff --git a/src/buildtool/compatibility/compatibility.hpp b/src/buildtool/compatibility/compatibility.hpp
index 2073ad52..e276c562 100644
--- a/src/buildtool/compatibility/compatibility.hpp
+++ b/src/buildtool/compatibility/compatibility.hpp
@@ -55,8 +55,8 @@ class Compatibility {
}
}
// This is only used in compatible mode.
- HashFunction const hash_function{HashFunction::JustHash::Compatible};
- auto compatible_hash = hash_function.ComputeHash(data).HexString();
+ HashFunction const hash_function{HashFunction::Type::PlainSHA256};
+ auto compatible_hash = hash_function.PlainHashData(data).HexString();
std::unique_lock lock_{Instance().mutex_};
Instance().git_to_compatible_[git_hash] = compatible_hash;
Instance().compatible_to_git_[compatible_hash] = {git_hash, repo};
diff --git a/src/buildtool/crypto/hash_function.cpp b/src/buildtool/crypto/hash_function.cpp
index a759a0ce..6f240e50 100644
--- a/src/buildtool/crypto/hash_function.cpp
+++ b/src/buildtool/crypto/hash_function.cpp
@@ -31,17 +31,17 @@ namespace {
}
} // namespace
-auto HashFunction::ComputeBlobHash(std::string const& data) const noexcept
+auto HashFunction::HashBlobData(std::string const& data) const noexcept
-> Hasher::HashDigest {
return HashTaggedLine(data, CreateGitBlobTag);
}
-auto HashFunction::ComputeTreeHash(std::string const& data) const noexcept
+auto HashFunction::HashTreeData(std::string const& data) const noexcept
-> Hasher::HashDigest {
return HashTaggedLine(data, CreateGitTreeTag);
}
-auto HashFunction::ComputeHash(std::string const& data) const noexcept
+auto HashFunction::PlainHashData(std::string const& data) const noexcept
-> Hasher::HashDigest {
return HashTaggedLine(data, std::nullopt);
}
@@ -50,7 +50,7 @@ auto HashFunction::HashTaggedLine(std::string const& data,
std::optional<TagCreator> tag_creator)
const noexcept -> Hasher::HashDigest {
auto hasher = MakeHasher();
- if (type_ == JustHash::Native and tag_creator.has_value()) {
+ if (type_ == Type::GitSHA1 and tag_creator.has_value()) {
hasher.Update(std::invoke(*tag_creator, data.size()));
}
hasher.Update(data);
@@ -79,7 +79,7 @@ auto HashFunction::HashTaggedFile(std::filesystem::path const& path,
"An overflow will occur while reading");
auto hasher = MakeHasher();
- if (type_ == JustHash::Native) {
+ if (type_ == Type::GitSHA1) {
hasher.Update(std::invoke(tag_creator, size));
}
diff --git a/src/buildtool/crypto/hash_function.hpp b/src/buildtool/crypto/hash_function.hpp
index 99a15cdb..9e5a9c0b 100644
--- a/src/buildtool/crypto/hash_function.hpp
+++ b/src/buildtool/crypto/hash_function.hpp
@@ -28,12 +28,12 @@
/// \brief Hash function used for the entire buildtool.
class HashFunction {
public:
- enum class JustHash : std::uint8_t {
- Native, ///< SHA1 for plain hashes, and Git for blobs and trees.
- Compatible ///< SHA256 for all hashes.
+ enum class Type : std::uint8_t {
+ GitSHA1, ///< SHA1 for plain hashes, and Git for blobs and trees.
+ PlainSHA256 ///< SHA256 for all hashes.
};
- explicit HashFunction(JustHash type) noexcept : type_{type} {
+ explicit HashFunction(Type type) noexcept : type_{type} {
static_assert(
sizeof(HashFunction) <= sizeof(void*),
"HashFunction is passed and stored by value. If the "
@@ -41,20 +41,18 @@ class HashFunction {
"the way how HashFunction is passed and stored must be changed.");
}
- [[nodiscard]] auto GetHashType() const noexcept -> JustHash {
- return type_;
- }
+ [[nodiscard]] auto GetType() const noexcept -> Type { return type_; }
/// \brief Compute the blob hash of a string.
- [[nodiscard]] auto ComputeBlobHash(std::string const& data) const noexcept
+ [[nodiscard]] auto HashBlobData(std::string const& data) const noexcept
-> Hasher::HashDigest;
/// \brief Compute the tree hash of a string.
- [[nodiscard]] auto ComputeTreeHash(std::string const& data) const noexcept
+ [[nodiscard]] auto HashTreeData(std::string const& data) const noexcept
-> Hasher::HashDigest;
/// \brief Compute the plain hash of a string.
- [[nodiscard]] auto ComputeHash(std::string const& data) const noexcept
+ [[nodiscard]] auto PlainHashData(std::string const& data) const noexcept
-> Hasher::HashDigest;
/// \brief Compute the blob hash of a file or std::nullopt on IO error.
@@ -71,10 +69,10 @@ class HashFunction {
[[nodiscard]] auto MakeHasher() const noexcept -> Hasher {
std::optional<Hasher> hasher;
switch (type_) {
- case JustHash::Native:
+ case Type::GitSHA1:
hasher = Hasher::Create(Hasher::HashType::SHA1);
break;
- case JustHash::Compatible:
+ case Type::PlainSHA256:
hasher = Hasher::Create(Hasher::HashType::SHA256);
break;
}
@@ -83,7 +81,7 @@ class HashFunction {
}
private:
- JustHash const type_;
+ Type const type_;
using TagCreator = std::function<std::string(std::size_t)>;
diff --git a/src/buildtool/execution_api/bazel_msg/bazel_msg_factory.cpp b/src/buildtool/execution_api/bazel_msg/bazel_msg_factory.cpp
index aeb75540..09462bec 100644
--- a/src/buildtool/execution_api/bazel_msg/bazel_msg_factory.cpp
+++ b/src/buildtool/execution_api/bazel_msg/bazel_msg_factory.cpp
@@ -186,7 +186,7 @@ template <class T>
}
// SHA256 is used since bazel types are processed here.
- HashFunction const hash_function{HashFunction::JustHash::Compatible};
+ HashFunction const hash_function{HashFunction::Type::PlainSHA256};
auto digest =
ArtifactDigest::Create<ObjectType::File>(hash_function, *content);
diff --git a/src/buildtool/execution_api/common/execution_common.hpp b/src/buildtool/execution_api/common/execution_common.hpp
index b6bd1fa0..0cf0983d 100644
--- a/src/buildtool/execution_api/common/execution_common.hpp
+++ b/src/buildtool/execution_api/common/execution_common.hpp
@@ -107,9 +107,9 @@ static void EncodeUUIDVariant1(std::string* uuid) {
// The type of HashFunction is irrelevant here. It is used for
// identification purposes only. SHA256 is used.
- HashFunction const hash_function{HashFunction::JustHash::Compatible};
+ HashFunction const hash_function{HashFunction::Type::PlainSHA256};
auto value = fmt::format("{}-{}", std::to_string(kRandomConstant), seed);
- auto uuid = hash_function.ComputeHash(value).Bytes();
+ auto uuid = hash_function.PlainHashData(value).Bytes();
EncodeUUIDVersion4(&uuid);
EncodeUUIDVariant1(&uuid);
Expects(uuid.size() >= kRawLength);
diff --git a/src/buildtool/execution_api/common/tree_reader_utils.cpp b/src/buildtool/execution_api/common/tree_reader_utils.cpp
index acd24108..0573d89e 100644
--- a/src/buildtool/execution_api/common/tree_reader_utils.cpp
+++ b/src/buildtool/execution_api/common/tree_reader_utils.cpp
@@ -91,7 +91,7 @@ auto TreeReaderUtils::ReadObjectInfos(bazel_re::Directory const& dir,
}
// SHA256 is used since bazel types are processed here.
- HashFunction const hash_function{HashFunction::JustHash::Compatible};
+ HashFunction const hash_function{HashFunction::Type::PlainSHA256};
for (auto const& l : dir.symlinks()) {
if (not store_info(l.name(), CreateObjectInfo(l, hash_function))) {
return false;
diff --git a/src/buildtool/execution_api/git/git_api.hpp b/src/buildtool/execution_api/git/git_api.hpp
index 470dca41..139291ef 100644
--- a/src/buildtool/execution_api/git/git_api.hpp
+++ b/src/buildtool/execution_api/git/git_api.hpp
@@ -196,7 +196,7 @@ class GitApi final : public IExecutionApi {
}
// GitApi works in the native mode only.
- HashFunction const hash_function{HashFunction::JustHash::Native};
+ HashFunction const hash_function{HashFunction::Type::GitSHA1};
// Collect blobs of missing artifacts from local CAS. Trees are
// processed recursively before any blob is uploaded.
diff --git a/src/buildtool/execution_api/local/local_cas_reader.cpp b/src/buildtool/execution_api/local/local_cas_reader.cpp
index 397c02ad..fd7ede7f 100644
--- a/src/buildtool/execution_api/local/local_cas_reader.cpp
+++ b/src/buildtool/execution_api/local/local_cas_reader.cpp
@@ -60,10 +60,10 @@ auto LocalCasReader::ReadGitTree(ArtifactDigest const& digest) const noexcept
};
// Git-SHA1 hashing is used for reading from git.
- HashFunction const hash_function{HashFunction::JustHash::Native};
+ HashFunction const hash_function{HashFunction::Type::GitSHA1};
return GitRepo::ReadTreeData(
*content,
- hash_function.ComputeTreeHash(*content).Bytes(),
+ hash_function.HashTreeData(*content).Bytes(),
check_symlinks,
/*is_hex_id=*/false);
}
diff --git a/src/buildtool/execution_api/remote/bazel/bazel_cas_client.cpp b/src/buildtool/execution_api/remote/bazel/bazel_cas_client.cpp
index 0c0bb433..28400a51 100644
--- a/src/buildtool/execution_api/remote/bazel/bazel_cas_client.cpp
+++ b/src/buildtool/execution_api/remote/bazel/bazel_cas_client.cpp
@@ -54,9 +54,9 @@ namespace {
// Create empty blob.
std::string empty_str{};
HashFunction const hash_function{Compatibility::IsCompatible()
- ? HashFunction::JustHash::Compatible
- : HashFunction::JustHash::Native};
- std::string hash = hash_function.ComputeBlobHash(empty_str).HexString();
+ ? HashFunction::Type::PlainSHA256
+ : HashFunction::Type::GitSHA1};
+ std::string hash = hash_function.HashBlobData(empty_str).HexString();
bazel_re::Digest digest{};
digest.set_hash(NativeSupport::Prefix(hash, false));
digest.set_size_bytes(empty_str.size());
@@ -122,9 +122,9 @@ namespace {
// Create empty blob.
std::string empty_str{};
HashFunction const hash_function{Compatibility::IsCompatible()
- ? HashFunction::JustHash::Compatible
- : HashFunction::JustHash::Native};
- std::string hash = hash_function.ComputeBlobHash(empty_str).HexString();
+ ? HashFunction::Type::PlainSHA256
+ : HashFunction::Type::GitSHA1};
+ std::string hash = hash_function.HashBlobData(empty_str).HexString();
bazel_re::Digest digest{};
digest.set_hash(NativeSupport::Prefix(hash, false));
digest.set_size_bytes(empty_str.size());
diff --git a/src/buildtool/execution_api/remote/bazel/bazel_network_reader.cpp b/src/buildtool/execution_api/remote/bazel/bazel_network_reader.cpp
index 8416189b..690a1278 100644
--- a/src/buildtool/execution_api/remote/bazel/bazel_network_reader.cpp
+++ b/src/buildtool/execution_api/remote/bazel/bazel_network_reader.cpp
@@ -67,8 +67,7 @@ auto BazelNetworkReader::ReadDirectory(ArtifactDigest const& digest)
auto BazelNetworkReader::ReadGitTree(ArtifactDigest const& digest)
const noexcept -> std::optional<GitRepo::tree_entries_t> {
- ExpectsAudit(hash_function_.GetHashType() ==
- HashFunction::JustHash::Native);
+ ExpectsAudit(hash_function_.GetType() == HashFunction::Type::GitSHA1);
auto read_blob = ReadSingleBlob(digest);
if (not read_blob) {
@@ -97,11 +96,10 @@ auto BazelNetworkReader::ReadGitTree(ArtifactDigest const& digest)
};
std::string const& content = *read_blob->data;
- return GitRepo::ReadTreeData(
- content,
- hash_function_.ComputeTreeHash(content).Bytes(),
- check_symlinks,
- /*is_hex_id=*/false);
+ return GitRepo::ReadTreeData(content,
+ hash_function_.HashTreeData(content).Bytes(),
+ check_symlinks,
+ /*is_hex_id=*/false);
}
auto BazelNetworkReader::DumpRawTree(Artifact::ObjectInfo const& info,
@@ -142,8 +140,7 @@ auto BazelNetworkReader::DumpBlob(Artifact::ObjectInfo const& info,
auto BazelNetworkReader::MakeAuxiliaryMap(
std::vector<bazel_re::Directory>&& full_tree) const noexcept
-> std::optional<DirectoryMap> {
- ExpectsAudit(hash_function_.GetHashType() ==
- HashFunction::JustHash::Compatible);
+ ExpectsAudit(hash_function_.GetType() == HashFunction::Type::PlainSHA256);
DirectoryMap result;
result.reserve(full_tree.size());
diff --git a/src/buildtool/execution_api/utils/subobject.cpp b/src/buildtool/execution_api/utils/subobject.cpp
index aa41b5da..380fe65f 100644
--- a/src/buildtool/execution_api/utils/subobject.cpp
+++ b/src/buildtool/execution_api/utils/subobject.cpp
@@ -76,8 +76,8 @@ auto RetrieveSubPathId(Artifact::ObjectInfo object_info,
object_info = *new_object_info;
}
else {
- auto const hash = HashFunction{HashFunction::JustHash::Native}
- .ComputeTreeHash(*data)
+ auto const hash = HashFunction{HashFunction::Type::GitSHA1}
+ .HashTreeData(*data)
.Bytes();
auto entries = GitRepo::ReadTreeData(
*data,
diff --git a/src/buildtool/main/install_cas.cpp b/src/buildtool/main/install_cas.cpp
index 3c460200..024d22c7 100644
--- a/src/buildtool/main/install_cas.cpp
+++ b/src/buildtool/main/install_cas.cpp
@@ -35,7 +35,7 @@ namespace {
// Only in compatible mode the size is checked, so an empty SHA256 hash is
// needed.
static auto const kEmptyHash =
- HashFunction{HashFunction::JustHash::Compatible}.ComputeBlobHash("");
+ HashFunction{HashFunction::Type::PlainSHA256}.HashBlobData("");
return Compatibility::IsCompatible() and // native mode is fine
(size_str == "0" or size_str.empty()) and // not "0" or "" is fine
kEmptyHash.HexString() != hash and // empty hash is fine
diff --git a/src/buildtool/main/main.cpp b/src/buildtool/main/main.cpp
index b089e321..08864e96 100644
--- a/src/buildtool/main/main.cpp
+++ b/src/buildtool/main/main.cpp
@@ -122,8 +122,8 @@ void SetupLogging(LogArguments const& clargs) {
auto config =
builder
- .SetHashType(is_compatible ? HashFunction::JustHash::Compatible
- : HashFunction::JustHash::Native)
+ .SetHashType(is_compatible ? HashFunction::Type::PlainSHA256
+ : HashFunction::Type::GitSHA1)
.SetRemoteExecutionArgs(
remote_address, remote_platform_properties, remote_dispatch)
.Build();
diff --git a/src/buildtool/serve_api/serve_service/source_tree.cpp b/src/buildtool/serve_api/serve_service/source_tree.cpp
index 6feb9288..511acfd3 100644
--- a/src/buildtool/serve_api/serve_service/source_tree.cpp
+++ b/src/buildtool/serve_api/serve_service/source_tree.cpp
@@ -1159,8 +1159,8 @@ auto SourceTreeService::ServeDistdirTree(
kv.name(), std::make_pair(blob_digest, kv.executable()));
}
// get hash of distdir content; this must match with that in just-mr
- auto content_id = HashFunction{HashFunction::JustHash::Native}
- .ComputeBlobHash(nlohmann::json(content_list).dump())
+ auto content_id = HashFunction{HashFunction::Type::GitSHA1}
+ .HashBlobData(nlohmann::json(content_list).dump())
.HexString();
// create in-memory tree of the distdir, now that we know we have all blobs
auto tree = GitRepo::CreateShallowTree(entries);
diff --git a/src/buildtool/storage/config.hpp b/src/buildtool/storage/config.hpp
index 56274c02..0841f9d5 100644
--- a/src/buildtool/storage/config.hpp
+++ b/src/buildtool/storage/config.hpp
@@ -65,7 +65,7 @@ struct StorageConfig final {
// Number of total storage generations (default: two generations).
std::size_t const num_generations = 2;
- HashFunction const hash_function{HashFunction::JustHash::Native};
+ HashFunction const hash_function{HashFunction::Type::GitSHA1};
// Hash of the execution backend description
std::string const backend_description_id = DefaultBackendDescriptionId();
@@ -182,7 +182,7 @@ class StorageConfig::Builder final {
}
/// \brief Specify the type of the hash function
- auto SetHashType(HashFunction::JustHash value) noexcept -> Builder& {
+ auto SetHashType(HashFunction::Type value) noexcept -> Builder& {
hash_type_ = value;
return *this;
}
@@ -249,7 +249,7 @@ class StorageConfig::Builder final {
private:
std::optional<std::filesystem::path> build_root_;
std::optional<std::size_t> num_generations_;
- std::optional<HashFunction::JustHash> hash_type_;
+ std::optional<HashFunction::Type> hash_type_;
// Fields for computing remote execution backend description
std::optional<ServerAddress> remote_address_;
diff --git a/src/buildtool/storage/fs_utils.cpp b/src/buildtool/storage/fs_utils.cpp
index 05d6bbb8..62adf1e9 100644
--- a/src/buildtool/storage/fs_utils.cpp
+++ b/src/buildtool/storage/fs_utils.cpp
@@ -77,7 +77,7 @@ auto GetForeignFileTreeIDFile(StorageConfig const& storage_config,
return GetDistdirTreeIDFile(
storage_config,
storage_config.hash_function
- .ComputeBlobHash(
+ .HashBlobData(
nlohmann::json(std::unordered_map<std::string,
std::pair<std::string, bool>>{
{name, {content, executable}}})
diff --git a/src/buildtool/storage/garbage_collector.cpp b/src/buildtool/storage/garbage_collector.cpp
index b03364f8..a108ae73 100644
--- a/src/buildtool/storage/garbage_collector.cpp
+++ b/src/buildtool/storage/garbage_collector.cpp
@@ -220,8 +220,8 @@ auto GarbageCollector::Compactify(StorageConfig const& storage_config,
});
auto compactify = [threshold](StorageConfig const& config) -> bool {
- Compatibility::SetCompatible(config.hash_function.GetHashType() ==
- HashFunction::JustHash::Compatible);
+ Compatibility::SetCompatible(config.hash_function.GetType() ==
+ HashFunction::Type::PlainSHA256);
auto const storage = ::Generation::Create(&config);
return Compactifier::RemoveInvalid(storage.CAS()) and
@@ -230,19 +230,19 @@ auto GarbageCollector::Compactify(StorageConfig const& storage_config,
};
// Compactification must be done for both native and compatible storages.
- static constexpr std::array kHashes = {HashFunction::JustHash::Native,
- HashFunction::JustHash::Compatible};
+ static constexpr std::array kHashes = {HashFunction::Type::GitSHA1,
+ HashFunction::Type::PlainSHA256};
auto builder = StorageConfig::Builder{}
.SetBuildRoot(storage_config.build_root)
.SetNumGenerations(storage_config.num_generations);
- return std::all_of(
- kHashes.begin(),
- kHashes.end(),
- [&builder, &compactify](HashFunction::JustHash hash_type) {
- auto const config = builder.SetHashType(hash_type).Build();
- return config.has_value() and compactify(*config);
- });
+ return std::all_of(kHashes.begin(),
+ kHashes.end(),
+ [&builder, &compactify](HashFunction::Type hash_type) {
+ auto const config =
+ builder.SetHashType(hash_type).Build();
+ return config.has_value() and compactify(*config);
+ });
}
#endif // BOOTSTRAP_BUILD_TOOL
diff --git a/src/other_tools/just_mr/main.cpp b/src/other_tools/just_mr/main.cpp
index 698a6ccb..24bf8ffd 100644
--- a/src/other_tools/just_mr/main.cpp
+++ b/src/other_tools/just_mr/main.cpp
@@ -214,8 +214,8 @@ void SetupLogging(MultiRepoLogArguments const& clargs) {
if (args.just_mr_paths->root.has_value()) {
builder.SetBuildRoot(*args.just_mr_paths->root);
}
- builder.SetHashType(is_compatible ? HashFunction::JustHash::Compatible
- : HashFunction::JustHash::Native);
+ builder.SetHashType(is_compatible ? HashFunction::Type::PlainSHA256
+ : HashFunction::Type::GitSHA1);
// As just-mr does not require the TargetCache, we do not need to set any of
// the remote execution fields for the backend description.
diff --git a/src/other_tools/repo_map/repos_to_setup_map.cpp b/src/other_tools/repo_map/repos_to_setup_map.cpp
index 5bcfd717..cb6a0149 100644
--- a/src/other_tools/repo_map/repos_to_setup_map.cpp
+++ b/src/other_tools/repo_map/repos_to_setup_map.cpp
@@ -592,8 +592,8 @@ void DistdirCheckout(ExpressionPtr const& repo_desc,
}
// get hash of distdir content
auto distdir_content_id =
- HashFunction{HashFunction::JustHash::Native}
- .ComputeBlobHash(nlohmann::json(*distdir_content_for_id).dump())
+ HashFunction{HashFunction::Type::GitSHA1}
+ .HashBlobData(nlohmann::json(*distdir_content_for_id).dump())
.HexString();
// get the WS root as git tree
DistdirInfo distdir_info = {