summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaksim Denisov <denisov.maksim@huawei.com>2024-12-17 16:51:12 +0100
committerMaksim Denisov <denisov.maksim@huawei.com>2024-12-19 16:37:59 +0100
commitbd410a2557b6127d47396cd0740347e4af0766df (patch)
treee8f9a976fb55751ede017c0746a43b682513ef7d
parent75abf567afd7a130e9fbc90c6b7ac03ac40651c1 (diff)
downloadjustbuild-bd410a2557b6127d47396cd0740347e4af0766df.tar.gz
Remove FileRoot::ComputedRoot
-rw-r--r--src/buildtool/common/repository_config.cpp25
-rw-r--r--src/buildtool/common/repository_config.hpp3
-rw-r--r--src/buildtool/file_system/TARGETS1
-rw-r--r--src/buildtool/file_system/file_root.hpp87
-rw-r--r--src/other_tools/repo_map/TARGETS1
-rw-r--r--src/other_tools/repo_map/repos_to_setup_map.cpp1
-rw-r--r--src/other_tools/utils/TARGETS2
-rw-r--r--src/other_tools/utils/parse_computed_root.cpp14
-rw-r--r--src/other_tools/utils/parse_computed_root.hpp5
9 files changed, 14 insertions, 125 deletions
diff --git a/src/buildtool/common/repository_config.cpp b/src/buildtool/common/repository_config.cpp
index 9561f10b..e47fc8d3 100644
--- a/src/buildtool/common/repository_config.cpp
+++ b/src/buildtool/common/repository_config.cpp
@@ -172,28 +172,3 @@ void RepositoryConfig::SetPrecomputedRoot(PrecomputedRoot const& root,
}
}
}
-
-void RepositoryConfig::SetComputedRoot(FileRoot::ComputedRoot const& root,
- FileRoot const& value) {
- for (auto const& [name, desc] : repos_) {
- auto new_info = desc.info;
- bool changed = false;
- auto set_root_if_matching =
- [&changed, &root, &value](auto* candidate_root) {
- auto croot = candidate_root->GetComputedDescription();
- if (croot) {
- if (*croot == root) {
- *candidate_root = value;
- changed = true;
- }
- }
- };
- set_root_if_matching(&new_info.workspace_root);
- set_root_if_matching(&new_info.target_root);
- set_root_if_matching(&new_info.rule_root);
- set_root_if_matching(&new_info.expression_root);
- if (changed) {
- SetInfo(name, std::move(new_info));
- }
- }
-}
diff --git a/src/buildtool/common/repository_config.hpp b/src/buildtool/common/repository_config.hpp
index a4b61b9e..7e9ba88f 100644
--- a/src/buildtool/common/repository_config.hpp
+++ b/src/buildtool/common/repository_config.hpp
@@ -74,9 +74,6 @@ class RepositoryConfig {
/// \param value Root to be used as a replacement.
void SetPrecomputedRoot(PrecomputedRoot const& root, FileRoot const& value);
- void SetComputedRoot(FileRoot::ComputedRoot const& root,
- FileRoot const& value);
-
[[nodiscard]] auto Info(std::string const& repo) const noexcept
-> RepositoryInfo const* {
if (auto const* data = Data(repo)) {
diff --git a/src/buildtool/file_system/TARGETS b/src/buildtool/file_system/TARGETS
index ffd6af53..ad5a92dc 100644
--- a/src/buildtool/file_system/TARGETS
+++ b/src/buildtool/file_system/TARGETS
@@ -194,7 +194,6 @@
, ["src/buildtool/logging", "logging"]
, ["src/utils/cpp", "concepts"]
, ["src/utils/cpp", "expected"]
- , ["src/utils/cpp", "hash_combine"]
, ["src/utils/cpp", "json"]
]
, "stage": ["src", "buildtool", "file_system"]
diff --git a/src/buildtool/file_system/file_root.hpp b/src/buildtool/file_system/file_root.hpp
index e47b68f5..cabd2aae 100644
--- a/src/buildtool/file_system/file_root.hpp
+++ b/src/buildtool/file_system/file_root.hpp
@@ -16,7 +16,6 @@
#define INCLUDED_SRC_BUILDTOOL_FILE_SYSTEM_FILE_ROOT_HPP
#include <algorithm>
-#include <compare>
#include <cstddef>
#include <exception>
#include <filesystem>
@@ -47,7 +46,6 @@
#include "src/buildtool/logging/logger.hpp"
#include "src/utils/cpp/concepts.hpp"
#include "src/utils/cpp/expected.hpp"
-#include "src/utils/cpp/hash_combine.hpp"
// Keep it to ensure fmt::format works on JSON objects
#include "src/utils/cpp/json.hpp" // IWYU pragma: keep
@@ -114,52 +112,10 @@ class FileRoot {
gsl::not_null<GitTreePtr> tree;
};
- public:
- struct ComputedRoot {
- std::string repository;
- std::string target_module;
- std::string target_name;
- nlohmann::json config;
-
- [[nodiscard]] auto operator==(
- ComputedRoot const& other) const noexcept {
- return (repository == other.repository) and
- (target_module == other.target_module) and
- (target_name == other.target_name) and
- (config == other.config);
- }
-
- [[nodiscard]] auto operator<(ComputedRoot const& other) const noexcept {
- if (auto const res = repository <=> other.repository; res != 0) {
- return res < 0;
- }
- if (auto const res = target_module <=> other.target_module;
- res != 0) {
- return res < 0;
- }
- if (auto const res = target_name <=> other.target_name; res != 0) {
- return res < 0;
- }
- return config < other.config;
- }
-
- [[nodiscard]] auto ToString() const -> std::string {
- return fmt::format("([\"@\", {}, {}, {}], {})",
- nlohmann::json(repository).dump(),
- nlohmann::json(target_module).dump(),
- nlohmann::json(target_name).dump(),
- config.dump());
- }
- };
-
- private:
// absent roots are defined by a tree hash with no witnessing repository
using absent_root_t = std::string;
- using root_t = std::variant<fs_root_t,
- RootGit,
- absent_root_t,
- ComputedRoot,
- PrecomputedRoot>;
+ using root_t =
+ std::variant<fs_root_t, RootGit, absent_root_t, PrecomputedRoot>;
public:
static constexpr auto kGitTreeMarker = "git tree";
@@ -383,14 +339,6 @@ class FileRoot {
gsl::not_null<GitTreePtr> const& tree,
bool ignore_special = false) noexcept
: root_{RootGit{cas, tree}}, ignore_special_{ignore_special} {}
- FileRoot(std::string repository,
- std::string target_module,
- std::string target_name,
- nlohmann::json config) noexcept
- : root_{ComputedRoot{std::move(repository),
- std::move(target_module),
- std::move(target_name),
- std::move(config)}} {}
explicit FileRoot(PrecomputedRoot precomputed)
: root_{std::move(precomputed)} {}
@@ -705,22 +653,6 @@ class FileRoot {
return std::nullopt;
}
- [[nodiscard]] auto IsComputed() const noexcept -> bool {
- return std::holds_alternative<ComputedRoot>(root_);
- }
-
- [[nodiscard]] auto GetComputedDescription() const noexcept
- -> std::optional<ComputedRoot> {
- if (std::holds_alternative<ComputedRoot>(root_)) {
- try {
- return std::get<ComputedRoot>(root_);
- } catch (...) {
- return std::nullopt;
- }
- }
- return std::nullopt;
- }
-
[[nodiscard]] auto IgnoreSpecial() const noexcept -> bool {
return ignore_special_;
}
@@ -854,19 +786,4 @@ class FileRoot {
bool ignore_special_{};
};
-namespace std {
-template <>
-struct hash<FileRoot::ComputedRoot> {
- [[nodiscard]] auto operator()(FileRoot::ComputedRoot const& cr) const
- -> std::size_t {
- size_t seed{};
- hash_combine<std::string>(&seed, cr.repository);
- hash_combine<std::string>(&seed, cr.target_module);
- hash_combine<std::string>(&seed, cr.target_name);
- hash_combine<nlohmann::json>(&seed, cr.config);
- return seed;
- }
-};
-} // namespace std
-
#endif // INCLUDED_SRC_BUILDTOOL_FILE_SYSTEM_FILE_ROOT_HPP
diff --git a/src/other_tools/repo_map/TARGETS b/src/other_tools/repo_map/TARGETS
index 8958f84c..af80fa2f 100644
--- a/src/other_tools/repo_map/TARGETS
+++ b/src/other_tools/repo_map/TARGETS
@@ -23,6 +23,7 @@
, ["src/buildtool/crypto", "hash_function"]
, ["src/buildtool/crypto", "hash_info"]
, ["src/buildtool/file_system", "file_root"]
+ , ["src/buildtool/file_system", "precomputed_root"]
, ["src/buildtool/file_system/symlinks_map", "pragma_special"]
, ["src/buildtool/multithreading", "task_system"]
, ["src/other_tools/just_mr", "utils"]
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 1470297b..779406b4 100644
--- a/src/other_tools/repo_map/repos_to_setup_map.cpp
+++ b/src/other_tools/repo_map/repos_to_setup_map.cpp
@@ -26,6 +26,7 @@
#include "src/buildtool/crypto/hash_function.hpp"
#include "src/buildtool/crypto/hash_info.hpp"
#include "src/buildtool/file_system/file_root.hpp"
+#include "src/buildtool/file_system/precomputed_root.hpp"
#include "src/buildtool/file_system/symlinks_map/pragma_special.hpp"
#include "src/buildtool/multithreading/task_system.hpp"
#include "src/other_tools/just_mr/utils.hpp"
diff --git a/src/other_tools/utils/TARGETS b/src/other_tools/utils/TARGETS
index efeb5494..8e1803b9 100644
--- a/src/other_tools/utils/TARGETS
+++ b/src/other_tools/utils/TARGETS
@@ -103,7 +103,7 @@
, "deps":
[ ["@", "gsl", "", "gsl"]
, ["src/buildtool/build_engine/expression", "expression_ptr_interface"]
- , ["src/buildtool/file_system", "file_root"]
+ , ["src/buildtool/file_system", "precomputed_root"]
, ["src/utils/cpp", "expected"]
]
, "private-deps":
diff --git a/src/other_tools/utils/parse_computed_root.cpp b/src/other_tools/utils/parse_computed_root.cpp
index ccc01d92..540f43c0 100644
--- a/src/other_tools/utils/parse_computed_root.cpp
+++ b/src/other_tools/utils/parse_computed_root.cpp
@@ -50,7 +50,7 @@ auto ComputedRootParser::GetTargetRepository() const
}
auto ComputedRootParser::GetResult() const
- -> expected<FileRoot::ComputedRoot, std::string> {
+ -> expected<ComputedRoot, std::string> {
auto const repo = GetTargetRepository();
if (not repo) {
return unexpected{repo.error()};
@@ -77,10 +77,10 @@ auto ComputedRootParser::GetResult() const
return unexpected{fmt::format("Unsupported value {} for key \"config\"",
config->ToString())};
}
- return FileRoot::ComputedRoot{.repository = *repo,
- .target_module = target_module->String(),
- .target_name = target_module->String(),
- .config = config.IsNotNull()
- ? config->ToJson()
- : nlohmann::json::object()};
+ return ComputedRoot{.repository = *repo,
+ .target_module = target_module->String(),
+ .target_name = target_module->String(),
+ .config = config.IsNotNull()
+ ? config->ToJson()
+ : nlohmann::json::object()};
}
diff --git a/src/other_tools/utils/parse_computed_root.hpp b/src/other_tools/utils/parse_computed_root.hpp
index e23284da..2cc54c87 100644
--- a/src/other_tools/utils/parse_computed_root.hpp
+++ b/src/other_tools/utils/parse_computed_root.hpp
@@ -20,7 +20,7 @@
#include "gsl/gsl"
#include "src/buildtool/build_engine/expression/expression_ptr.hpp"
-#include "src/buildtool/file_system/file_root.hpp"
+#include "src/buildtool/file_system/precomputed_root.hpp"
#include "src/utils/cpp/expected.hpp"
class ComputedRootParser final {
@@ -36,8 +36,7 @@ class ComputedRootParser final {
[[nodiscard]] auto GetTargetRepository() const
-> expected<std::string, std::string>;
- [[nodiscard]] auto GetResult() const
- -> expected<FileRoot::ComputedRoot, std::string>;
+ [[nodiscard]] auto GetResult() const -> expected<ComputedRoot, std::string>;
private:
ExpressionPtr const& repository_;