From 5d89525367527b659fe9732c4ed90b4e9c2f3658 Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Thu, 5 May 2022 14:26:36 +0200 Subject: Verify conflict-freeness in inputs, artifacts, and runfiles Our maps serve two purposes: on the one hand, they can be a generic key-value association with arbitrary strings as keys. On the other hand, we use them to describe arrangements of files (inputs to actions, artifacts or runfiles generated). In this function, certain keys refer to the same path and hence have to be identifed. Therefore, at places where the keys clearly have to be paths in the file system, implicitly normalize them and check for conflicts. --- src/buildtool/build_engine/target_map/utils.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/buildtool/build_engine/target_map/utils.cpp') diff --git a/src/buildtool/build_engine/target_map/utils.cpp b/src/buildtool/build_engine/target_map/utils.cpp index 2368f03e..bdd5dd11 100644 --- a/src/buildtool/build_engine/target_map/utils.cpp +++ b/src/buildtool/build_engine/target_map/utils.cpp @@ -75,6 +75,20 @@ auto BuildMaps::Target::Utils::keys_expr(const ExpressionPtr& map) return ExpressionPtr{result}; } +auto BuildMaps::Target::Utils::artifacts_tree(const ExpressionPtr& map) + -> std::variant { + auto result = Expression::map_t::underlying_map_t{}; + for (auto const& [key, artifact] : map->Map()) { + auto location = ToNormalPath(std::filesystem::path{key}).string(); + if (auto it = result.find(location); + it != result.end() && !(it->second == artifact)) { + return location; + } + result.emplace(std::move(location), artifact); + } + return ExpressionPtr{Expression::map_t{result}}; +} + auto BuildMaps::Target::Utils::tree_conflict(const ExpressionPtr& map) -> std::optional { std::vector trees{}; -- cgit v1.2.3