aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/analysis/TargetCompleteEvent.java
diff options
context:
space:
mode:
authorGravatar janakr <janakr@google.com>2018-03-27 10:26:36 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-03-27 10:27:58 -0700
commit60554e40665c44e0f0423eb43183db3ea7c69514 (patch)
tree4a30f8ddb04d3ec7940595c2034094eeb22e2341 /src/main/java/com/google/devtools/build/lib/analysis/TargetCompleteEvent.java
parente666d3b88efb59f2a8f10b18882c9f13801508d9 (diff)
Get rid of a few more #getConfiguration() calls. We're now passing a ConfiguredTargetAndData into TargetCompleteEvent, which seems reasonable.
PiperOrigin-RevId: 190634162
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.java62
1 files changed, 31 insertions, 31 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 aeba06b462..97dde9c546 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
@@ -46,9 +46,9 @@ 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.skyframe.ConfiguredTargetAndData;
import com.google.devtools.build.lib.syntax.Type;
import com.google.devtools.build.skyframe.SkyValue;
import java.util.Collection;
@@ -60,8 +60,7 @@ public final class TargetCompleteEvent
BuildEventWithOrderConstraint,
EventReportingArtifacts,
BuildEventWithConfiguration {
- private final ConfiguredTarget target;
- private final Target actualTarget;
+ private final ConfiguredTargetAndData targetAndData;
private final NestedSet<Cause> rootCauses;
private final ImmutableList<BuildEventId> postedAfter;
private final Iterable<ArtifactsInOutputGroup> outputs;
@@ -69,20 +68,18 @@ public final class TargetCompleteEvent
private final boolean isTest;
private TargetCompleteEvent(
- ConfiguredTarget target,
- Target actualTarget,
+ ConfiguredTargetAndData targetAndData,
NestedSet<Cause> rootCauses,
Iterable<ArtifactsInOutputGroup> outputs,
boolean isTest) {
- this.target = target;
- this.actualTarget = actualTarget;
+ this.targetAndData = targetAndData;
this.rootCauses =
(rootCauses == null) ? NestedSetBuilder.<Cause>emptySet(Order.STABLE_ORDER) : rootCauses;
ImmutableList.Builder<BuildEventId> postedAfterBuilder = ImmutableList.builder();
Label label = getTarget().getLabel();
- if (target instanceof AliasConfiguredTarget) {
- label = ((AliasConfiguredTarget) target).getOriginalLabel();
+ if (targetAndData.getConfiguredTarget() instanceof AliasConfiguredTarget) {
+ label = ((AliasConfiguredTarget) targetAndData.getConfiguredTarget()).getOriginalLabel();
}
postedAfterBuilder.add(BuildEventId.targetConfigured(label));
for (Cause cause : getRootCauses()) {
@@ -92,7 +89,7 @@ public final class TargetCompleteEvent
this.outputs = outputs;
this.isTest = isTest;
InstrumentedFilesProvider instrumentedFilesProvider =
- this.target.getProvider(InstrumentedFilesProvider.class);
+ this.targetAndData.getConfiguredTarget().getProvider(InstrumentedFilesProvider.class);
if (instrumentedFilesProvider == null) {
this.baselineCoverageArtifacts = null;
} else {
@@ -108,29 +105,28 @@ public final class TargetCompleteEvent
/** Construct a successful target completion event. */
public static TargetCompleteEvent successfulBuild(
- ConfiguredTarget ct, Target target, NestedSet<ArtifactsInOutputGroup> outputs) {
- return new TargetCompleteEvent(ct, target, null, outputs, false);
+ ConfiguredTargetAndData ct, NestedSet<ArtifactsInOutputGroup> outputs) {
+ return new TargetCompleteEvent(ct, null, outputs, false);
}
/** Construct a successful target completion event for a target that will be tested. */
public static TargetCompleteEvent successfulBuildSchedulingTest(
- ConfiguredTarget ct, Target target, NestedSet<ArtifactsInOutputGroup> outputs) {
- return new TargetCompleteEvent(ct, target, null, outputs, true);
+ ConfiguredTargetAndData ct, NestedSet<ArtifactsInOutputGroup> outputs) {
+ return new TargetCompleteEvent(ct, null, outputs, true);
}
/**
* Construct a target completion event for a failed target, with the given non-empty root causes.
*/
public static TargetCompleteEvent createFailed(
- ConfiguredTarget ct, Target target, NestedSet<Cause> rootCauses) {
+ ConfiguredTargetAndData ct, NestedSet<Cause> rootCauses) {
Preconditions.checkArgument(!Iterables.isEmpty(rootCauses));
- return new TargetCompleteEvent(
- ct, target, rootCauses, ImmutableList.<ArtifactsInOutputGroup>of(), false);
+ return new TargetCompleteEvent(ct, rootCauses, ImmutableList.of(), false);
}
/** Returns the target associated with the event. */
public ConfiguredTarget getTarget() {
- return target;
+ return targetAndData.getConfiguredTarget();
}
/** Determines whether the target has failed or succeeded. */
@@ -146,10 +142,10 @@ public final class TargetCompleteEvent
@Override
public BuildEventId getEventId() {
Label label = getTarget().getLabel();
- if (target instanceof AliasConfiguredTarget) {
- label = ((AliasConfiguredTarget) target).getOriginalLabel();
+ if (targetAndData.getConfiguredTarget() instanceof AliasConfiguredTarget) {
+ label = ((AliasConfiguredTarget) targetAndData.getConfiguredTarget()).getOriginalLabel();
}
- BuildConfiguration config = getTarget().getConfiguration();
+ BuildConfiguration config = targetAndData.getConfiguration();
BuildEventId configId =
config == null ? BuildEventId.nullConfigurationId() : config.getEventId();
return BuildEventId.targetCompleted(label, configId);
@@ -165,15 +161,18 @@ 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.getLabel();
- TestProvider.TestParams params = target.getProvider(TestProvider.class).getTestParams();
+ Label label = targetAndData.getConfiguredTarget().getLabel();
+ TestProvider.TestParams params =
+ targetAndData.getConfiguredTarget().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++) {
childrenBuilder.add(
- BuildEventId.testResult(label, run, shard, target.getConfiguration().getEventId()));
+ BuildEventId.testResult(
+ label, run, shard, targetAndData.getConfiguration().getEventId()));
}
}
- childrenBuilder.add(BuildEventId.testSummary(label, target.getConfiguration().getEventId()));
+ childrenBuilder.add(
+ BuildEventId.testSummary(label, targetAndData.getConfiguration().getEventId()));
}
return childrenBuilder.build();
}
@@ -205,14 +204,14 @@ public final class TargetCompleteEvent
BuildEventStreamProtos.TargetComplete.newBuilder();
builder.setSuccess(!failed());
- builder.setTargetKind(actualTarget.getTargetKind());
+ builder.setTargetKind(targetAndData.getTarget().getTargetKind());
builder.addAllTag(getTags());
builder.addAllOutputGroup(getOutputFilesByGroup(converters.artifactGroupNamer()));
if (isTest) {
builder.setTestSize(
TargetConfiguredEvent.bepTestSize(
- TestSize.getTestSize(actualTarget.getAssociatedRule())));
+ TestSize.getTestSize(targetAndData.getTarget().getAssociatedRule())));
}
// TODO(aehlig): remove direct reporting of artifacts as soon as clients no longer
@@ -251,9 +250,9 @@ public final class TargetCompleteEvent
@Override
public Collection<BuildEvent> getConfigurations() {
- BuildConfiguration configuration = target.getConfiguration();
+ BuildConfiguration configuration = targetAndData.getConfiguration();
if (configuration != null) {
- return ImmutableList.of(target.getConfiguration().toBuildEvent());
+ return ImmutableList.of(targetAndData.getConfiguration().toBuildEvent());
} else {
return ImmutableList.<BuildEvent>of();
}
@@ -261,12 +260,13 @@ public final class TargetCompleteEvent
private Iterable<String> getTags() {
// We are only interested in targets that are rules.
- if (!(target instanceof RuleConfiguredTarget)) {
+ if (!(targetAndData.getConfiguredTarget() instanceof RuleConfiguredTarget)) {
return ImmutableList.<String>of();
}
AttributeMap attributes =
ConfiguredAttributeMapper.of(
- (Rule) actualTarget, ((RuleConfiguredTarget) target).getConfigConditions());
+ (Rule) targetAndData.getTarget(),
+ ((RuleConfiguredTarget) targetAndData.getConfiguredTarget()).getConfigConditions());
// Every rule (implicitly) has a "tags" attribute.
return attributes.get("tags", Type.STRING_LIST);
}