summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2023-07-13 11:41:07 +0200
committerPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2023-08-07 17:01:01 +0200
commit317cb72c64330036f23fd19a7caf65637bac5bc1 (patch)
tree4760afa62324c21b491933d9be6849b951769fa2
parent19aa5015df60e0b9eccf1a93afb0d9776692f5d3 (diff)
downloadjustbuild-317cb72c64330036f23fd19a7caf65637bac5bc1.tar.gz
just-mr: Update async map keys with the 'special' pragma value
For 'file' and 'archive' checkouts we will handle more than just the 'ignore' value.
-rw-r--r--src/other_tools/just_mr/main.cpp16
-rw-r--r--src/other_tools/ops_maps/content_cas_map.hpp8
-rw-r--r--src/other_tools/repo_map/repos_to_setup_map.cpp14
-rw-r--r--src/other_tools/root_maps/TARGETS4
-rw-r--r--src/other_tools/root_maps/content_git_map.cpp10
-rw-r--r--src/other_tools/root_maps/fpath_git_map.cpp15
-rw-r--r--src/other_tools/root_maps/fpath_git_map.hpp9
7 files changed, 34 insertions, 42 deletions
diff --git a/src/other_tools/just_mr/main.cpp b/src/other_tools/just_mr/main.cpp
index cc33f5f3..c15970d2 100644
--- a/src/other_tools/just_mr/main.cpp
+++ b/src/other_tools/just_mr/main.cpp
@@ -787,18 +787,6 @@ void DefaultReachableRepositories(
(*resolved_repo_desc)->Get("sha256", Expression::none_t{});
auto repo_desc_sha512 =
(*resolved_repo_desc)->Get("sha512", Expression::none_t{});
- // check "special" pragma
- auto repo_desc_pragma = (*resolved_repo_desc)->At("pragma");
- auto pragma_special =
- repo_desc_pragma ? repo_desc_pragma->get()->At("special")
- : std::nullopt;
- auto pragma_special_value =
- pragma_special and pragma_special->get()->IsString() and
- kPragmaSpecialMap.contains(
- pragma_special->get()->String())
- ? std::make_optional(kPragmaSpecialMap.at(
- pragma_special->get()->String()))
- : std::nullopt;
ArchiveRepoInfo archive_info = {
.archive = {.content = repo_desc_content->get()->String(),
@@ -820,8 +808,8 @@ void DefaultReachableRepositories(
.origin_from_distdir = false},
.repo_type = repo_type_str,
.subdir = subdir.empty() ? "." : subdir.string(),
- .ignore_special =
- pragma_special_value == PragmaSpecial::Ignore};
+ .pragma_special = std::nullopt // not used
+ };
// add to list
repos_to_fetch.emplace_back(std::move(archive_info));
}
diff --git a/src/other_tools/ops_maps/content_cas_map.hpp b/src/other_tools/ops_maps/content_cas_map.hpp
index 17fa38f1..3b40010f 100644
--- a/src/other_tools/ops_maps/content_cas_map.hpp
+++ b/src/other_tools/ops_maps/content_cas_map.hpp
@@ -43,13 +43,13 @@ struct ArchiveRepoInfo {
ArchiveContent archive; /* key */
std::string repo_type; /* key */
std::string subdir; /* key */
- // create root that ignores symlinks
- bool ignore_special; /* key */
+ // create root based on "special" pragma value
+ std::optional<PragmaSpecial> pragma_special{std::nullopt}; /* key */
[[nodiscard]] auto operator==(const ArchiveRepoInfo& other) const -> bool {
return archive == other.archive and repo_type == other.repo_type and
subdir == other.subdir and
- ignore_special == other.ignore_special;
+ pragma_special == other.pragma_special;
}
};
@@ -78,7 +78,7 @@ struct hash<ArchiveRepoInfo> {
hash_combine<ArchiveContent>(&seed, ct.archive);
hash_combine<std::string>(&seed, ct.repo_type);
hash_combine<std::string>(&seed, ct.subdir);
- hash_combine<bool>(&seed, ct.ignore_special);
+ hash_combine<std::optional<PragmaSpecial>>(&seed, ct.pragma_special);
return seed;
}
};
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 a07ebaa6..69addd88 100644
--- a/src/other_tools/repo_map/repos_to_setup_map.cpp
+++ b/src/other_tools/repo_map/repos_to_setup_map.cpp
@@ -210,7 +210,7 @@ void ArchiveCheckout(ExpressionPtr const& repo_desc,
.origin_from_distdir = false},
.repo_type = repo_type,
.subdir = subdir.empty() ? "." : subdir.string(),
- .ignore_special = pragma_special_value == PragmaSpecial::Ignore};
+ .pragma_special = pragma_special_value};
// get the WS root as git tree
content_git_map->ConsumeAfterKeysReady(
ts,
@@ -278,12 +278,14 @@ void FileCheckout(ExpressionPtr const& repo_desc,
// check "to_git" pragma
auto pragma_to_git =
repo_desc_pragma ? repo_desc_pragma->get()->At("to_git") : std::nullopt;
- if (pragma_to_git and pragma_to_git->get()->IsBool() and
- pragma_to_git->get()->Bool()) {
+ // resolving symlinks implies also to_git
+ if (pragma_special_value == PragmaSpecial::ResolvePartially or
+ pragma_special_value == PragmaSpecial::ResolveCompletely or
+ (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 = fpath,
- .ignore_special = pragma_special_value == PragmaSpecial::Ignore};
+ FpathInfo fpath_info = {.fpath = fpath,
+ .pragma_special = pragma_special_value};
fpath_git_map->ConsumeAfterKeysReady(
ts,
{std::move(fpath_info)},
diff --git a/src/other_tools/root_maps/TARGETS b/src/other_tools/root_maps/TARGETS
index 56342137..469caf49 100644
--- a/src/other_tools/root_maps/TARGETS
+++ b/src/other_tools/root_maps/TARGETS
@@ -53,11 +53,11 @@
, ["@", "json", "", "json"]
, ["src/utils/cpp", "path_hash"]
, ["src/utils/cpp", "hash_combine"]
+ , ["src/other_tools/just_mr", "utils"]
]
, "stage": ["src", "other_tools", "root_maps"]
, "private-deps":
- [ ["src/other_tools/just_mr", "utils"]
- , ["src/buildtool/execution_api/local", "config"]
+ [ ["src/buildtool/execution_api/local", "config"]
, ["src/buildtool/storage", "config"]
, ["src/utils/cpp", "tmp_dir"]
, ["src/buildtool/file_system", "file_root"]
diff --git a/src/other_tools/root_maps/content_git_map.cpp b/src/other_tools/root_maps/content_git_map.cpp
index 524a59a4..df62fab6 100644
--- a/src/other_tools/root_maps/content_git_map.cpp
+++ b/src/other_tools/root_maps/content_git_map.cpp
@@ -83,7 +83,7 @@ auto CreateContentGitMap(
{std::move(op_key)},
[archive_tree_id = *archive_tree_id,
subdir = key.subdir,
- ignore_special = key.ignore_special,
+ pragma_special = key.pragma_special,
setter,
logger](auto const& values) {
GitOpValue op_result = *values[0];
@@ -119,7 +119,7 @@ auto CreateContentGitMap(
// set the workspace root
(*setter)(std::pair(
nlohmann::json::array(
- {ignore_special
+ {pragma_special == PragmaSpecial::Ignore
? FileRoot::kGitTreeIgnoreSpecialMarker
: FileRoot::kGitTreeMarker,
*subtree_hash,
@@ -145,7 +145,7 @@ auto CreateContentGitMap(
repo_type = key.repo_type,
content_id = key.archive.content,
subdir = key.subdir,
- ignore_special = key.ignore_special,
+ pragma_special = key.pragma_special,
import_to_git_map,
ts,
setter,
@@ -186,7 +186,7 @@ auto CreateContentGitMap(
[tmp_dir, // keep tmp_dir alive
archive_tree_id_file,
subdir,
- ignore_special,
+ pragma_special,
setter,
logger](auto const& values) {
// check for errors
@@ -246,7 +246,7 @@ auto CreateContentGitMap(
// set the workspace root
(*setter)(std::pair(
nlohmann::json::array(
- {ignore_special
+ {pragma_special == PragmaSpecial::Ignore
? FileRoot::kGitTreeIgnoreSpecialMarker
: FileRoot::kGitTreeMarker,
*subtree_hash,
diff --git a/src/other_tools/root_maps/fpath_git_map.cpp b/src/other_tools/root_maps/fpath_git_map.cpp
index e7946e71..e26b3a9d 100644
--- a/src/other_tools/root_maps/fpath_git_map.cpp
+++ b/src/other_tools/root_maps/fpath_git_map.cpp
@@ -17,7 +17,6 @@
#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"
auto CreateFilePathGitMap(
@@ -73,7 +72,7 @@ auto CreateFilePathGitMap(
ts,
{std::move(op_key)},
[fpath = key.fpath,
- ignore_special = key.ignore_special,
+ pragma_special = key.pragma_special,
git_cas = std::move(git_cas),
repo_root = std::move(*repo_root),
setter,
@@ -111,8 +110,9 @@ auto CreateFilePathGitMap(
}
// set the workspace root
(*setter)(nlohmann::json::array(
- {ignore_special ? FileRoot::kGitTreeIgnoreSpecialMarker
- : FileRoot::kGitTreeMarker,
+ {pragma_special == PragmaSpecial::Ignore
+ ? FileRoot::kGitTreeIgnoreSpecialMarker
+ : FileRoot::kGitTreeMarker,
*tree_hash,
repo_root}));
},
@@ -159,7 +159,7 @@ auto CreateFilePathGitMap(
{std::move(c_info)},
// tmp_dir passed, to ensure folder is not removed until import
// to git is done
- [tmp_dir, ignore_special = key.ignore_special, setter, logger](
+ [tmp_dir, pragma_special = key.pragma_special, setter, logger](
auto const& values) {
// check for errors
if (not values[0]->second) {
@@ -171,8 +171,9 @@ auto CreateFilePathGitMap(
std::string tree = values[0]->first;
// set the workspace root
(*setter)(nlohmann::json::array(
- {ignore_special ? FileRoot::kGitTreeIgnoreSpecialMarker
- : FileRoot::kGitTreeMarker,
+ {pragma_special == PragmaSpecial::Ignore
+ ? FileRoot::kGitTreeIgnoreSpecialMarker
+ : FileRoot::kGitTreeMarker,
tree,
StorageConfig::GitRoot()}));
},
diff --git a/src/other_tools/root_maps/fpath_git_map.hpp b/src/other_tools/root_maps/fpath_git_map.hpp
index 9c78b868..25721c19 100644
--- a/src/other_tools/root_maps/fpath_git_map.hpp
+++ b/src/other_tools/root_maps/fpath_git_map.hpp
@@ -16,18 +16,19 @@
#define INCLUDED_SRC_OTHER_TOOLS_ROOT_MAPS_FPATH_GIT_MAP_HPP
#include "nlohmann/json.hpp"
+#include "src/other_tools/just_mr/utils.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 */
+ // create root based on "special" pragma value
+ std::optional<PragmaSpecial> pragma_special{std::nullopt}; /* key */
[[nodiscard]] auto operator==(const FpathInfo& other) const noexcept
-> bool {
- return fpath == other.fpath and ignore_special == other.ignore_special;
+ return fpath == other.fpath and pragma_special == other.pragma_special;
}
};
@@ -47,7 +48,7 @@ struct hash<FpathInfo> {
-> std::size_t {
size_t seed{};
hash_combine<std::filesystem::path>(&seed, ct.fpath);
- hash_combine<bool>(&seed, ct.ignore_special);
+ hash_combine<std::optional<PragmaSpecial>>(&seed, ct.pragma_special);
return seed;
}
};