diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/other_tools/just_mr/setup.cpp | 8 | ||||
-rw-r--r-- | src/other_tools/just_mr/utils.hpp | 10 | ||||
-rw-r--r-- | src/other_tools/repo_map/TARGETS | 1 | ||||
-rw-r--r-- | src/other_tools/repo_map/repos_to_setup_map.cpp | 74 | ||||
-rw-r--r-- | src/other_tools/repo_map/repos_to_setup_map.hpp | 23 |
5 files changed, 95 insertions, 21 deletions
diff --git a/src/other_tools/just_mr/setup.cpp b/src/other_tools/just_mr/setup.cpp index 3370f0fc..97a236cc 100644 --- a/src/other_tools/just_mr/setup.cpp +++ b/src/other_tools/just_mr/setup.cpp @@ -208,6 +208,13 @@ auto MultiRepoSetup(std::shared_ptr<Configuration> const& config, common_args.fetch_absent, common_args.jobs); + auto foreign_file_git_map = + CreateForeignFileGitMap(&content_cas_map, + &import_to_git_map, + serve_api_exists, + common_args.fetch_absent, + common_args.jobs); + auto fpath_git_map = CreateFilePathGitMap( just_cmd_args.subcmd_name, &critical_git_op_map, @@ -250,6 +257,7 @@ auto MultiRepoSetup(std::shared_ptr<Configuration> const& config, interactive, &commit_git_map, &content_git_map, + &foreign_file_git_map, &fpath_git_map, &distdir_git_map, &tree_id_git_map, diff --git a/src/other_tools/just_mr/utils.hpp b/src/other_tools/just_mr/utils.hpp index a2966e20..30e7a913 100644 --- a/src/other_tools/just_mr/utils.hpp +++ b/src/other_tools/just_mr/utils.hpp @@ -155,13 +155,21 @@ nlohmann::json const kDefaultConfigLocations = nlohmann::json::array( {{"root", "system"}, {"path", "etc/just-repos.json"}}}); /// \brief Checkout type enum -enum class CheckoutType : std::uint8_t { Git, Archive, File, Distdir, GitTree }; +enum class CheckoutType : std::uint8_t { + Git, + Archive, + ForeignFile, + File, + Distdir, + GitTree +}; /// \brief Checkout type map std::unordered_map<std::string, CheckoutType> const kCheckoutTypeMap = { {"git", CheckoutType::Git}, {"archive", CheckoutType::Archive}, {"zip", CheckoutType::Archive}, // treated the same as "archive" + {"foreign file", CheckoutType::ForeignFile}, {"file", CheckoutType::File}, {"distdir", CheckoutType::Distdir}, {"git tree", CheckoutType::GitTree}}; diff --git a/src/other_tools/repo_map/TARGETS b/src/other_tools/repo_map/TARGETS index 94a6094a..1e805352 100644 --- a/src/other_tools/repo_map/TARGETS +++ b/src/other_tools/repo_map/TARGETS @@ -7,6 +7,7 @@ [ ["@", "gsl", "", "gsl"] , ["src/other_tools/root_maps", "commit_git_map"] , ["src/other_tools/root_maps", "content_git_map"] + , ["src/other_tools/root_maps", "foreign_file_git_map"] , ["src/other_tools/root_maps", "distdir_git_map"] , ["src/other_tools/root_maps", "fpath_git_map"] , ["src/buildtool/build_engine/expression", "expression"] diff --git a/src/other_tools/repo_map/repos_to_setup_map.cpp b/src/other_tools/repo_map/repos_to_setup_map.cpp index e98cf848..ccffd201 100644 --- a/src/other_tools/repo_map/repos_to_setup_map.cpp +++ b/src/other_tools/repo_map/repos_to_setup_map.cpp @@ -239,6 +239,47 @@ void ArchiveCheckout(ExpressionPtr const& repo_desc, }); } +/// \brief Perform checkout for an archive type repository. +/// Guarantees the logger is called exactly once with fatal if a failure occurs. +void ForeignFileCheckout( + ExpressionPtr const& repo_desc, + ExpressionPtr&& repos, + std::string const& repo_name, + gsl::not_null<ForeignFileGitMap*> const& foreign_file_git_map, + gsl::not_null<TaskSystem*> const& ts, + ReposToSetupMap::SetterPtr const& setter, + ReposToSetupMap::LoggerPtr const& logger) { + auto foreign_file_repo_info = + ParseForeignFileDescription(repo_desc, repo_name, logger); + if (not foreign_file_repo_info) { + return; + } + // get the WS root as git tree + foreign_file_git_map->ConsumeAfterKeysReady( + ts, + {std::move(*foreign_file_repo_info)}, + [repos = std::move(repos), repo_name, setter](auto const& values) { + auto ws_root = values[0]->first; + nlohmann::json cfg({}); + cfg["workspace_root"] = ws_root; + SetReposTakeOver(&cfg, repos, repo_name); + if (values[0]->second) { + JustMRStatistics::Instance().IncrementCacheHitsCounter(); + } + else { + JustMRStatistics::Instance().IncrementExecutedCounter(); + } + (*setter)(std::move(cfg)); + }, + [logger, repo_name](auto const& msg, bool fatal) { + (*logger)(fmt::format("While setting the workspace root for " + "foreign-file repository {}:\n{}", + nlohmann::json(repo_name).dump(), + msg), + fatal); + }); +} + /// \brief Perform checkout for a file type repository. /// Guarantees the logger is called exactly once with fatal if a failure occurs. void FileCheckout(ExpressionPtr const& repo_desc, @@ -719,21 +760,24 @@ void GitTreeCheckout(ExpressionPtr const& repo_desc, } // namespace -auto CreateReposToSetupMap(std::shared_ptr<Configuration> const& config, - std::optional<std::string> const& main, - bool interactive, - gsl::not_null<CommitGitMap*> const& commit_git_map, - gsl::not_null<ContentGitMap*> const& content_git_map, - gsl::not_null<FilePathGitMap*> const& fpath_git_map, - gsl::not_null<DistdirGitMap*> const& distdir_git_map, - gsl::not_null<TreeIdGitMap*> const& tree_id_git_map, - bool fetch_absent, - std::size_t jobs) -> ReposToSetupMap { +auto CreateReposToSetupMap( + std::shared_ptr<Configuration> const& config, + std::optional<std::string> const& main, + bool interactive, + gsl::not_null<CommitGitMap*> const& commit_git_map, + gsl::not_null<ContentGitMap*> const& content_git_map, + gsl::not_null<ForeignFileGitMap*> const& foreign_file_git_map, + gsl::not_null<FilePathGitMap*> const& fpath_git_map, + gsl::not_null<DistdirGitMap*> const& distdir_git_map, + gsl::not_null<TreeIdGitMap*> const& tree_id_git_map, + bool fetch_absent, + std::size_t jobs) -> ReposToSetupMap { auto setup_repo = [config, main, interactive, commit_git_map, content_git_map, + foreign_file_git_map, fpath_git_map, distdir_git_map, tree_id_git_map, @@ -848,6 +892,16 @@ auto CreateReposToSetupMap(std::shared_ptr<Configuration> const& config, wrapped_logger); break; } + case CheckoutType::ForeignFile: { + ForeignFileCheckout(*resolved_repo_desc, + std::move(repos), + key, + foreign_file_git_map, + ts, + setter, + wrapped_logger); + break; + } case CheckoutType::File: { FileCheckout(*resolved_repo_desc, std::move(repos), diff --git a/src/other_tools/repo_map/repos_to_setup_map.hpp b/src/other_tools/repo_map/repos_to_setup_map.hpp index ecd1bb6d..4cf992e8 100644 --- a/src/other_tools/repo_map/repos_to_setup_map.hpp +++ b/src/other_tools/repo_map/repos_to_setup_map.hpp @@ -24,6 +24,7 @@ #include "src/other_tools/root_maps/commit_git_map.hpp" #include "src/other_tools/root_maps/content_git_map.hpp" #include "src/other_tools/root_maps/distdir_git_map.hpp" +#include "src/other_tools/root_maps/foreign_file_git_map.hpp" #include "src/other_tools/root_maps/fpath_git_map.hpp" #include "src/other_tools/root_maps/tree_id_git_map.hpp" @@ -31,15 +32,17 @@ /// root and the TAKE_OVER fields. using ReposToSetupMap = AsyncMapConsumer<std::string, nlohmann::json>; -auto CreateReposToSetupMap(std::shared_ptr<Configuration> const& config, - std::optional<std::string> const& main, - bool interactive, - gsl::not_null<CommitGitMap*> const& commit_git_map, - gsl::not_null<ContentGitMap*> const& content_git_map, - gsl::not_null<FilePathGitMap*> const& fpath_git_map, - gsl::not_null<DistdirGitMap*> const& distdir_git_map, - gsl::not_null<TreeIdGitMap*> const& tree_id_git_map, - bool fetch_absent, - std::size_t jobs) -> ReposToSetupMap; +auto CreateReposToSetupMap( + std::shared_ptr<Configuration> const& config, + std::optional<std::string> const& main, + bool interactive, + gsl::not_null<CommitGitMap*> const& commit_git_map, + gsl::not_null<ContentGitMap*> const& content_git_map, + gsl::not_null<ForeignFileGitMap*> const& foreign_file_git_map, + gsl::not_null<FilePathGitMap*> const& fpath_git_map, + gsl::not_null<DistdirGitMap*> const& distdir_git_map, + gsl::not_null<TreeIdGitMap*> const& tree_id_git_map, + bool fetch_absent, + std::size_t jobs) -> ReposToSetupMap; #endif // INCLUDED_SRC_OTHER_TOOLS_REPO_MAP_REPOS_TO_SETUP_MAP_HPP |