diff options
author | Maksim Denisov <denisov.maksim@huawei.com> | 2025-02-14 15:16:10 +0100 |
---|---|---|
committer | Maksim Denisov <denisov.maksim@huawei.com> | 2025-02-19 17:50:30 +0100 |
commit | 8ab573ef1c624e2ed81b2032178c25451176d2f1 (patch) | |
tree | b3e41ee30eed3240bcd18502b7972903e7c2a53e /src/buildtool/main | |
parent | dfa481bd5f97d92c444dc31a4a051cb890494d1d (diff) | |
download | justbuild-8ab573ef1c624e2ed81b2032178c25451176d2f1.tar.gz |
ApiBundle: Remove HashFunction.
And ensure every user obtains HashFunction from corresponding IExecutionApi
Diffstat (limited to 'src/buildtool/main')
-rw-r--r-- | src/buildtool/main/TARGETS | 2 | ||||
-rw-r--r-- | src/buildtool/main/archive.cpp | 21 | ||||
-rw-r--r-- | src/buildtool/main/archive.hpp | 2 | ||||
-rw-r--r-- | src/buildtool/main/build_utils.cpp | 3 | ||||
-rw-r--r-- | src/buildtool/main/install_cas.cpp | 5 |
5 files changed, 12 insertions, 21 deletions
diff --git a/src/buildtool/main/TARGETS b/src/buildtool/main/TARGETS index 5662580c..44440484 100644 --- a/src/buildtool/main/TARGETS +++ b/src/buildtool/main/TARGETS @@ -369,7 +369,6 @@ [ ["@", "fmt", "", "fmt"] , ["src/buildtool/build_engine/expression", "expression"] , ["src/buildtool/build_engine/expression", "expression_ptr_interface"] - , ["src/buildtool/crypto", "hash_function"] , ["src/buildtool/execution_api/common", "common"] , ["src/buildtool/multithreading", "async_map_utils"] , ["src/buildtool/multithreading", "task_system"] @@ -382,7 +381,6 @@ , "srcs": ["archive.cpp"] , "deps": [ ["src/buildtool/common", "common"] - , ["src/buildtool/crypto", "hash_function"] , ["src/buildtool/execution_api/common", "common"] ] , "stage": ["src", "buildtool", "main"] diff --git a/src/buildtool/main/archive.cpp b/src/buildtool/main/archive.cpp index 2d8c95db..017aaaeb 100644 --- a/src/buildtool/main/archive.cpp +++ b/src/buildtool/main/archive.cpp @@ -59,8 +59,7 @@ void archive_entry_cleanup(archive_entry* entry) { } } -auto add_to_archive(HashFunction::Type hash_type, - archive* archive, +auto add_to_archive(archive* archive, IExecutionApi const& api, const Artifact::ObjectInfo& artifact, const std::filesystem::path& location) -> bool { @@ -134,8 +133,11 @@ auto add_to_archive(HashFunction::Type hash_type, for (auto const& [hash, entries] : *git_tree) { auto hex_hash = ToHexString(hash); for (auto const& entry : entries) { - auto digest = ArtifactDigestFactory::Create( - hash_type, hex_hash, 0, IsTreeObject(entry.type)); + auto digest = + ArtifactDigestFactory::Create(api.GetHashType(), + hex_hash, + 0, + IsTreeObject(entry.type)); if (not digest) { return false; } @@ -146,8 +148,7 @@ auto add_to_archive(HashFunction::Type hash_type, } } for (auto const& [name, obj] : tree) { - if (not add_to_archive( - hash_type, archive, api, obj, location / name)) { + if (not add_to_archive(archive, api, obj, location / name)) { return false; } } @@ -160,7 +161,6 @@ auto add_to_archive(HashFunction::Type hash_type, } // namespace [[nodiscard]] auto GenerateArchive( - HashFunction::Type hash_type, IExecutionApi const& api, const Artifact::ObjectInfo& artifact, const std::optional<std::filesystem::path>& output_path) -> bool { @@ -204,11 +204,8 @@ auto add_to_archive(HashFunction::Type hash_type, } } - if (not add_to_archive(hash_type, - archive.get(), - api, - artifact, - std::filesystem::path{""})) { + if (not add_to_archive( + archive.get(), api, artifact, std::filesystem::path{""})) { return false; } if (output_path) { diff --git a/src/buildtool/main/archive.hpp b/src/buildtool/main/archive.hpp index da61a5c3..ff23c65e 100644 --- a/src/buildtool/main/archive.hpp +++ b/src/buildtool/main/archive.hpp @@ -21,11 +21,9 @@ #include <optional> #include "src/buildtool/common/artifact.hpp" -#include "src/buildtool/crypto/hash_function.hpp" #include "src/buildtool/execution_api/common/execution_api.hpp" [[nodiscard]] auto GenerateArchive( - HashFunction::Type hash_type, IExecutionApi const& api, const Artifact::ObjectInfo& artifact, const std::optional<std::filesystem::path>& output_path) -> bool; diff --git a/src/buildtool/main/build_utils.cpp b/src/buildtool/main/build_utils.cpp index e7787af3..3b919ade 100644 --- a/src/buildtool/main/build_utils.cpp +++ b/src/buildtool/main/build_utils.cpp @@ -22,7 +22,6 @@ #include "src/buildtool/build_engine/expression/expression.hpp" #include "src/buildtool/build_engine/expression/expression_ptr.hpp" #ifndef BOOTSTRAP_BUILD_TOOL -#include "src/buildtool/crypto/hash_function.hpp" #include "src/buildtool/execution_api/common/execution_api.hpp" #include "src/buildtool/logging/log_level.hpp" #include "src/buildtool/multithreading/async_map_utils.hpp" @@ -106,7 +105,7 @@ auto CreateTargetCacheWriterMap( } auto const& target = cache_targets.at(tc_key); auto entry = TargetCacheEntry::FromTarget( - apis->hash_function.GetType(), target, extra_infos); + apis->remote->GetHashType(), target, extra_infos); if (not entry) { (*logger)( fmt::format("Failed creating target cache entry for key {}", diff --git a/src/buildtool/main/install_cas.cpp b/src/buildtool/main/install_cas.cpp index 8f7f9d65..782a0422 100644 --- a/src/buildtool/main/install_cas.cpp +++ b/src/buildtool/main/install_cas.cpp @@ -105,7 +105,7 @@ auto FetchAndInstallArtifacts(ApiBundle const& apis, FetchArguments const& clargs, RemoteContext const& remote_context) -> bool { auto object_info = ObjectInfoFromLiberalString( - apis.hash_function.GetType(), + apis.remote->GetHashType(), clargs.object_id, remote_context.exec_config->remote_address.has_value()); if (not object_info) { @@ -156,8 +156,7 @@ auto FetchAndInstallArtifacts(ApiBundle const& apis, object_info->ToString()); return false; } - return GenerateArchive( - apis.hash_function.GetType(), *apis.remote, *object_info, out); + return GenerateArchive(*apis.remote, *object_info, out); } if (out) { |