diff options
author | Klaus Aehlig <klaus.aehlig@huawei.com> | 2022-05-05 14:26:36 +0200 |
---|---|---|
committer | Klaus Aehlig <klaus.aehlig@huawei.com> | 2022-05-09 14:55:40 +0200 |
commit | 5d89525367527b659fe9732c4ed90b4e9c2f3658 (patch) | |
tree | c2928137678014ba5aadc95e7a13f7250abc6f8a /src/buildtool/build_engine/target_map/utils.cpp | |
parent | 39714825086c40c43345379c95f181a1957d6080 (diff) | |
download | justbuild-5d89525367527b659fe9732c4ed90b4e9c2f3658.tar.gz |
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.
Diffstat (limited to 'src/buildtool/build_engine/target_map/utils.cpp')
-rw-r--r-- | src/buildtool/build_engine/target_map/utils.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
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<std::string, ExpressionPtr> { + 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::string> { std::vector<std::filesystem::path> trees{}; |