summaryrefslogtreecommitdiff
path: root/src/other_tools/repo_map
diff options
context:
space:
mode:
authorKlaus Aehlig <klaus.aehlig@huawei.com>2024-02-27 17:48:24 +0100
committerKlaus Aehlig <klaus.aehlig@huawei.com>2024-03-05 11:05:10 +0100
commit4daf637c2703ac2ce57691c7a03ffb551e0c7695 (patch)
tree26d36360e5cd634e682099033a9723880098763e /src/other_tools/repo_map
parent4bd538db22dca66b63a35165f8272a9d9627a4d1 (diff)
downloadjustbuild-4daf637c2703ac2ce57691c7a03ffb551e0c7695.tar.gz
Support checkout of foreign-file repos
Diffstat (limited to 'src/other_tools/repo_map')
-rw-r--r--src/other_tools/repo_map/TARGETS1
-rw-r--r--src/other_tools/repo_map/repos_to_setup_map.cpp74
-rw-r--r--src/other_tools/repo_map/repos_to_setup_map.hpp23
3 files changed, 78 insertions, 20 deletions
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