summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/other_tools/just_mr/utils.hpp6
-rw-r--r--src/other_tools/repo_map/TARGETS1
-rw-r--r--src/other_tools/repo_map/repos_to_setup_map.cpp49
3 files changed, 53 insertions, 3 deletions
diff --git a/src/other_tools/just_mr/utils.hpp b/src/other_tools/just_mr/utils.hpp
index 9b31d888..753e4b36 100644
--- a/src/other_tools/just_mr/utils.hpp
+++ b/src/other_tools/just_mr/utils.hpp
@@ -155,7 +155,8 @@ enum class CheckoutType : std::uint8_t {
ForeignFile,
File,
Distdir,
- GitTree
+ GitTree,
+ Computed
};
/// \brief Checkout type map
@@ -166,7 +167,8 @@ std::unordered_map<std::string, CheckoutType> const kCheckoutTypeMap = {
{"foreign file", CheckoutType::ForeignFile},
{"file", CheckoutType::File},
{"distdir", CheckoutType::Distdir},
- {"git tree", CheckoutType::GitTree}};
+ {"git tree", CheckoutType::GitTree},
+ {"computed", CheckoutType::Computed}};
namespace JustMR::Utils {
/// \brief Recursive part of the ResolveRepo function.
diff --git a/src/other_tools/repo_map/TARGETS b/src/other_tools/repo_map/TARGETS
index 264b4dcb..8958f84c 100644
--- a/src/other_tools/repo_map/TARGETS
+++ b/src/other_tools/repo_map/TARGETS
@@ -29,6 +29,7 @@
, ["src/other_tools/ops_maps", "content_cas_map"]
, ["src/other_tools/ops_maps", "git_tree_fetch_map"]
, ["src/other_tools/utils", "parse_archive"]
+ , ["src/other_tools/utils", "parse_computed_root"]
, ["src/other_tools/utils", "parse_git_tree"]
, ["src/utils/cpp", "expected"]
, ["src/utils/cpp", "path"]
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 8a714cb2..87dd7812 100644
--- a/src/other_tools/repo_map/repos_to_setup_map.cpp
+++ b/src/other_tools/repo_map/repos_to_setup_map.cpp
@@ -32,6 +32,7 @@
#include "src/other_tools/ops_maps/content_cas_map.hpp"
#include "src/other_tools/ops_maps/git_tree_fetch_map.hpp"
#include "src/other_tools/utils/parse_archive.hpp"
+#include "src/other_tools/utils/parse_computed_root.hpp"
#include "src/other_tools/utils/parse_git_tree.hpp"
#include "src/utils/cpp/expected.hpp"
#include "src/utils/cpp/path.hpp"
@@ -635,6 +636,44 @@ void GitTreeCheckout(ExpressionPtr const& repo_desc,
});
}
+void ComputedRootCheckout(ExpressionPtr const& repo_desc,
+ std::string const& repo_name,
+ ReposToSetupMap::SetterPtr const& setter,
+ ReposToSetupMap::SubCallerPtr const& subcaller,
+ ReposToSetupMap::LoggerPtr const& logger) {
+ auto const parser = ComputedRootParser::Create(&repo_desc);
+ if (not parser) {
+ (*logger)(
+ fmt::format("ComputedRootCheckout: Not a computed repository: {}",
+ nlohmann::json(repo_name).dump()),
+ /*fatal=*/true);
+ return;
+ }
+ auto result_root = parser->GetResult();
+ if (not result_root) {
+ (*logger)(fmt::format("ComputedRootCheckout: parsing repository {} "
+ "failed with:\n{}",
+ nlohmann::json(repo_name).dump(),
+ std::move(result_root).error()),
+ /*fatal=*/true);
+ return;
+ }
+ std::string target_repo = result_root->repository;
+ (*subcaller)(
+ {std::move(target_repo)},
+ [setter, result = *std::move(result_root)](auto const& /*unused*/) {
+ nlohmann::json cfg{};
+ auto& ws_root = cfg["workspace_root"];
+ ws_root.push_back("computed");
+ ws_root.push_back(result.repository);
+ ws_root.push_back(result.target_module);
+ ws_root.push_back(result.target_name);
+ ws_root.push_back(result.config);
+ std::invoke(*setter, std::move(cfg));
+ },
+ logger);
+}
+
} // namespace
auto CreateReposToSetupMap(
@@ -663,7 +702,7 @@ auto CreateReposToSetupMap(
stats](auto ts,
auto setter,
auto logger,
- auto /* unused */,
+ auto subcaller,
auto const& key) {
auto repos = (*config)["repositories"];
if (main and (key == *main) and interactive) {
@@ -820,6 +859,14 @@ auto CreateReposToSetupMap(
wrapped_logger);
break;
}
+ case CheckoutType::Computed: {
+ ComputedRootCheckout(*resolved_repo_desc,
+ key,
+ setter,
+ subcaller,
+ wrapped_logger);
+ break;
+ }
}
}
};