From 7b3f56d8e6987c6d0918b520f64e6ae1ee08c5ce Mon Sep 17 00:00:00 2001 From: lberki Date: Fri, 26 Feb 2021 10:36:26 +0100 Subject: [PATCH] Don't keep a reference to the full AspectValue in AspectCompleteEvent. This makes AspectCompleteEvent a lightweight data object instead, which is nicer. RELNOTES: None. PiperOrigin-RevId: 359711784 --- .../lib/analysis/AspectCompleteEvent.java | 38 +++++++++++-------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/google/devtools/build/lib/analysis/AspectCompleteEvent.java b/src/main/java/com/google/devtools/build/lib/analysis/AspectCompleteEvent.java index f19fe144756b04..33d7a391494792 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/AspectCompleteEvent.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/AspectCompleteEvent.java @@ -29,16 +29,19 @@ 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 rootCauses; private final Collection postedAfter; private final CompletionContext completionContext; @@ -46,12 +49,14 @@ public class AspectCompleteEvent private final BuildEventId configurationEventId; private AspectCompleteEvent( - AspectValue aspectValue, + Label label, + AspectDescriptor descriptor, NestedSet rootCauses, CompletionContext completionContext, NestedSet artifactOutputGroups, BuildEventId configurationEventId) { - this.aspectValue = aspectValue; + this.label = label; + this.descriptor = descriptor; this.rootCauses = (rootCauses == null) ? NestedSetBuilder.emptySet(Order.STABLE_ORDER) : rootCauses; ImmutableList.Builder postedAfterBuilder = ImmutableList.builder(); @@ -70,7 +75,13 @@ public static AspectCompleteEvent createSuccessful( CompletionContext completionContext, NestedSet artifacts, BuildEventId configurationEventId) { - return new AspectCompleteEvent(value, null, completionContext, artifacts, configurationEventId); + return new AspectCompleteEvent( + value.getKey().getLabel(), + value.getAspect().getDescriptor(), + null, + completionContext, + artifacts, + configurationEventId); } /** @@ -83,14 +94,13 @@ public static AspectCompleteEvent createFailed( BuildEventId configurationEventId, NestedSet 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); } /** @@ -108,9 +118,7 @@ public NestedSet getRootCauses() { @Override public BuildEventId getEventId() { return BuildEventIdUtil.aspectCompleted( - aspectValue.getKey().getLabel(), - configurationEventId, - aspectValue.getAspect().getDescriptor().getDescription()); + label, configurationEventId, descriptor.getDescription()); } @Override