Filtering the legacy important_outputs field in the BEP by source, middleman
This change makes the field match the semantics of the legacy mechanism that
is not open source. This is intended for migration only and the field should
not be used otherwise (that is why the field is deprecated).
PiperOrigin-RevId: 196817282
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/TargetCompleteEvent.java b/src/main/java/com/google/devtools/build/lib/analysis/TargetCompleteEvent.java
index 49e470c..d8b09c9 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/TargetCompleteEvent.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/TargetCompleteEvent.java
@@ -64,14 +64,14 @@
private final ConfiguredTargetAndData targetAndData;
private final NestedSet<Cause> rootCauses;
private final ImmutableList<BuildEventId> postedAfter;
- private final Iterable<ArtifactsInOutputGroup> outputs;
+ private final NestedSet<ArtifactsInOutputGroup> outputs;
private final NestedSet<Artifact> baselineCoverageArtifacts;
private final boolean isTest;
private TargetCompleteEvent(
ConfiguredTargetAndData targetAndData,
NestedSet<Cause> rootCauses,
- Iterable<ArtifactsInOutputGroup> outputs,
+ NestedSet<ArtifactsInOutputGroup> outputs,
boolean isTest) {
this.targetAndData = targetAndData;
this.rootCauses =
@@ -122,7 +122,8 @@
public static TargetCompleteEvent createFailed(
ConfiguredTargetAndData ct, NestedSet<Cause> rootCauses) {
Preconditions.checkArgument(!Iterables.isEmpty(rootCauses));
- return new TargetCompleteEvent(ct, rootCauses, ImmutableList.of(), false);
+ return new TargetCompleteEvent(
+ ct, rootCauses, NestedSetBuilder.emptySet(Order.STABLE_ORDER), false);
}
/** Returns the target associated with the event. */
@@ -140,6 +141,19 @@
return rootCauses;
}
+ public Iterable<Artifact> getLegacyFilteredImportantArtifacts() {
+ // TODO(ulfjack): This duplicates code in ArtifactsToBuild.
+ NestedSetBuilder<Artifact> builder = new NestedSetBuilder<>(outputs.getOrder());
+ for (ArtifactsInOutputGroup artifactsInOutputGroup : outputs) {
+ if (artifactsInOutputGroup.areImportant()) {
+ builder.addTransitive(artifactsInOutputGroup.getArtifacts());
+ }
+ }
+ return Iterables.filter(
+ builder.build(),
+ (artifact) -> !artifact.isSourceArtifact() && !artifact.isMiddlemanArtifact());
+ }
+
@Override
public BuildEventId getEventId() {
Label label = getTarget().getLabel();
@@ -218,11 +232,7 @@
// TODO(aehlig): remove direct reporting of artifacts as soon as clients no longer
// need it.
- for (ArtifactsInOutputGroup group : outputs) {
- if (group.areImportant()) {
- addImportantOutputs(builder, converters, group.getArtifacts());
- }
- }
+ addImportantOutputs(builder, converters, getLegacyFilteredImportantArtifacts());
if (baselineCoverageArtifacts != null) {
addImportantOutputs(
builder, (artifact -> BASELINE_COVERAGE), converters, baselineCoverageArtifacts);