summaryrefslogtreecommitdiff
path: root/src/other_tools/ops_maps
diff options
context:
space:
mode:
Diffstat (limited to 'src/other_tools/ops_maps')
-rw-r--r--src/other_tools/ops_maps/TARGETS13
-rw-r--r--src/other_tools/ops_maps/archive_fetch_map.cpp20
-rw-r--r--src/other_tools/ops_maps/archive_fetch_map.hpp2
-rw-r--r--src/other_tools/ops_maps/content_cas_map.cpp44
-rw-r--r--src/other_tools/ops_maps/content_cas_map.hpp4
-rw-r--r--src/other_tools/ops_maps/git_tree_fetch_map.cpp82
-rw-r--r--src/other_tools/ops_maps/git_tree_fetch_map.hpp2
-rw-r--r--src/other_tools/ops_maps/git_update_map.cpp37
-rw-r--r--src/other_tools/ops_maps/git_update_map.hpp11
-rw-r--r--src/other_tools/ops_maps/import_to_git_map.cpp62
-rw-r--r--src/other_tools/ops_maps/import_to_git_map.hpp2
11 files changed, 154 insertions, 125 deletions
diff --git a/src/other_tools/ops_maps/TARGETS b/src/other_tools/ops_maps/TARGETS
index ab8c6664..d564dc41 100644
--- a/src/other_tools/ops_maps/TARGETS
+++ b/src/other_tools/ops_maps/TARGETS
@@ -22,13 +22,13 @@
, ["src/other_tools/git_operations", "git_repo_remote"]
, ["src/utils/cpp", "path"]
, ["src/utils/cpp", "path_hash"]
+ , ["src/buildtool/storage", "config"]
]
, "stage": ["src", "other_tools", "ops_maps"]
, "private-deps":
[ ["@", "fmt", "", "fmt"]
, ["src/buildtool/multithreading", "task_system"]
, ["src/buildtool/storage", "fs_utils"]
- , ["src/buildtool/storage", "storage"]
, ["src/buildtool/execution_api/common", "common"]
, ["src/buildtool/execution_api/local", "config"]
]
@@ -42,6 +42,7 @@
[ ["src/other_tools/git_operations", "git_repo_remote"]
, ["src/buildtool/multithreading", "async_map_consumer"]
, ["src/utils/cpp", "hash_combine"]
+ , ["src/buildtool/storage", "config"]
]
, "stage": ["src", "other_tools", "ops_maps"]
, "private-deps":
@@ -50,7 +51,6 @@
, ["src/buildtool/storage", "fs_utils"]
, ["src/other_tools/just_mr/progress_reporting", "statistics"]
, ["src/other_tools/just_mr/progress_reporting", "progress"]
- , ["src/buildtool/storage", "config"]
]
}
, "content_cas_map":
@@ -68,19 +68,18 @@
, ["src/other_tools/ops_maps", "critical_git_op_map"]
, ["src/utils/cpp", "hash_combine"]
, ["src/buildtool/serve_api/remote", "serve_api"]
+ , ["src/buildtool/storage", "config"]
+ , ["src/buildtool/storage", "storage"]
]
, "stage": ["src", "other_tools", "ops_maps"]
, "private-deps":
[ ["@", "fmt", "", "fmt"]
, ["src/other_tools/utils", "content"]
, ["src/buildtool/file_system", "file_storage"]
- , ["src/buildtool/storage", "config"]
, ["src/buildtool/storage", "fs_utils"]
- , ["src/buildtool/storage", "storage"]
, ["src/other_tools/git_operations", "git_repo_remote"]
, ["src/other_tools/just_mr/progress_reporting", "statistics"]
, ["src/other_tools/just_mr/progress_reporting", "progress"]
- , ["src/buildtool/storage", "storage"]
]
}
, "archive_fetch_map":
@@ -92,6 +91,7 @@
[ ["@", "gsl", "", "gsl"]
, "content_cas_map"
, ["src/buildtool/execution_api/common", "common"]
+ , ["src/buildtool/storage", "storage"]
]
, "stage": ["src", "other_tools", "ops_maps"]
, "private-deps":
@@ -114,6 +114,7 @@
, ["src/other_tools/ops_maps", "critical_git_op_map"]
, ["src/other_tools/ops_maps", "import_to_git_map"]
, ["src/buildtool/serve_api/remote", "serve_api"]
+ , ["src/buildtool/storage", "config"]
]
, "stage": ["src", "other_tools", "ops_maps"]
, "private-deps":
@@ -122,8 +123,6 @@
, ["src/buildtool/compatibility", "compatibility"]
, ["src/buildtool/file_system", "file_system_manager"]
, ["src/buildtool/multithreading", "task_system"]
- , ["src/buildtool/storage", "config"]
- , ["src/buildtool/storage", "storage"]
, ["src/buildtool/system", "system_command"]
, ["src/other_tools/git_operations", "git_repo_remote"]
, ["src/other_tools/just_mr/progress_reporting", "progress"]
diff --git a/src/other_tools/ops_maps/archive_fetch_map.cpp b/src/other_tools/ops_maps/archive_fetch_map.cpp
index e035b128..f04d43f4 100644
--- a/src/other_tools/ops_maps/archive_fetch_map.cpp
+++ b/src/other_tools/ops_maps/archive_fetch_map.cpp
@@ -19,7 +19,6 @@
#include "fmt/core.h"
#include "src/buildtool/file_system/file_storage.hpp"
#include "src/buildtool/file_system/file_system_manager.hpp"
-#include "src/buildtool/storage/storage.hpp"
#include "src/other_tools/just_mr/progress_reporting/progress.hpp"
#include "src/other_tools/just_mr/progress_reporting/statistics.hpp"
#include "src/other_tools/just_mr/utils.hpp"
@@ -69,15 +68,19 @@ void ProcessContent(std::filesystem::path const& content_path,
auto CreateArchiveFetchMap(gsl::not_null<ContentCASMap*> const& content_cas_map,
std::filesystem::path const& fetch_dir,
+ gsl::not_null<Storage const*> const& storage,
gsl::not_null<IExecutionApi const*> const& local_api,
IExecutionApi const* remote_api,
std::size_t jobs) -> ArchiveFetchMap {
- auto fetch_archive = [content_cas_map, fetch_dir, local_api, remote_api](
- auto ts,
- auto setter,
- auto logger,
- auto /* unused */,
- auto const& key) {
+ auto fetch_archive = [content_cas_map,
+ fetch_dir,
+ storage,
+ local_api,
+ remote_api](auto ts,
+ auto setter,
+ auto logger,
+ auto /* unused */,
+ auto const& key) {
// get corresponding distfile
auto distfile =
(key.distfile
@@ -89,13 +92,14 @@ auto CreateArchiveFetchMap(gsl::not_null<ContentCASMap*> const& content_cas_map,
ts,
{key},
[target_name,
+ storage,
local_api,
remote_api,
content = key.content,
setter,
logger]([[maybe_unused]] auto const& values) {
// content is in local CAS now
- auto const& cas = Storage::Instance().CAS();
+ auto const& cas = storage->CAS();
auto content_path =
cas.BlobPath(ArtifactDigest{content, 0, /*is_tree=*/false},
/*is_executable=*/false)
diff --git a/src/other_tools/ops_maps/archive_fetch_map.hpp b/src/other_tools/ops_maps/archive_fetch_map.hpp
index 6ec3e44c..772d59e4 100644
--- a/src/other_tools/ops_maps/archive_fetch_map.hpp
+++ b/src/other_tools/ops_maps/archive_fetch_map.hpp
@@ -21,6 +21,7 @@
#include "gsl/gsl"
#include "src/buildtool/execution_api/common/execution_api.hpp"
+#include "src/buildtool/storage/storage.hpp"
#include "src/other_tools/ops_maps/content_cas_map.hpp"
/// \brief Maps an archive content hash to a status flag.
@@ -29,6 +30,7 @@ using ArchiveFetchMap = AsyncMapConsumer<ArchiveContent, bool>;
[[nodiscard]] auto CreateArchiveFetchMap(
gsl::not_null<ContentCASMap*> const& content_cas_map,
std::filesystem::path const& fetch_dir, // should exist!
+ gsl::not_null<Storage const*> const& storage,
gsl::not_null<IExecutionApi const*> const& local_api,
IExecutionApi const* remote_api,
std::size_t jobs) -> ArchiveFetchMap;
diff --git a/src/other_tools/ops_maps/content_cas_map.cpp b/src/other_tools/ops_maps/content_cas_map.cpp
index 59a22327..cacee577 100644
--- a/src/other_tools/ops_maps/content_cas_map.cpp
+++ b/src/other_tools/ops_maps/content_cas_map.cpp
@@ -18,9 +18,7 @@
#include "fmt/core.h"
#include "src/buildtool/file_system/file_storage.hpp"
-#include "src/buildtool/storage/config.hpp"
#include "src/buildtool/storage/fs_utils.hpp"
-#include "src/buildtool/storage/storage.hpp"
#include "src/other_tools/git_operations/git_repo_remote.hpp"
#include "src/other_tools/just_mr/progress_reporting/progress.hpp"
#include "src/other_tools/just_mr/progress_reporting/statistics.hpp"
@@ -32,6 +30,7 @@ namespace {
void FetchFromNetwork(ArchiveContent const& key,
MirrorsPtr const& additional_mirrors,
CAInfoPtr const& ca_info,
+ Storage const& storage,
ContentCASMap::SetterPtr const& setter,
ContentCASMap::LoggerPtr const& logger) {
// first, check that mandatory fields are provided
@@ -75,7 +74,7 @@ void FetchFromNetwork(ArchiveContent const& key,
}
}
// add the fetched data to CAS
- auto path = StorageUtils::AddToCAS(Storage::Instance(), *data);
+ auto path = StorageUtils::AddToCAS(storage, *data);
// check one last time if content is in CAS now
if (not path) {
(*logger)(fmt::format("Failed to store fetched content from {}",
@@ -84,7 +83,7 @@ void FetchFromNetwork(ArchiveContent const& key,
return;
}
// check that the data we stored actually produces the requested digest
- auto const& cas = Storage::Instance().CAS();
+ auto const& cas = storage.CAS();
if (not cas.BlobPath(ArtifactDigest{key.content, 0, /*is_tree=*/false},
/*is_executable=*/false)) {
(*logger)(
@@ -107,6 +106,8 @@ auto CreateContentCASMap(
CAInfoPtr const& ca_info,
gsl::not_null<CriticalGitOpMap*> const& critical_git_op_map,
ServeApi const* serve,
+ gsl::not_null<StorageConfig const*> const& storage_config,
+ gsl::not_null<Storage const*> const& storage,
gsl::not_null<IExecutionApi const*> const& local_api,
IExecutionApi const* remote_api,
std::size_t jobs) -> ContentCASMap {
@@ -115,6 +116,8 @@ auto CreateContentCASMap(
ca_info,
critical_git_op_map,
serve,
+ storage,
+ storage_config,
local_api,
remote_api](auto ts,
auto setter,
@@ -123,23 +126,21 @@ auto CreateContentCASMap(
auto const& key) {
auto digest = ArtifactDigest(key.content, 0, false);
// check local CAS
- auto const& cas = Storage::Instance().CAS();
- if (cas.BlobPath(digest, /*is_executable=*/false)) {
+ if (local_api->IsAvailable(digest)) {
(*setter)(nullptr);
return;
}
// check if content is in Git cache;
// ensure Git cache
- GitOpKey op_key = {
- .params =
- {
- StorageConfig::Instance().GitRoot(), // target_path
- "", // git_hash
- "", // branch
- std::nullopt, // message
- true // init_bare
- },
- .op_type = GitOpType::ENSURE_INIT};
+ GitOpKey op_key = {.params =
+ {
+ storage_config->GitRoot(), // target_path
+ "", // git_hash
+ "", // branch
+ std::nullopt, // message
+ true // init_bare
+ },
+ .op_type = GitOpType::ENSURE_INIT};
critical_git_op_map->ConsumeAfterKeysReady(
ts,
{std::move(op_key)},
@@ -149,6 +150,7 @@ auto CreateContentCASMap(
additional_mirrors,
ca_info,
serve,
+ storage,
local_api,
remote_api,
setter,
@@ -183,7 +185,7 @@ auto CreateContentCASMap(
// blob check failed
return;
}
- auto const& cas = Storage::Instance().CAS();
+ auto const& cas = storage->CAS();
if (res.second) {
// blob found; add it to CAS
if (not cas.StoreBlob(*res.second,
@@ -207,7 +209,7 @@ auto CreateContentCASMap(
.filename()
.string());
StorageUtils::AddDistfileToCAS(
- Storage::Instance(), repo_distfile, just_mr_paths);
+ *storage, repo_distfile, just_mr_paths);
// check if content is in CAS now
if (cas.BlobPath(digest, /*is_executable=*/false)) {
JustMRProgress::Instance().TaskTracker().Stop(key.origin);
@@ -240,10 +242,10 @@ auto CreateContentCASMap(
}
// revert to network fetch
FetchFromNetwork(
- key, additional_mirrors, ca_info, setter, logger);
+ key, additional_mirrors, ca_info, *storage, setter, logger);
},
- [logger, target_path = StorageConfig::Instance().GitRoot()](
- auto const& msg, bool fatal) {
+ [logger, target_path = storage_config->GitRoot()](auto const& msg,
+ bool fatal) {
(*logger)(fmt::format("While running critical Git op "
"ENSURE_INIT for target {}:\n{}",
target_path.string(),
diff --git a/src/other_tools/ops_maps/content_cas_map.hpp b/src/other_tools/ops_maps/content_cas_map.hpp
index 049edc5f..27bb9429 100644
--- a/src/other_tools/ops_maps/content_cas_map.hpp
+++ b/src/other_tools/ops_maps/content_cas_map.hpp
@@ -26,6 +26,8 @@
#include "src/buildtool/file_system/symlinks_map/pragma_special.hpp"
#include "src/buildtool/multithreading/async_map_consumer.hpp"
#include "src/buildtool/serve_api/remote/serve_api.hpp"
+#include "src/buildtool/storage/config.hpp"
+#include "src/buildtool/storage/storage.hpp"
#include "src/other_tools/just_mr/mirrors.hpp"
#include "src/other_tools/ops_maps/critical_git_op_map.hpp"
#include "src/utils/cpp/hash_combine.hpp"
@@ -85,6 +87,8 @@ using ContentCASMap = AsyncMapConsumer<ArchiveContent, std::nullptr_t>;
CAInfoPtr const& ca_info,
gsl::not_null<CriticalGitOpMap*> const& critical_git_op_map,
ServeApi const* serve,
+ gsl::not_null<StorageConfig const*> const& storage_config,
+ gsl::not_null<Storage const*> const& storage,
gsl::not_null<IExecutionApi const*> const& local_api,
IExecutionApi const* remote_api,
std::size_t jobs) -> ContentCASMap;
diff --git a/src/other_tools/ops_maps/git_tree_fetch_map.cpp b/src/other_tools/ops_maps/git_tree_fetch_map.cpp
index 60ea67da..f88f5d46 100644
--- a/src/other_tools/ops_maps/git_tree_fetch_map.cpp
+++ b/src/other_tools/ops_maps/git_tree_fetch_map.cpp
@@ -25,8 +25,6 @@
#include "src/buildtool/execution_api/git/git_api.hpp"
#include "src/buildtool/file_system/file_system_manager.hpp"
#include "src/buildtool/multithreading/task_system.hpp"
-#include "src/buildtool/storage/config.hpp"
-#include "src/buildtool/storage/storage.hpp"
#include "src/buildtool/system/system_command.hpp"
#include "src/other_tools/git_operations/git_repo_remote.hpp"
#include "src/other_tools/just_mr/progress_reporting/progress.hpp"
@@ -35,11 +33,12 @@
namespace {
void BackupToRemote(std::string const& tree_id,
+ StorageConfig const& storage_config,
IExecutionApi const& remote_api,
GitTreeFetchMap::LoggerPtr const& logger) {
// try to back up to remote CAS
auto repo = RepositoryConfig{};
- if (repo.SetGitCAS(StorageConfig::Instance().GitRoot())) {
+ if (repo.SetGitCAS(storage_config.GitRoot())) {
auto git_api = GitApi{&repo};
if (not git_api.RetrieveToCas(
{Artifact::ObjectInfo{
@@ -56,7 +55,7 @@ void BackupToRemote(std::string const& tree_id,
else {
// give a warning
(*logger)(fmt::format("Failed to SetGitCAS at {}",
- StorageConfig::Instance().GitRoot().string()),
+ storage_config.GitRoot().string()),
/*fatal=*/false);
}
}
@@ -66,6 +65,7 @@ void BackupToRemote(std::string const& tree_id,
void MoveCASTreeToGit(std::string const& tree_id,
ArtifactDigest const& digest,
gsl::not_null<ImportToGitMap*> const& import_to_git_map,
+ gsl::not_null<StorageConfig const*> const& storage_config,
gsl::not_null<IExecutionApi const*> const& local_api,
IExecutionApi const* remote_api,
bool backup_to_remote,
@@ -73,8 +73,7 @@ void MoveCASTreeToGit(std::string const& tree_id,
GitTreeFetchMap::SetterPtr const& setter,
GitTreeFetchMap::LoggerPtr const& logger) {
// Move tree from CAS to local Git storage
- auto tmp_dir =
- StorageConfig::Instance().CreateTypedTmpDir("fetch-remote-git-tree");
+ auto tmp_dir = storage_config->CreateTypedTmpDir("fetch-remote-git-tree");
if (not tmp_dir) {
(*logger)(fmt::format("Failed to create tmp directory for copying "
"git-tree {} from remote CAS",
@@ -97,6 +96,7 @@ void MoveCASTreeToGit(std::string const& tree_id,
{std::move(c_info)},
[tmp_dir, // keep tmp_dir alive
tree_id,
+ storage_config,
remote_api,
backup_to_remote,
setter,
@@ -108,7 +108,7 @@ void MoveCASTreeToGit(std::string const& tree_id,
}
// backup to remote if needed and in compatibility mode
if (backup_to_remote and remote_api != nullptr) {
- BackupToRemote(tree_id, *remote_api, logger);
+ BackupToRemote(tree_id, *storage_config, *remote_api, logger);
}
(*setter)(false /*no cache hit*/);
},
@@ -130,6 +130,7 @@ auto CreateGitTreeFetchMap(
std::string const& git_bin,
std::vector<std::string> const& launcher,
ServeApi const* serve,
+ gsl::not_null<StorageConfig const*> const& storage_config,
gsl::not_null<IExecutionApi const*> const& local_api,
IExecutionApi const* remote_api,
bool backup_to_remote,
@@ -139,6 +140,7 @@ auto CreateGitTreeFetchMap(
git_bin,
launcher,
serve,
+ storage_config,
local_api,
remote_api,
backup_to_remote](auto ts,
@@ -148,16 +150,15 @@ auto CreateGitTreeFetchMap(
auto const& key) {
// check whether tree exists already in Git cache;
// ensure Git cache exists
- GitOpKey op_key = {
- .params =
- {
- StorageConfig::Instance().GitRoot(), // target_path
- "", // git_hash
- "", // branch
- std::nullopt, // message
- true // init_bare
- },
- .op_type = GitOpType::ENSURE_INIT};
+ GitOpKey op_key = {.params =
+ {
+ storage_config->GitRoot(), // target_path
+ "", // git_hash
+ "", // branch
+ std::nullopt, // message
+ true // init_bare
+ },
+ .op_type = GitOpType::ENSURE_INIT};
critical_git_op_map->ConsumeAfterKeysReady(
ts,
{std::move(op_key)},
@@ -166,6 +167,7 @@ auto CreateGitTreeFetchMap(
git_bin,
launcher,
serve,
+ storage_config,
local_api,
remote_api,
backup_to_remote,
@@ -184,9 +186,8 @@ auto CreateGitTreeFetchMap(
auto git_repo = GitRepoRemote::Open(
op_result.git_cas); // link fake repo to odb
if (not git_repo) {
- (*logger)(fmt::format(
- "Could not open repository {}",
- StorageConfig::Instance().GitRoot().string()),
+ (*logger)(fmt::format("Could not open repository {}",
+ storage_config->GitRoot().string()),
/*fatal=*/true);
return;
}
@@ -208,7 +209,8 @@ auto CreateGitTreeFetchMap(
if (*tree_found) {
// backup to remote if needed and in native mode
if (backup_to_remote and remote_api != nullptr) {
- BackupToRemote(key.hash, *remote_api, logger);
+ BackupToRemote(
+ key.hash, *storage_config, *remote_api, logger);
}
// success
(*setter)(true /*cache hit*/);
@@ -216,12 +218,12 @@ auto CreateGitTreeFetchMap(
}
// check if tree is known to local CAS
auto digest = ArtifactDigest{key.hash, 0, /*is_tree=*/true};
- auto const& cas = Storage::Instance().CAS();
- if (auto path = cas.TreePath(digest)) {
+ if (local_api->IsAvailable(digest)) {
// import tree to Git cache
MoveCASTreeToGit(key.hash,
digest,
import_to_git_map,
+ storage_config,
local_api,
remote_api,
backup_to_remote,
@@ -251,6 +253,7 @@ auto CreateGitTreeFetchMap(
key.hash,
digest,
import_to_git_map,
+ storage_config,
local_api,
remote_api,
false, // tree already in remote, so ignore backing up
@@ -261,8 +264,7 @@ auto CreateGitTreeFetchMap(
return;
}
// create temporary location for command execution root
- auto tmp_dir =
- StorageConfig::Instance().CreateTypedTmpDir("git-tree");
+ auto tmp_dir = storage_config->CreateTypedTmpDir("git-tree");
if (not tmp_dir) {
(*logger)(
"Failed to create execution root tmp directory for "
@@ -271,8 +273,7 @@ auto CreateGitTreeFetchMap(
return;
}
// create temporary location for storing command result files
- auto out_dir =
- StorageConfig::Instance().CreateTypedTmpDir("git-tree");
+ auto out_dir = storage_config->CreateTypedTmpDir("git-tree");
if (not out_dir) {
(*logger)(
"Failed to create results tmp directory for tree id "
@@ -322,6 +323,7 @@ auto CreateGitTreeFetchMap(
key,
git_bin,
launcher,
+ storage_config,
remote_api,
backup_to_remote,
ts,
@@ -401,8 +403,7 @@ auto CreateGitTreeFetchMap(
}
// define temp repo path
auto tmp_dir =
- StorageConfig::Instance().CreateTypedTmpDir(
- "git-tree");
+ storage_config->CreateTypedTmpDir("git-tree");
;
if (not tmp_dir) {
(*logger)(fmt::format("Could not create unique "
@@ -423,7 +424,7 @@ auto CreateGitTreeFetchMap(
fatal);
});
if (not just_git_repo->FetchViaTmpRepo(
- StorageConfig::Instance(),
+ *storage_config,
target_path.string(),
std::nullopt,
key.inherit_env,
@@ -449,8 +450,7 @@ auto CreateGitTreeFetchMap(
GitOpKey op_key = {
.params =
{
- StorageConfig::Instance()
- .GitRoot(), // target_path
+ storage_config->GitRoot(), // target_path
*op_result.result, // git_hash
"", // branch
"Keep referenced tree alive" // message
@@ -459,8 +459,12 @@ auto CreateGitTreeFetchMap(
critical_git_op_map->ConsumeAfterKeysReady(
ts,
{std::move(op_key)},
- [remote_api, backup_to_remote, key, setter, logger](
- auto const& values) {
+ [remote_api,
+ storage_config,
+ backup_to_remote,
+ key,
+ setter,
+ logger](auto const& values) {
GitOpValue op_result = *values[0];
// check flag
if (not op_result.result) {
@@ -473,8 +477,10 @@ auto CreateGitTreeFetchMap(
// backup to remote if needed and in native mode
if (backup_to_remote and
remote_api != nullptr) {
- BackupToRemote(
- key.hash, *remote_api, logger);
+ BackupToRemote(key.hash,
+ *storage_config,
+ *remote_api,
+ logger);
}
// success
(*setter)(false /*no cache hit*/);
@@ -496,8 +502,8 @@ auto CreateGitTreeFetchMap(
fatal);
});
},
- [logger, target_path = StorageConfig::Instance().GitRoot()](
- auto const& msg, bool fatal) {
+ [logger, target_path = storage_config->GitRoot()](auto const& msg,
+ bool fatal) {
(*logger)(fmt::format("While running critical Git op "
"ENSURE_INIT bare for target {}:\n{}",
target_path.string(),
diff --git a/src/other_tools/ops_maps/git_tree_fetch_map.hpp b/src/other_tools/ops_maps/git_tree_fetch_map.hpp
index 4a8ab527..e61e1264 100644
--- a/src/other_tools/ops_maps/git_tree_fetch_map.hpp
+++ b/src/other_tools/ops_maps/git_tree_fetch_map.hpp
@@ -24,6 +24,7 @@
#include "gsl/gsl"
#include "src/buildtool/execution_api/common/execution_api.hpp"
#include "src/buildtool/serve_api/remote/serve_api.hpp"
+#include "src/buildtool/storage/config.hpp"
#include "src/other_tools/ops_maps/critical_git_op_map.hpp"
#include "src/other_tools/ops_maps/import_to_git_map.hpp"
@@ -61,6 +62,7 @@ using GitTreeFetchMap = AsyncMapConsumer<GitTreeInfo, bool>;
std::string const& git_bin,
std::vector<std::string> const& launcher,
ServeApi const* serve,
+ gsl::not_null<StorageConfig const*> const& storage_config,
gsl::not_null<IExecutionApi const*> const& local_api,
IExecutionApi const* remote_api,
bool backup_to_remote,
diff --git a/src/other_tools/ops_maps/git_update_map.cpp b/src/other_tools/ops_maps/git_update_map.cpp
index 143000bc..de3bfb25 100644
--- a/src/other_tools/ops_maps/git_update_map.cpp
+++ b/src/other_tools/ops_maps/git_update_map.cpp
@@ -16,20 +16,22 @@
#include "fmt/core.h"
#include "src/buildtool/execution_api/local/config.hpp"
-#include "src/buildtool/storage/config.hpp"
#include "src/buildtool/storage/fs_utils.hpp"
#include "src/other_tools/just_mr/progress_reporting/progress.hpp"
#include "src/other_tools/just_mr/progress_reporting/statistics.hpp"
-auto CreateGitUpdateMap(GitCASPtr const& git_cas,
- std::string const& git_bin,
- std::vector<std::string> const& launcher,
- std::size_t jobs) -> GitUpdateMap {
- auto update_commits = [git_cas, git_bin, launcher](auto /* unused */,
- auto setter,
- auto logger,
- auto /* unused */,
- auto const& key) {
+auto CreateGitUpdateMap(
+ GitCASPtr const& git_cas,
+ std::string const& git_bin,
+ std::vector<std::string> const& launcher,
+ gsl::not_null<StorageConfig const*> const& storage_config,
+ std::size_t jobs) -> GitUpdateMap {
+ auto update_commits = [git_cas, git_bin, launcher, storage_config](
+ auto /* unused */,
+ auto setter,
+ auto logger,
+ auto /* unused */,
+ auto const& key) {
// perform git update commit
auto git_repo = GitRepoRemote::Open(git_cas); // wrap the tmp odb
if (not git_repo) {
@@ -49,14 +51,13 @@ auto CreateGitUpdateMap(GitCASPtr const& git_cas,
// update commit
auto id = fmt::format("{}:{}", key.repo, key.branch);
JustMRProgress::Instance().TaskTracker().Start(id);
- auto new_commit =
- git_repo->UpdateCommitViaTmpRepo(StorageConfig::Instance(),
- key.repo,
- key.branch,
- key.inherit_env,
- git_bin,
- launcher,
- wrapped_logger);
+ auto new_commit = git_repo->UpdateCommitViaTmpRepo(*storage_config,
+ key.repo,
+ key.branch,
+ key.inherit_env,
+ git_bin,
+ launcher,
+ wrapped_logger);
JustMRProgress::Instance().TaskTracker().Stop(id);
if (not new_commit) {
return;
diff --git a/src/other_tools/ops_maps/git_update_map.hpp b/src/other_tools/ops_maps/git_update_map.hpp
index bc021113..4b043284 100644
--- a/src/other_tools/ops_maps/git_update_map.hpp
+++ b/src/other_tools/ops_maps/git_update_map.hpp
@@ -21,6 +21,7 @@
#include <vector>
#include "src/buildtool/multithreading/async_map_consumer.hpp"
+#include "src/buildtool/storage/config.hpp"
#include "src/other_tools/git_operations/git_repo_remote.hpp"
#include "src/utils/cpp/hash_combine.hpp"
@@ -51,9 +52,11 @@ struct hash<RepoDescriptionForUpdating> {
};
} // namespace std
-[[nodiscard]] auto CreateGitUpdateMap(GitCASPtr const& git_cas,
- std::string const& git_bin,
- std::vector<std::string> const& launcher,
- std::size_t jobs) -> GitUpdateMap;
+[[nodiscard]] auto CreateGitUpdateMap(
+ GitCASPtr const& git_cas,
+ std::string const& git_bin,
+ std::vector<std::string> const& launcher,
+ gsl::not_null<StorageConfig const*> const& storage_config,
+ std::size_t jobs) -> GitUpdateMap;
#endif // INCLUDED_SRC_OTHER_TOOLS_OPS_MAPS_GIT_UPDATE_MAP_HPP
diff --git a/src/other_tools/ops_maps/import_to_git_map.cpp b/src/other_tools/ops_maps/import_to_git_map.cpp
index 7e75ab71..51a4548e 100644
--- a/src/other_tools/ops_maps/import_to_git_map.cpp
+++ b/src/other_tools/ops_maps/import_to_git_map.cpp
@@ -18,7 +18,6 @@
#include "src/buildtool/execution_api/common/execution_common.hpp"
#include "src/buildtool/execution_api/local/config.hpp"
#include "src/buildtool/multithreading/task_system.hpp"
-#include "src/buildtool/storage/config.hpp"
#include "src/buildtool/storage/fs_utils.hpp"
namespace {
@@ -28,19 +27,19 @@ void KeepCommitAndSetTree(
std::string const& commit,
std::filesystem::path const& target_path,
GitCASPtr const& just_git_cas,
+ StorageConfig const& storage_config,
gsl::not_null<TaskSystem*> const& ts,
ImportToGitMap::SetterPtr const& setter,
ImportToGitMap::LoggerPtr const& logger) {
// Keep tag for commit
- GitOpKey op_key = {
- .params =
- {
- StorageConfig::Instance().GitRoot(), // target_path
- commit, // git_hash
- "", // branch
- "Keep referenced tree alive" // message
- },
- .op_type = GitOpType::KEEP_TAG};
+ GitOpKey op_key = {.params =
+ {
+ storage_config.GitRoot(), // target_path
+ commit, // git_hash
+ "", // branch
+ "Keep referenced tree alive" // message
+ },
+ .op_type = GitOpType::KEEP_TAG};
critical_git_op_map->ConsumeAfterKeysReady(
ts,
{std::move(op_key)},
@@ -93,13 +92,16 @@ auto CreateImportToGitMap(
gsl::not_null<CriticalGitOpMap*> const& critical_git_op_map,
std::string const& git_bin,
std::vector<std::string> const& launcher,
+ gsl::not_null<StorageConfig const*> const& storage_config,
std::size_t jobs) -> ImportToGitMap {
- auto import_to_git = [critical_git_op_map, git_bin, launcher](
- auto ts,
- auto setter,
- auto logger,
- auto /*unused*/,
- auto const& key) {
+ auto import_to_git = [critical_git_op_map,
+ git_bin,
+ launcher,
+ storage_config](auto ts,
+ auto setter,
+ auto logger,
+ auto /*unused*/,
+ auto const& key) {
// Perform initial commit at import location: init + add . + commit
GitOpKey op_key = {.params =
{
@@ -118,6 +120,7 @@ auto CreateImportToGitMap(
target_path = key.target_path,
git_bin,
launcher,
+ storage_config,
ts,
setter,
logger](auto const& values) {
@@ -133,11 +136,11 @@ auto CreateImportToGitMap(
GitOpKey op_key = {
.params =
{
- StorageConfig::Instance().GitRoot(), // target_path
- "", // git_hash
- "", // branch
- std::nullopt, // message
- true // init_bare
+ storage_config->GitRoot(), // target_path
+ "", // git_hash
+ "", // branch
+ std::nullopt, // message
+ true // init_bare
},
.op_type = GitOpType::ENSURE_INIT};
critical_git_op_map->ConsumeAfterKeysReady(
@@ -148,6 +151,7 @@ auto CreateImportToGitMap(
target_path,
git_bin,
launcher,
+ storage_config,
ts,
setter,
logger](auto const& values) {
@@ -162,12 +166,11 @@ auto CreateImportToGitMap(
auto just_git_repo =
GitRepoRemote::Open(op_result.git_cas);
if (not just_git_repo) {
- (*logger)(fmt::format("Could not open Git cache "
- "repository {}",
- StorageConfig::Instance()
- .GitRoot()
- .string()),
- /*fatal=*/true);
+ (*logger)(
+ fmt::format("Could not open Git cache "
+ "repository {}",
+ storage_config->GitRoot().string()),
+ /*fatal=*/true);
return;
}
auto wrapped_logger =
@@ -181,7 +184,7 @@ auto CreateImportToGitMap(
fatal);
});
if (not just_git_repo->FetchViaTmpRepo(
- StorageConfig::Instance(),
+ *storage_config,
target_path.string(),
std::nullopt,
std::vector<std::string>{} /* inherit_env */,
@@ -206,11 +209,12 @@ auto CreateImportToGitMap(
commit,
target_path,
op_result.git_cas, /*just_git_cas*/
+ *storage_config,
ts,
setter,
wrapped_logger);
},
- [logger, target_path = StorageConfig::Instance().GitRoot()](
+ [logger, target_path = storage_config->GitRoot()](
auto const& msg, bool fatal) {
(*logger)(fmt::format("While running critical Git "
"op ENSURE_INIT bare for "
diff --git a/src/other_tools/ops_maps/import_to_git_map.hpp b/src/other_tools/ops_maps/import_to_git_map.hpp
index ce17d781..cd6fdbef 100644
--- a/src/other_tools/ops_maps/import_to_git_map.hpp
+++ b/src/other_tools/ops_maps/import_to_git_map.hpp
@@ -21,6 +21,7 @@
#include <utility>
#include "gsl/gsl"
+#include "src/buildtool/storage/config.hpp"
#include "src/other_tools/git_operations/git_repo_remote.hpp"
#include "src/other_tools/ops_maps/critical_git_op_map.hpp"
#include "src/utils/cpp/path.hpp"
@@ -65,6 +66,7 @@ using ImportToGitMap =
gsl::not_null<CriticalGitOpMap*> const& critical_git_op_map,
std::string const& git_bin,
std::vector<std::string> const& launcher,
+ gsl::not_null<StorageConfig const*> const& storage_config,
std::size_t jobs) -> ImportToGitMap;
#endif // INCLUDED_SRC_OTHER_TOOLS_OPS_MAPS_IMPORT_TO_GIT_MAP_HPP \ No newline at end of file