Skip to content

Commit

Permalink
Rule "generic": verify that the output is a properly formed artifact …
Browse files Browse the repository at this point in the history
…stage
  • Loading branch information
aehlig committed Aug 23, 2024
1 parent 56d7eef commit c5ea015
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 12 additions & 4 deletions src/buildtool/build_engine/target_map/built_in_rules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<AnalysedTarget const>(
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<ActionDescription::Ptr>{action},
std::vector<std::string>{},
std::move(trees),
Expand Down

0 comments on commit c5ea015

Please sign in to comment.