diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/buildtool/build_engine/target_map/absent_target_map.cpp | 9 | ||||
-rw-r--r-- | src/buildtool/build_engine/target_map/export.cpp | 7 | ||||
-rw-r--r-- | src/buildtool/common/TARGETS | 6 | ||||
-rw-r--r-- | src/buildtool/common/repository_config.cpp | 8 | ||||
-rw-r--r-- | src/buildtool/common/repository_config.hpp | 4 | ||||
-rw-r--r-- | src/buildtool/main/analyse_context.hpp | 4 | ||||
-rw-r--r-- | src/buildtool/main/main.cpp | 11 | ||||
-rw-r--r-- | src/buildtool/serve_api/serve_service/target.cpp | 3 |
8 files changed, 28 insertions, 24 deletions
diff --git a/src/buildtool/build_engine/target_map/absent_target_map.cpp b/src/buildtool/build_engine/target_map/absent_target_map.cpp index 017d25c5..3c886586 100644 --- a/src/buildtool/build_engine/target_map/absent_target_map.cpp +++ b/src/buildtool/build_engine/target_map/absent_target_map.cpp @@ -24,6 +24,7 @@ #include "src/buildtool/logging/logger.hpp" #include "src/buildtool/progress_reporting/progress.hpp" #include "src/buildtool/serve_api/remote/serve_api.hpp" +#include "src/buildtool/storage/storage.hpp" #include "src/buildtool/storage/target_cache.hpp" #include "src/buildtool/storage/target_cache_key.hpp" #include "src/utils/cpp/json.hpp" @@ -57,14 +58,15 @@ void WithFlexibleVariables( // TODO(asartori): avoid code duplication in export.cpp context->statistics->IncrementExportsFoundCounter(); auto target_name = key.target.GetNamedTarget(); - auto repo_key = context->repo_config->RepositoryKey(target_name.repository); + auto repo_key = context->repo_config->RepositoryKey(*context->storage, + target_name.repository); if (!repo_key) { (*logger)(fmt::format("Failed to obtain repository key for repo \"{}\"", target_name.repository), /*fatal=*/true); return; } - auto target_cache_key = context->target_cache->ComputeKey( + auto target_cache_key = context->storage->TargetCache().ComputeKey( *repo_key, target_name, effective_config); if (not target_cache_key) { (*logger)(fmt::format("Could not produce cache key for target {}", @@ -74,7 +76,8 @@ void WithFlexibleVariables( } std::optional<std::pair<TargetCacheEntry, Artifact::ObjectInfo>> target_cache_value{std::nullopt}; - target_cache_value = context->target_cache->Read(*target_cache_key); + target_cache_value = + context->storage->TargetCache().Read(*target_cache_key); bool from_just_serve = false; if (not target_cache_value and context->serve != nullptr) { auto task = fmt::format("[{},{}]", diff --git a/src/buildtool/build_engine/target_map/export.cpp b/src/buildtool/build_engine/target_map/export.cpp index 2d92bed6..23ffe641 100644 --- a/src/buildtool/build_engine/target_map/export.cpp +++ b/src/buildtool/build_engine/target_map/export.cpp @@ -129,16 +129,17 @@ void ExportRule( } context->statistics->IncrementExportsFoundCounter(); auto const& target_name = key.target.GetNamedTarget(); - auto repo_key = context->repo_config->RepositoryKey(target_name.repository); + auto repo_key = context->repo_config->RepositoryKey(*context->storage, + target_name.repository); auto target_cache_key = repo_key - ? context->target_cache->ComputeKey( + ? context->storage->TargetCache().ComputeKey( *repo_key, target_name, effective_config) : std::nullopt; if (target_cache_key) { // first try to get value from local target cache auto target_cache_value = - context->target_cache->Read(*target_cache_key); + context->storage->TargetCache().Read(*target_cache_key); bool from_just_serve{false}; #ifndef BOOTSTRAP_BUILD_TOOL diff --git a/src/buildtool/common/TARGETS b/src/buildtool/common/TARGETS index be4246f0..d8f48a8e 100644 --- a/src/buildtool/common/TARGETS +++ b/src/buildtool/common/TARGETS @@ -127,12 +127,10 @@ , ["src/buildtool/file_system", "file_root"] , ["src/buildtool/file_system", "git_cas"] , ["src/buildtool/multithreading", "atomic_value"] - ] - , "stage": ["src", "buildtool", "common"] - , "private-deps": - [ ["src/utils/automata", "dfa_minimizer"] , ["src/buildtool/storage", "storage"] ] + , "stage": ["src", "buildtool", "common"] + , "private-deps": [["src/utils/automata", "dfa_minimizer"]] } , "user_structs": { "type": ["@", "rules", "CC", "library"] diff --git a/src/buildtool/common/repository_config.cpp b/src/buildtool/common/repository_config.cpp index a3b81de1..d26ba55b 100644 --- a/src/buildtool/common/repository_config.cpp +++ b/src/buildtool/common/repository_config.cpp @@ -14,7 +14,6 @@ #include "src/buildtool/common/repository_config.hpp" -#include "src/buildtool/storage/storage.hpp" #include "src/utils/automata/dfa_minimizer.hpp" auto RepositoryConfig::RepositoryInfo::BaseContentDescription() const @@ -35,15 +34,16 @@ auto RepositoryConfig::RepositoryInfo::BaseContentDescription() const return std::nullopt; } -auto RepositoryConfig::RepositoryKey(std::string const& repo) const noexcept +auto RepositoryConfig::RepositoryKey(Storage const& storage, + std::string const& repo) const noexcept -> std::optional<std::string> { auto const& unique = DeduplicateRepo(repo); if (auto const* data = Data(unique)) { // compute key only once (thread-safe) return data->key.SetOnceAndGet( - [this, &unique]() -> std::optional<std::string> { + [this, &storage, &unique]() -> std::optional<std::string> { if (auto graph = BuildGraphForRepository(unique)) { - auto const& cas = Storage::Instance().CAS(); + auto const& cas = storage.CAS(); if (auto digest = cas.StoreBlob(graph->dump(2))) { return ArtifactDigest{*digest}.hash(); } diff --git a/src/buildtool/common/repository_config.hpp b/src/buildtool/common/repository_config.hpp index ea463d43..8c5c29a5 100644 --- a/src/buildtool/common/repository_config.hpp +++ b/src/buildtool/common/repository_config.hpp @@ -28,6 +28,7 @@ #include "src/buildtool/file_system/file_root.hpp" #include "src/buildtool/file_system/git_cas.hpp" #include "src/buildtool/multithreading/atomic_value.hpp" +#include "src/buildtool/storage/storage.hpp" class RepositoryConfig { @@ -136,7 +137,8 @@ class RepositoryConfig { // Obtain repository's cache key if the repository is content fixed or // std::nullopt otherwise. - [[nodiscard]] auto RepositoryKey(std::string const& repo) const noexcept + [[nodiscard]] auto RepositoryKey(Storage const& storage, + std::string const& repo) const noexcept -> std::optional<std::string>; // used for testing diff --git a/src/buildtool/main/analyse_context.hpp b/src/buildtool/main/analyse_context.hpp index 9999ae43..4fe7381e 100644 --- a/src/buildtool/main/analyse_context.hpp +++ b/src/buildtool/main/analyse_context.hpp @@ -20,11 +20,11 @@ #include "src/buildtool/common/statistics.hpp" #include "src/buildtool/progress_reporting/progress.hpp" #include "src/buildtool/serve_api/remote/serve_api.hpp" -#include "src/buildtool/storage/target_cache.hpp" +#include "src/buildtool/storage/storage.hpp" struct AnalyseContext final { gsl::not_null<RepositoryConfig const*> const repo_config; - gsl::not_null<ActiveTargetCache const*> const target_cache; + gsl::not_null<Storage const*> const storage; gsl::not_null<Statistics*> const statistics; gsl::not_null<Progress*> const progress; ServeApi const* const serve = nullptr; diff --git a/src/buildtool/main/main.cpp b/src/buildtool/main/main.cpp index 878cfc50..293c8002 100644 --- a/src/buildtool/main/main.cpp +++ b/src/buildtool/main/main.cpp @@ -991,12 +991,11 @@ auto main(int argc, char* argv[]) -> int { // create progress tracker for export targets Progress exports_progress{}; - AnalyseContext analyse_ctx{ - .repo_config = &repo_config, - .target_cache = &Storage::Instance().TargetCache(), - .statistics = &stats, - .progress = &exports_progress, - .serve = serve ? &*serve : nullptr}; + AnalyseContext analyse_ctx{.repo_config = &repo_config, + .storage = &Storage::Instance(), + .statistics = &stats, + .progress = &exports_progress, + .serve = serve ? &*serve : nullptr}; auto result = AnalyseTarget(&analyse_ctx, id, diff --git a/src/buildtool/serve_api/serve_service/target.cpp b/src/buildtool/serve_api/serve_service/target.cpp index 727751f4..ec86bf47 100644 --- a/src/buildtool/serve_api/serve_service/target.cpp +++ b/src/buildtool/serve_api/serve_service/target.cpp @@ -39,6 +39,7 @@ #include "src/buildtool/progress_reporting/progress.hpp" #include "src/buildtool/progress_reporting/progress_reporter.hpp" #include "src/buildtool/serve_api/serve_service/target_utils.hpp" +#include "src/buildtool/storage/garbage_collector.hpp" #include "src/buildtool/storage/target_cache_key.hpp" #include "src/utils/cpp/verify_hash.hpp" @@ -443,7 +444,7 @@ auto TargetService::ServeTarget( Logger logger{"serve-target", {LogSinkFile::CreateFactory(tmp_log)}}; AnalyseContext analyse_ctx{.repo_config = &repository_config, - .target_cache = &tc, + .storage = &storage_, .statistics = &stats, .progress = &progress, .serve = serve_}; |