diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/other_tools/repo_map/TARGETS | 1 | ||||
-rw-r--r-- | src/other_tools/repo_map/repos_to_setup_map.cpp | 15 | ||||
-rw-r--r-- | src/other_tools/root_maps/TARGETS | 2 | ||||
-rw-r--r-- | src/other_tools/root_maps/fpath_git_map.cpp | 32 | ||||
-rw-r--r-- | src/other_tools/root_maps/fpath_git_map.hpp | 27 |
5 files changed, 61 insertions, 16 deletions
diff --git a/src/other_tools/repo_map/TARGETS b/src/other_tools/repo_map/TARGETS index 649708ae..b91730b9 100644 --- a/src/other_tools/repo_map/TARGETS +++ b/src/other_tools/repo_map/TARGETS @@ -15,6 +15,7 @@ , "private-deps": [ ["src/other_tools/just_mr/progress_reporting", "progress"] , ["src/other_tools/just_mr/progress_reporting", "statistics"] + , ["src/buildtool/file_system", "file_root"] ] } } 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 0a2c65ca..3fdd6678 100644 --- a/src/other_tools/repo_map/repos_to_setup_map.cpp +++ b/src/other_tools/repo_map/repos_to_setup_map.cpp @@ -14,6 +14,7 @@ #include "src/other_tools/repo_map/repos_to_setup_map.hpp" +#include "src/buildtool/file_system/file_root.hpp" #include "src/other_tools/just_mr/progress_reporting/progress.hpp" #include "src/other_tools/just_mr/progress_reporting/statistics.hpp" @@ -242,6 +243,12 @@ void FileCheckout(ExpressionPtr const& repo_desc, // get absolute path auto fpath = ToNormalPath( std::filesystem::absolute(repo_desc_path->get()->String())); + // get ignore-special entry + auto repo_desc_ignore_special = + repo_desc->Get("ignore_special", Expression::none_t{}); + bool ignore_special = repo_desc_ignore_special->IsBool() + ? repo_desc_ignore_special->Bool() + : false; // check to_git pragma auto repo_desc_pragma = repo_desc->At("pragma"); auto pragma_to_git = @@ -249,9 +256,10 @@ void FileCheckout(ExpressionPtr const& repo_desc, if (pragma_to_git and pragma_to_git->get()->IsBool() and pragma_to_git->get()->Bool()) { // get the WS root as git tree + FpathInfo fpath_info = {fpath, ignore_special}; fpath_git_map->ConsumeAfterKeysReady( ts, - {std::move(fpath)}, + {std::move(fpath_info)}, [repos = std::move(repos), repo_name, setter](auto const& values) { auto ws_root = *values[0]; nlohmann::json cfg({}); @@ -272,8 +280,9 @@ void FileCheckout(ExpressionPtr const& repo_desc, else { // get the WS root as filesystem location nlohmann::json cfg({}); - cfg["workspace_root"] = - nlohmann::json::array({"file", fpath.string()}); // explicit array + cfg["workspace_root"] = nlohmann::json::array( + {ignore_special ? FileRoot::kFileIgnoreSpecialMarker : "file", + fpath.string()}); // explicit array SetReposTakeOver(&cfg, repos, repo_name); (*setter)(std::move(cfg)); // report local path diff --git a/src/other_tools/root_maps/TARGETS b/src/other_tools/root_maps/TARGETS index e4bc6990..063f5a1c 100644 --- a/src/other_tools/root_maps/TARGETS +++ b/src/other_tools/root_maps/TARGETS @@ -50,6 +50,7 @@ [ ["src/other_tools/ops_maps", "import_to_git_map"] , ["@", "json", "", "json"] , ["src/utils/cpp", "path_hash"] + , ["src/utils/cpp", "hash_combine"] ] , "stage": ["src", "other_tools", "root_maps"] , "private-deps": @@ -57,6 +58,7 @@ , ["src/buildtool/execution_api/local", "config"] , ["src/buildtool/storage", "config"] , ["src/utils/cpp", "tmp_dir"] + , ["src/buildtool/file_system", "file_root"] ] } , "content_git_map": diff --git a/src/other_tools/root_maps/fpath_git_map.cpp b/src/other_tools/root_maps/fpath_git_map.cpp index 1330ee99..262d2b77 100644 --- a/src/other_tools/root_maps/fpath_git_map.cpp +++ b/src/other_tools/root_maps/fpath_git_map.cpp @@ -15,6 +15,7 @@ #include "src/other_tools/root_maps/fpath_git_map.hpp" #include "src/buildtool/execution_api/local/config.hpp" +#include "src/buildtool/file_system/file_root.hpp" #include "src/buildtool/storage/config.hpp" #include "src/other_tools/just_mr/utils.hpp" #include "src/utils/cpp/tmp_dir.hpp" @@ -39,7 +40,7 @@ auto CreateFilePathGitMap( }); // check if path is a part of a git repo auto repo_root = GitRepoRemote::GetRepoRootFromPath( - key, wrapped_logger); // static function + key.fpath, wrapped_logger); // static function if (not repo_root) { return; } @@ -70,7 +71,8 @@ auto CreateFilePathGitMap( critical_git_op_map->ConsumeAfterKeysReady( ts, {std::move(op_key)}, - [fpath = key, + [fpath = key.fpath, + ignore_special = key.ignore_special, git_cas = std::move(git_cas), repo_root = std::move(*repo_root), setter, @@ -108,7 +110,10 @@ auto CreateFilePathGitMap( } // set the workspace root (*setter)(nlohmann::json::array( - {"git tree", *tree_hash, repo_root})); + {ignore_special ? FileRoot::kGitTreeIgnoreSpecialMarker + : FileRoot::kGitTreeMarker, + *tree_hash, + repo_root})); }, [logger, target_path = *repo_root](auto const& msg, bool fatal) { @@ -126,7 +131,7 @@ auto CreateFilePathGitMap( "path \'{}\'.\nPlease consider using " "\'just-mr setup\' and \'just {}\' " "separately to cache the output.", - key.string(), + key.fpath.string(), *current_subcmd), /*fatal=*/false); } @@ -139,21 +144,22 @@ auto CreateFilePathGitMap( } // copy folder content to tmp dir if (not FileSystemManager::CopyDirectoryImpl( - key, tmp_dir->GetPath(), /*recursively=*/true)) { + key.fpath, tmp_dir->GetPath(), /*recursively=*/true)) { (*logger)( fmt::format("Failed to copy content from directory {}", - key.string()), + key.fpath.string()), /*fatal=*/true); return; } // do import to git - CommitInfo c_info{tmp_dir->GetPath(), "file", key}; + CommitInfo c_info{tmp_dir->GetPath(), "file", key.fpath}; import_to_git_map->ConsumeAfterKeysReady( ts, {std::move(c_info)}, // tmp_dir passed, to ensure folder is not removed until import // to git is done - [tmp_dir, setter, logger](auto const& values) { + [tmp_dir, ignore_special = key.ignore_special, setter, logger]( + auto const& values) { // check for errors if (not values[0]->second) { (*logger)("Importing to git failed", @@ -164,9 +170,12 @@ auto CreateFilePathGitMap( std::string tree = values[0]->first; // set the workspace root (*setter)(nlohmann::json::array( - {"git tree", tree, StorageConfig::GitRoot()})); + {ignore_special ? FileRoot::kGitTreeIgnoreSpecialMarker + : FileRoot::kGitTreeMarker, + tree, + StorageConfig::GitRoot()})); }, - [logger, target_path = key](auto const& msg, bool fatal) { + [logger, target_path = key.fpath](auto const& msg, bool fatal) { (*logger)( fmt::format("While importing target {} to git:\n{}", target_path.string(), @@ -175,6 +184,5 @@ auto CreateFilePathGitMap( }); } }; - return AsyncMapConsumer<std::filesystem::path, nlohmann::json>(dir_to_git, - jobs); + return AsyncMapConsumer<FpathInfo, nlohmann::json>(dir_to_git, jobs); } diff --git a/src/other_tools/root_maps/fpath_git_map.hpp b/src/other_tools/root_maps/fpath_git_map.hpp index 9b209163..9c78b868 100644 --- a/src/other_tools/root_maps/fpath_git_map.hpp +++ b/src/other_tools/root_maps/fpath_git_map.hpp @@ -17,10 +17,22 @@ #include "nlohmann/json.hpp" #include "src/other_tools/ops_maps/import_to_git_map.hpp" +#include "src/utils/cpp/hash_combine.hpp" #include "src/utils/cpp/path_hash.hpp" +struct FpathInfo { + std::filesystem::path fpath{}; /* key */ + // create root that ignores symlinks + bool ignore_special{}; /* key */ + + [[nodiscard]] auto operator==(const FpathInfo& other) const noexcept + -> bool { + return fpath == other.fpath and ignore_special == other.ignore_special; + } +}; + /// \brief Maps the path to a repo on the file system to its Git tree WS root. -using FilePathGitMap = AsyncMapConsumer<std::filesystem::path, nlohmann::json>; +using FilePathGitMap = AsyncMapConsumer<FpathInfo, nlohmann::json>; [[nodiscard]] auto CreateFilePathGitMap( std::optional<std::string> const& current_subcmd, @@ -28,4 +40,17 @@ using FilePathGitMap = AsyncMapConsumer<std::filesystem::path, nlohmann::json>; gsl::not_null<ImportToGitMap*> const& import_to_git_map, std::size_t jobs) -> FilePathGitMap; +namespace std { +template <> +struct hash<FpathInfo> { + [[nodiscard]] auto operator()(FpathInfo const& ct) const noexcept + -> std::size_t { + size_t seed{}; + hash_combine<std::filesystem::path>(&seed, ct.fpath); + hash_combine<bool>(&seed, ct.ignore_special); + return seed; + } +}; +} // namespace std + #endif // INCLUDED_SRC_OTHER_TOOLS_ROOT_MAPS_FPATH_GIT_MAP_HPP |