Skip to content

Commit

Permalink
Don't keep a reference to the full AspectValue in AspectCompleteEvent.
Browse files Browse the repository at this point in the history
This makes AspectCompleteEvent a lightweight data object instead, which is nicer.

RELNOTES: None.
PiperOrigin-RevId: 359711784
  • Loading branch information
lberki authored and philwo committed Feb 26, 2021
1 parent de8f69d commit 7b3f56d
Showing 1 changed file with 23 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,34 @@
import com.google.devtools.build.lib.buildeventstream.BuildEventWithOrderConstraint;
import com.google.devtools.build.lib.buildeventstream.GenericBuildEvent;
import com.google.devtools.build.lib.causes.Cause;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
import com.google.devtools.build.lib.collect.nestedset.Order;
import com.google.devtools.build.lib.packages.AspectDescriptor;
import com.google.devtools.build.skyframe.SkyValue;
import java.util.Collection;

/** This event is fired as soon as a top-level aspect is either built or fails. */
public class AspectCompleteEvent
implements SkyValue, BuildEventWithOrderConstraint, EventReportingArtifacts {
private final AspectValue aspectValue;
private final Label label;
private final AspectDescriptor descriptor;
private final NestedSet<Cause> rootCauses;
private final Collection<BuildEventId> postedAfter;
private final CompletionContext completionContext;
private final NestedSet<ArtifactsInOutputGroup> artifactOutputGroups;
private final BuildEventId configurationEventId;

private AspectCompleteEvent(
AspectValue aspectValue,
Label label,
AspectDescriptor descriptor,
NestedSet<Cause> rootCauses,
CompletionContext completionContext,
NestedSet<ArtifactsInOutputGroup> artifactOutputGroups,
BuildEventId configurationEventId) {
this.aspectValue = aspectValue;
this.label = label;
this.descriptor = descriptor;
this.rootCauses =
(rootCauses == null) ? NestedSetBuilder.<Cause>emptySet(Order.STABLE_ORDER) : rootCauses;
ImmutableList.Builder<BuildEventId> postedAfterBuilder = ImmutableList.builder();
Expand All @@ -70,7 +75,13 @@ public static AspectCompleteEvent createSuccessful(
CompletionContext completionContext,
NestedSet<ArtifactsInOutputGroup> artifacts,
BuildEventId configurationEventId) {
return new AspectCompleteEvent(value, null, completionContext, artifacts, configurationEventId);
return new AspectCompleteEvent(
value.getKey().getLabel(),
value.getAspect().getDescriptor(),
null,
completionContext,
artifacts,
configurationEventId);
}

/**
Expand All @@ -83,14 +94,13 @@ public static AspectCompleteEvent createFailed(
BuildEventId configurationEventId,
NestedSet<ArtifactsInOutputGroup> outputs) {
Preconditions.checkArgument(!rootCauses.isEmpty());
return new AspectCompleteEvent(value, rootCauses, ctx, outputs, configurationEventId);
}

/**
* Returns the target associated with the event.
*/
public AspectValue getAspectValue() {
return aspectValue;
return new AspectCompleteEvent(
value.getKey().getLabel(),
value.getAspect().getDescriptor(),
rootCauses,
ctx,
outputs,
configurationEventId);
}

/**
Expand All @@ -108,9 +118,7 @@ public NestedSet<Cause> getRootCauses() {
@Override
public BuildEventId getEventId() {
return BuildEventIdUtil.aspectCompleted(
aspectValue.getKey().getLabel(),
configurationEventId,
aspectValue.getAspect().getDescriptor().getDescription());
label, configurationEventId, descriptor.getDescription());
}

@Override
Expand Down

0 comments on commit 7b3f56d

Please sign in to comment.