diff options
author | Oliver Reiche <oliver.reiche@huawei.com> | 2023-03-07 15:35:10 +0100 |
---|---|---|
committer | Oliver Reiche <oliver.reiche@huawei.com> | 2023-03-13 17:28:59 +0100 |
commit | 600876757ffe49248c34bab33d0d9247e60232f0 (patch) | |
tree | 46222384693cf36b8306cce7030b5bde482deed4 /src/buildtool/main/main.cpp | |
parent | f4cbd6a77213d12884a767e65da71d77a0fbf3ac (diff) | |
download | justbuild-600876757ffe49248c34bab33d0d9247e60232f0.tar.gz |
TargetCache: Drop dependency on execution api
Diffstat (limited to 'src/buildtool/main/main.cpp')
-rw-r--r-- | src/buildtool/main/main.cpp | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/src/buildtool/main/main.cpp b/src/buildtool/main/main.cpp index a3f985b7..5b72b640 100644 --- a/src/buildtool/main/main.cpp +++ b/src/buildtool/main/main.cpp @@ -1209,24 +1209,27 @@ void WriteTargetCacheEntries( gsl::not_null<IExecutionApi*> const& local_api, gsl::not_null<IExecutionApi*> const& remote_api) { auto ts = TaskSystem{jobs}; - TargetCache::Instance().SetLocalApi(local_api); - TargetCache::Instance().SetRemoteApi(remote_api); + auto downloader = [&local_api, &remote_api](auto infos) { + return remote_api->RetrieveToCas(infos, local_api); + }; for (auto const& [key, target] : cache_targets) { - ts.QueueTask([&key = key, &target = target, &extra_infos]() { - if (auto entry = - TargetCacheEntry::FromTarget(target, extra_infos)) { - if (not TargetCache::Instance().Store(key, *entry)) { + ts.QueueTask( + [&key = key, &target = target, &extra_infos, &downloader]() { + if (auto entry = + TargetCacheEntry::FromTarget(target, extra_infos)) { + if (not TargetCache::Instance().Store( + key, *entry, downloader)) { + Logger::Log(LogLevel::Warning, + "Failed writing target cache entry for {}", + key.Id().ToString()); + } + } + else { Logger::Log(LogLevel::Warning, - "Failed writing target cache entry for {}", + "Failed creating target cache entry for {}", key.Id().ToString()); } - } - else { - Logger::Log(LogLevel::Warning, - "Failed creating target cache entry for {}", - key.Id().ToString()); - } - }); + }); } } #endif |