summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaksim Denisov <denisov.maksim@huawei.com>2025-01-02 14:03:44 +0100
committerMaksim Denisov <denisov.maksim@huawei.com>2025-01-07 14:18:09 +0100
commit4618817981165d08120749589d1c1457668bb547 (patch)
tree0405d1637656c0691af40315e8a9d57d1fa8b8b9 /src
parentfd7d5ebd03e51f3860bad7b4bd102fe1a47de589 (diff)
downloadjustbuild-4618817981165d08120749589d1c1457668bb547.tar.gz
Store BackendDescription in StorageConfig
...instead of a plain hash. Hash gets computed for different storage types on the fly.
Diffstat (limited to 'src')
-rw-r--r--src/buildtool/storage/TARGETS6
-rw-r--r--src/buildtool/storage/config.hpp20
-rw-r--r--src/buildtool/storage/target_cache.hpp5
3 files changed, 10 insertions, 21 deletions
diff --git a/src/buildtool/storage/TARGETS b/src/buildtool/storage/TARGETS
index 8358825d..0a841c48 100644
--- a/src/buildtool/storage/TARGETS
+++ b/src/buildtool/storage/TARGETS
@@ -6,12 +6,9 @@
[ "backend_description"
, ["@", "fmt", "", "fmt"]
, ["@", "gsl", "", "gsl"]
- , ["src/buildtool/common", "artifact_digest_factory"]
- , ["src/buildtool/common", "common"]
, ["src/buildtool/common", "protocol_traits"]
, ["src/buildtool/crypto", "hash_function"]
, ["src/buildtool/file_system", "file_system_manager"]
- , ["src/buildtool/file_system", "object_type"]
, ["src/utils/cpp", "expected"]
, ["src/utils/cpp", "gsl"]
, ["src/utils/cpp", "tmp_dir"]
@@ -51,7 +48,8 @@
]
, "srcs": ["target_cache_entry.cpp", "uplinker.cpp"]
, "deps":
- [ "config"
+ [ "backend_description"
+ , "config"
, "file_chunker"
, ["@", "fmt", "", "fmt"]
, ["@", "gsl", "", "gsl"]
diff --git a/src/buildtool/storage/config.hpp b/src/buildtool/storage/config.hpp
index 493c00b2..a5d96e90 100644
--- a/src/buildtool/storage/config.hpp
+++ b/src/buildtool/storage/config.hpp
@@ -23,12 +23,9 @@
#include "fmt/core.h"
#include "gsl/gsl"
-#include "src/buildtool/common/artifact_digest.hpp"
-#include "src/buildtool/common/artifact_digest_factory.hpp"
#include "src/buildtool/common/protocol_traits.hpp"
#include "src/buildtool/crypto/hash_function.hpp"
#include "src/buildtool/file_system/file_system_manager.hpp"
-#include "src/buildtool/file_system/object_type.hpp"
#include "src/buildtool/storage/backend_description.hpp"
#include "src/utils/cpp/expected.hpp"
#include "src/utils/cpp/gsl.hpp"
@@ -65,7 +62,7 @@ struct StorageConfig final {
HashFunction const hash_function{HashFunction::Type::GitSHA1};
// Hash of the execution backend description
- std::string const backend_description_id = DefaultBackendDescriptionId();
+ BackendDescription const backend_description;
/// \brief Root directory of all storage generations.
[[nodiscard]] auto CacheRoot() const noexcept -> std::filesystem::path {
@@ -150,12 +147,6 @@ struct StorageConfig final {
bool is_native) -> std::filesystem::path {
return dir / (is_native ? "git-sha1" : "compatible-sha256");
};
-
- [[nodiscard]] auto DefaultBackendDescriptionId() noexcept -> std::string {
- return ArtifactDigestFactory::HashDataAs<ObjectType::File>(
- hash_function, BackendDescription{}.GetDescription())
- .hash();
- }
};
class StorageConfig::Builder final {
@@ -212,19 +203,16 @@ class StorageConfig::Builder final {
: default_config.hash_function;
// Hash the execution backend description
- auto backend_description_id = default_config.backend_description_id;
+ auto backend_description = default_config.backend_description;
if (backend_description_) {
- backend_description_id =
- ArtifactDigestFactory::HashDataAs<ObjectType::File>(
- hash_function, backend_description_->GetDescription())
- .hash();
+ backend_description = *backend_description_;
}
return StorageConfig{
.build_root = std::move(build_root),
.num_generations = num_generations,
.hash_function = hash_function,
- .backend_description_id = std::move(backend_description_id)};
+ .backend_description = std::move(backend_description)};
}
private:
diff --git a/src/buildtool/storage/target_cache.hpp b/src/buildtool/storage/target_cache.hpp
index 5fadabec..08dc498c 100644
--- a/src/buildtool/storage/target_cache.hpp
+++ b/src/buildtool/storage/target_cache.hpp
@@ -31,6 +31,7 @@
#include "src/buildtool/file_system/file_storage.hpp"
#include "src/buildtool/file_system/object_type.hpp"
#include "src/buildtool/logging/logger.hpp"
+#include "src/buildtool/storage/backend_description.hpp"
#include "src/buildtool/storage/config.hpp"
#include "src/buildtool/storage/local_cas.hpp"
#include "src/buildtool/storage/target_cache_entry.hpp"
@@ -59,7 +60,9 @@ class TargetCache {
: TargetCache(cas,
config.target_cache,
uplinker,
- config.storage_config->backend_description_id) {}
+ config.storage_config->backend_description
+ .HashContent(cas->GetHashFunction())
+ .hash()) {}
/// \brief Returns a new TargetCache backed by the same CAS, but the
/// FileStorage uses the given \p backend_description 's hash. This is