summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKlaus Aehlig <klaus.aehlig@huawei.com>2023-11-17 13:01:28 +0100
committerOliver Reiche <oliver.reiche@huawei.com>2023-12-13 15:22:16 +0100
commite3f9b479cd43b5f7204403de83c8044523c4c432 (patch)
tree3aa2be83fd7d3f8f349ebcdd165b6b3b9c890bc4
parent975d0e9aadbbb8c3f67d2445f31d80122e054fe7 (diff)
downloadjustbuild-e3f9b479cd43b5f7204403de83c8044523c4c432.tar.gz
built-in "install" rule: verify well-formedness of resulting stage
The install target, like any other target, has to have artifacts and runfiles being proper stages, i.e., in such a way that the keys can be interpreted as names in the file system without causing conflicts. This property used to be unchecked, thus allowing users to define mal-formed targets that, when used as inputs to actions, would result in unspecified layout of the action directory. Fix this by adding an appropriate check enforcing well-formedness of the resulting stage. (cherry picked from f66db4bb21efeead140a453f91280bb9471f24a9)
-rw-r--r--CHANGELOG.md5
-rw-r--r--src/buildtool/build_engine/target_map/built_in_rules.cpp5
2 files changed, 10 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 27c95c44..f0220b16 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,11 @@
Bug fixes on top of release `1.2.3`.
+### Fixes
+
+- The built-in rule `"install"` now properly enforces that the
+ resulting stage is well-formed, i.e., without tree conflicts.
+
## Release `1.2.3` (2023-11-15)
Bug fixes on top of release `1.2.2`.
diff --git a/src/buildtool/build_engine/target_map/built_in_rules.cpp b/src/buildtool/build_engine/target_map/built_in_rules.cpp
index 29eba7bf..6d55784f 100644
--- a/src/buildtool/build_engine/target_map/built_in_rules.cpp
+++ b/src/buildtool/build_engine/target_map/built_in_rules.cpp
@@ -665,6 +665,11 @@ void InstallRuleWithDeps(
stage = ExpressionPtr{Expression::map_t{stage, to_stage}};
}
+ auto conflict = BuildMaps::Target::Utils::tree_conflict(stage);
+ if (conflict) {
+ (*logger)(fmt::format("TREE conflict on subtree {}", *conflict), true);
+ return;
+ }
auto const& empty_map = Expression::kEmptyMap;
auto result = std::make_shared<AnalysedTarget const>(
TargetResult{