diff options
Diffstat (limited to 'src/main/java/com')
6 files changed, 109 insertions, 8 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/BuildView.java b/src/main/java/com/google/devtools/build/lib/analysis/BuildView.java index 60a694636e..382ba82dee 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/BuildView.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/BuildView.java @@ -476,6 +476,16 @@ public class BuildView { List<TargetAndConfiguration> topLevelTargetsWithConfigs = nodesForTopLevelTargets(configurations, targets, eventHandler); + // Report the generated association of targets to configurations + Multimap<Label, BuildConfiguration> byLabel = + ArrayListMultimap.<Label, BuildConfiguration>create(); + for (TargetAndConfiguration pair : topLevelTargetsWithConfigs) { + byLabel.put(pair.getLabel(), pair.getConfiguration()); + } + for (Label label : byLabel.keySet()) { + eventBus.post(new TargetConfiguredEvent(label, byLabel.get(label))); + } + List<ConfiguredTargetKey> topLevelCtKeys = Lists.transform(topLevelTargetsWithConfigs, new Function<TargetAndConfiguration, ConfiguredTargetKey>() { @Override @@ -484,6 +494,7 @@ public class BuildView { } }); + List<AspectValueKey> aspectKeys = new ArrayList<>(); for (String aspect : aspects) { // Syntax: label%aspect 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 f296202635..f28713fc2c 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 @@ -20,6 +20,8 @@ import com.google.common.collect.Iterables; import com.google.devtools.build.lib.actions.Artifact; import com.google.devtools.build.lib.actions.EventReportingArtifacts; import com.google.devtools.build.lib.analysis.TopLevelArtifactHelper.ArtifactsInOutputGroup; +import com.google.devtools.build.lib.analysis.config.BuildConfiguration; +import com.google.devtools.build.lib.analysis.config.BuildEventWithConfiguration; import com.google.devtools.build.lib.buildeventstream.ArtifactGroupNamer; import com.google.devtools.build.lib.buildeventstream.BuildEventConverters; import com.google.devtools.build.lib.buildeventstream.BuildEventId; @@ -43,8 +45,10 @@ import java.util.Collection; /** This event is fired as soon as a target is either built or fails. */ public final class TargetCompleteEvent - implements SkyValue, BuildEventWithOrderConstraint, EventReportingArtifacts { - + implements SkyValue, + BuildEventWithOrderConstraint, + EventReportingArtifacts, + BuildEventWithConfiguration { private final ConfiguredTarget target; private final NestedSet<Cause> rootCauses; private final Collection<BuildEventId> postedAfter; @@ -111,7 +115,8 @@ public final class TargetCompleteEvent @Override public BuildEventId getEventId() { - return BuildEventId.targetCompleted(getTarget().getLabel()); + return BuildEventId.targetCompleted( + getTarget().getLabel(), getTarget().getConfiguration().getEventId()); } @Override @@ -177,6 +182,16 @@ public final class TargetCompleteEvent return builder.build(); } + @Override + public Collection<BuildConfiguration> getConfigurations() { + BuildConfiguration configuration = target.getConfiguration(); + if (configuration != null) { + return ImmutableList.of(target.getConfiguration()); + } else { + return ImmutableList.<BuildConfiguration>of(); + } + } + private Iterable<String> getTags() { // We are only interested in targets that are rules. if (!(target instanceof RuleConfiguredTarget)) { diff --git a/src/main/java/com/google/devtools/build/lib/analysis/TargetConfiguredEvent.java b/src/main/java/com/google/devtools/build/lib/analysis/TargetConfiguredEvent.java new file mode 100644 index 0000000000..8606afe708 --- /dev/null +++ b/src/main/java/com/google/devtools/build/lib/analysis/TargetConfiguredEvent.java @@ -0,0 +1,61 @@ +// Copyright 2017 The Bazel Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package com.google.devtools.build.lib.analysis; + +import com.google.common.collect.ImmutableList; +import com.google.devtools.build.lib.analysis.config.BuildConfiguration; +import com.google.devtools.build.lib.analysis.config.BuildEventWithConfiguration; +import com.google.devtools.build.lib.buildeventstream.BuildEventConverters; +import com.google.devtools.build.lib.buildeventstream.BuildEventId; +import com.google.devtools.build.lib.buildeventstream.BuildEventStreamProtos; +import com.google.devtools.build.lib.buildeventstream.GenericBuildEvent; +import com.google.devtools.build.lib.cmdline.Label; +import java.util.Collection; + +/** Event reporting about the configurations associated with a given target */ +public class TargetConfiguredEvent implements BuildEventWithConfiguration { + private final Label label; + private final Collection<BuildConfiguration> configurations; + + TargetConfiguredEvent(Label label, Collection<BuildConfiguration> configurations) { + this.label = label; + this.configurations = configurations; + } + + @Override + public Collection<BuildConfiguration> getConfigurations() { + return configurations; + } + + @Override + public BuildEventId getEventId() { + return BuildEventId.targetConfigured(label); + } + + @Override + public Collection<BuildEventId> getChildrenEvents() { + ImmutableList.Builder childrenBuilder = ImmutableList.builder(); + for (BuildConfiguration config : configurations) { + childrenBuilder.add(BuildEventId.targetCompleted(label, config.getEventId())); + } + return childrenBuilder.build(); + } + + @Override + public BuildEventStreamProtos.BuildEvent asStreamProto(BuildEventConverters converters) { + return GenericBuildEvent.protoChaining(this) + .setConfigured(BuildEventStreamProtos.TargetConfigured.getDefaultInstance()) + .build(); + } +} diff --git a/src/main/java/com/google/devtools/build/lib/buildeventstream/BuildEventId.java b/src/main/java/com/google/devtools/build/lib/buildeventstream/BuildEventId.java index 381358bfd4..b6bf39d18a 100644 --- a/src/main/java/com/google/devtools/build/lib/buildeventstream/BuildEventId.java +++ b/src/main/java/com/google/devtools/build/lib/buildeventstream/BuildEventId.java @@ -137,11 +137,22 @@ public final class BuildEventId implements Serializable { return targetPatternExpanded(targetPattern, true); } + public static BuildEventId targetConfigured(Label label) { + BuildEventStreamProtos.BuildEventId.TargetConfiguredId configuredId = + BuildEventStreamProtos.BuildEventId.TargetConfiguredId.newBuilder() + .setLabel(label.toString()) + .build(); + return new BuildEventId( + BuildEventStreamProtos.BuildEventId.newBuilder().setTargetConfigured(configuredId).build()); + } - public static BuildEventId targetCompleted(Label target) { + public static BuildEventId targetCompleted(Label target, BuildEventId configuration) { + BuildEventStreamProtos.BuildEventId.ConfigurationId configId = + configuration.protoid.getConfiguration(); BuildEventStreamProtos.BuildEventId.TargetCompletedId targetId = BuildEventStreamProtos.BuildEventId.TargetCompletedId.newBuilder() .setLabel(target.toString()) + .setConfiguration(configId) .build(); return new BuildEventId( BuildEventStreamProtos.BuildEventId.newBuilder().setTargetCompleted(targetId).build()); diff --git a/src/main/java/com/google/devtools/build/lib/buildeventstream/proto/build_event_stream.proto b/src/main/java/com/google/devtools/build/lib/buildeventstream/proto/build_event_stream.proto index 9439273352..19e5825db1 100644 --- a/src/main/java/com/google/devtools/build/lib/buildeventstream/proto/build_event_stream.proto +++ b/src/main/java/com/google/devtools/build/lib/buildeventstream/proto/build_event_stream.proto @@ -100,6 +100,9 @@ message BuildEventId { message TargetCompletedId { string label = 1; + // The configuration for wich the target was built. + ConfigurationId configuration = 3; + // If not empty, the id refers to the completion of the target for a given // aspect. string aspect = 2; diff --git a/src/main/java/com/google/devtools/build/lib/pkgcache/TargetParsingCompleteEvent.java b/src/main/java/com/google/devtools/build/lib/pkgcache/TargetParsingCompleteEvent.java index 4a0967af85..704a316358 100644 --- a/src/main/java/com/google/devtools/build/lib/pkgcache/TargetParsingCompleteEvent.java +++ b/src/main/java/com/google/devtools/build/lib/pkgcache/TargetParsingCompleteEvent.java @@ -111,12 +111,12 @@ public class TargetParsingCompleteEvent implements BuildEvent { @Override public Collection<BuildEventId> getChildrenEvents() { - ImmutableList.Builder childrenBuilder = ImmutableList.builder(); + ImmutableList.Builder<BuildEventId> childrenBuilder = ImmutableList.builder(); for (Target target : expandedTargets) { - // Test suits won't produce a target-complete event, so do not anounce their - // completion as children. + // Test suits won't produce target configuration and target-complete events, so do not + // announce here completion as children. if (!TargetUtils.isTestSuiteRule(target)) { - childrenBuilder.add(BuildEventId.targetCompleted(target.getLabel())); + childrenBuilder.add(BuildEventId.targetConfigured(target.getLabel())); } } return childrenBuilder.build(); |