summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKlaus Aehlig <klaus.aehlig@huawei.com>2025-01-24 12:12:00 +0100
committerKlaus Aehlig <klaus.aehlig@huawei.com>2025-02-05 12:03:46 +0100
commit4fa29293c42891f7398f7974c2a588cdca9dc472 (patch)
treedf0961eb97b87d6152cf90ab5353bf86a4cceff6 /src
parent34f9a89ba329dd0d64790a276fb1a4813c9c06c1 (diff)
downloadjustbuild-4fa29293c42891f7398f7974c2a588cdca9dc472.tar.gz
"generic" rule: verify staging conflicts on inputs
The "generic" rules deliberately resolves conflicts on identical paths in a latest-wins fashion (seeing all artifacts as later than all runfiles) to allow an easy way to define actions. However, the inputs stage obtained by this resolution can still contain conflicts and those are an error. Properly detect those. Also clarify in the documentation, that only conflicts on identical paths are resolved in the described priority, not semantic overlap. (cherry-picked from 5e104a526cf76fe75312d2fd288a3c88f506fb0a)
Diffstat (limited to 'src')
-rw-r--r--src/buildtool/build_engine/target_map/built_in_rules.cpp9
1 files changed, 9 insertions, 0 deletions
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 9623f816..a227c30b 100644
--- a/src/buildtool/build_engine/target_map/built_in_rules.cpp
+++ b/src/buildtool/build_engine/target_map/built_in_rules.cpp
@@ -1351,9 +1351,18 @@ void GenericRuleWithDeps(
for (auto const& dep : dependency_values) {
inputs = ExpressionPtr{Expression::map_t{inputs, (*dep)->RunFiles()}};
}
+ auto inputs_conflict = BuildMaps::Target::Utils::tree_conflict(inputs);
for (auto const& dep : dependency_values) {
inputs = ExpressionPtr{Expression::map_t{inputs, (*dep)->Artifacts()}};
}
+ // While syntactical conflicts are resolved in a latest wins (with artifacts
+ // after runfiles), semantic path conclicts are an error.
+ if (inputs_conflict) {
+ (*logger)(fmt::format("Input artifacts have staging conflict on {}",
+ nlohmann::json(*inputs_conflict).dump()),
+ /*fatal=*/true);
+ return;
+ }
std::vector<Tree::Ptr> trees{};
inputs = BuildMaps::Target::Utils::add_dir_for(
cwd_value->String(), inputs, &trees);