diff options
author | 2018-02-13 13:00:52 -0800 | |
---|---|---|
committer | 2018-02-13 13:02:45 -0800 | |
commit | 14dbe1392a085bf8a8b9528c5caab55de47325d1 (patch) | |
tree | ddf4ab608062877a8a81705f4ad6972815a72dca /src/main/java/com/google/devtools/build/lib/analysis/TargetCompleteEvent.java | |
parent | 1b78769afd36b979a1e29116f5878551bdd29ddd (diff) |
Get rid of the last reference to getAttributeMapper by keeping packages which
are referenced by TopLevelTargets when we discard the analysis cache.
PiperOrigin-RevId: 185574670
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/analysis/TargetCompleteEvent.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/analysis/TargetCompleteEvent.java | 40 |
1 files changed, 23 insertions, 17 deletions
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 1a597212b8..753ce7091e 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 @@ -43,6 +43,9 @@ import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder; import com.google.devtools.build.lib.collect.nestedset.NestedSetView; import com.google.devtools.build.lib.collect.nestedset.Order; import com.google.devtools.build.lib.packages.AttributeMap; +import com.google.devtools.build.lib.packages.ConfiguredAttributeMapper; +import com.google.devtools.build.lib.packages.Rule; +import com.google.devtools.build.lib.packages.Target; import com.google.devtools.build.lib.packages.TestSize; import com.google.devtools.build.lib.rules.AliasConfiguredTarget; import com.google.devtools.build.lib.syntax.Type; @@ -56,6 +59,7 @@ public final class TargetCompleteEvent EventReportingArtifacts, BuildEventWithConfiguration { private final ConfiguredTarget target; + private final Target actualTarget; private final NestedSet<Cause> rootCauses; private final ImmutableList<BuildEventId> postedAfter; private final Iterable<ArtifactsInOutputGroup> outputs; @@ -64,10 +68,12 @@ public final class TargetCompleteEvent private TargetCompleteEvent( ConfiguredTarget target, + Target actualTarget, NestedSet<Cause> rootCauses, Iterable<ArtifactsInOutputGroup> outputs, boolean isTest) { this.target = target; + this.actualTarget = actualTarget; this.rootCauses = (rootCauses == null) ? NestedSetBuilder.<Cause>emptySet(Order.STABLE_ORDER) : rootCauses; @@ -100,35 +106,33 @@ public final class TargetCompleteEvent /** Construct a successful target completion event. */ public static TargetCompleteEvent successfulBuild( - ConfiguredTarget ct, NestedSet<ArtifactsInOutputGroup> outputs) { - return new TargetCompleteEvent(ct, null, outputs, false); + ConfiguredTarget ct, Target target, NestedSet<ArtifactsInOutputGroup> outputs) { + return new TargetCompleteEvent(ct, target, null, outputs, false); } /** Construct a successful target completion event for a target that will be tested. */ - public static TargetCompleteEvent successfulBuildSchedulingTest(ConfiguredTarget ct) { - return new TargetCompleteEvent(ct, null, ImmutableList.<ArtifactsInOutputGroup>of(), true); + public static TargetCompleteEvent successfulBuildSchedulingTest( + ConfiguredTarget ct, Target target) { + return new TargetCompleteEvent( + ct, target, null, ImmutableList.<ArtifactsInOutputGroup>of(), true); } - /** * Construct a target completion event for a failed target, with the given non-empty root causes. */ - public static TargetCompleteEvent createFailed(ConfiguredTarget ct, NestedSet<Cause> rootCauses) { + public static TargetCompleteEvent createFailed( + ConfiguredTarget ct, Target target, NestedSet<Cause> rootCauses) { Preconditions.checkArgument(!Iterables.isEmpty(rootCauses)); return new TargetCompleteEvent( - ct, rootCauses, ImmutableList.<ArtifactsInOutputGroup>of(), false); + ct, target, rootCauses, ImmutableList.<ArtifactsInOutputGroup>of(), false); } - /** - * Returns the target associated with the event. - */ + /** Returns the target associated with the event. */ public ConfiguredTarget getTarget() { return target; } - /** - * Determines whether the target has failed or succeeded. - */ + /** Determines whether the target has failed or succeeded. */ public boolean failed() { return !rootCauses.isEmpty(); } @@ -160,7 +164,7 @@ public final class TargetCompleteEvent // For tests, announce all the test actions that will minimally happen (except for // interruption). If after the result of a test action another attempt is necessary, // it will be announced with the action that made the new attempt necessary. - Label label = target.getTarget().getLabel(); + Label label = target.getLabel(); TestProvider.TestParams params = target.getProvider(TestProvider.class).getTestParams(); for (int run = 0; run < Math.max(params.getRuns(), 1); run++) { for (int shard = 0; shard < Math.max(params.getShards(), 1); shard++) { @@ -192,14 +196,14 @@ public final class TargetCompleteEvent BuildEventStreamProtos.TargetComplete.newBuilder(); builder.setSuccess(!failed()); - builder.setTargetKind(target.getTarget().getTargetKind()); + builder.setTargetKind(actualTarget.getTargetKind()); builder.addAllTag(getTags()); builder.addAllOutputGroup(getOutputFilesByGroup(converters.artifactGroupNamer())); if (isTest) { builder.setTestSize( TargetConfiguredEvent.bepTestSize( - TestSize.getTestSize(target.getTarget().getAssociatedRule()))); + TestSize.getTestSize(actualTarget.getAssociatedRule()))); } // TODO(aehlig): remove direct reporting of artifacts as soon as clients no longer @@ -250,7 +254,9 @@ public final class TargetCompleteEvent if (!(target instanceof RuleConfiguredTarget)) { return ImmutableList.<String>of(); } - AttributeMap attributes = ((RuleConfiguredTarget) target).getAttributeMapper(); + AttributeMap attributes = + ConfiguredAttributeMapper.of( + (Rule) actualTarget, ((RuleConfiguredTarget) target).getConfigConditions()); // Every rule (implicitly) has a "tags" attribute. return attributes.get("tags", Type.STRING_LIST); } |