From c5ea015b57344063000015e7f1e18bf5f14337f3 Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Fri, 23 Aug 2024 16:12:24 +0200 Subject: Rule "generic": verify that the output is a properly formed artifact stage --- CHANGELOG.md | 3 +++ src/buildtool/build_engine/target_map/built_in_rules.cpp | 16 ++++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 22581d9e..3c53b23a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,9 @@ A feature release on top of `1.3.0`, backwards compatible. ### Fixes +- The built-in rule `"generic"` now properly enforces that the + obtained outputs form a well-formed artifact stage; a conflicting + arrangement of artifacts was possilbe beforehand. - A bug was fixed that cased `just serve` to fail with an internal error when building against ignore-special roots. - `just` now accurately reports internal errors that occurred on 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 51664549..94da5991 100644 --- a/src/buildtool/build_engine/target_map/built_in_rules.cpp +++ b/src/buildtool/build_engine/target_map/built_in_rules.cpp @@ -1387,13 +1387,21 @@ void GenericRuleWithDeps( action_identifier, std::filesystem::path{path})}); } } + auto artifacts_stage = ExpressionPtr{Expression::map_t{artifacts}}; + auto artifacts_conflict = + BuildMaps::Target::Utils::tree_conflict(artifacts_stage); + if (artifacts_conflict) { + (*logger)(fmt::format("artifacts have staging conflicts on {}", + nlohmann::json(*artifacts_conflict).dump()), + /*fatal=*/true); + return; + } auto const& empty_map = Expression::kEmptyMap; auto result = std::make_shared( - TargetResult{ - .artifact_stage = ExpressionPtr{Expression::map_t{artifacts}}, - .provides = empty_map, - .runfiles = empty_map}, + TargetResult{.artifact_stage = std::move(artifacts_stage), + .provides = empty_map, + .runfiles = empty_map}, std::vector{action}, std::vector{}, std::move(trees), -- cgit v1.2.3