diff options
Diffstat (limited to 'src/main/java/com/google')
5 files changed, 63 insertions, 5 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 01a3ddf18d..fc1402573a 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 @@ -116,8 +116,10 @@ public final class TargetCompleteEvent @Override public BuildEventId getEventId() { - return BuildEventId.targetCompleted( - getTarget().getLabel(), getTarget().getConfiguration().getEventId()); + BuildConfiguration config = getTarget().getConfiguration(); + BuildEventId configId = + config == null ? BuildEventId.nullConfigurationId() : config.getEventId(); + return BuildEventId.targetCompleted(getTarget().getLabel(), configId); } @Override 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 index 8606afe708..2473991981 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/TargetConfiguredEvent.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/TargetConfiguredEvent.java @@ -47,7 +47,12 @@ public class TargetConfiguredEvent implements BuildEventWithConfiguration { public Collection<BuildEventId> getChildrenEvents() { ImmutableList.Builder childrenBuilder = ImmutableList.builder(); for (BuildConfiguration config : configurations) { - childrenBuilder.add(BuildEventId.targetCompleted(label, config.getEventId())); + if (config != null) { + childrenBuilder.add(BuildEventId.targetCompleted(label, config.getEventId())); + } else { + childrenBuilder.add( + BuildEventId.targetCompleted(label, BuildEventId.nullConfigurationId())); + } } return childrenBuilder.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 c34cdf9fb5..3f4fa37ea5 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 @@ -114,6 +114,10 @@ public final class BuildEventId implements Serializable { BuildEventStreamProtos.BuildEventId.newBuilder().setConfiguration(configurationId).build()); } + public static BuildEventId nullConfigurationId() { + return configurationId("none"); + } + private static BuildEventId targetPatternExpanded(List<String> targetPattern, boolean skipped) { BuildEventStreamProtos.BuildEventId.PatternExpandedId patternId = BuildEventStreamProtos.BuildEventId.PatternExpandedId.newBuilder() diff --git a/src/main/java/com/google/devtools/build/lib/buildeventstream/NullConfiguration.java b/src/main/java/com/google/devtools/build/lib/buildeventstream/NullConfiguration.java new file mode 100644 index 0000000000..a95e5a3d72 --- /dev/null +++ b/src/main/java/com/google/devtools/build/lib/buildeventstream/NullConfiguration.java @@ -0,0 +1,42 @@ +// 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.buildeventstream; + +import com.google.common.collect.ImmutableList; +import java.util.Collection; + +/** + * {@link BuildEvent} presenting the configuration in the build event protocol + * that internally is just a null pointer. + */ +public class NullConfiguration implements BuildEvent { + + @Override + public BuildEventId getEventId() { + return BuildEventId.nullConfigurationId(); + } + + @Override + public Collection<BuildEventId> getChildrenEvents() { + return ImmutableList.of(); + } + + @Override + public BuildEventStreamProtos.BuildEvent asStreamProto(BuildEventConverters converters) { + return GenericBuildEvent.protoChaining(this) + .setConfiguration(BuildEventStreamProtos.Configuration.getDefaultInstance()) + .build(); + } +} diff --git a/src/main/java/com/google/devtools/build/lib/runtime/BuildEventStreamer.java b/src/main/java/com/google/devtools/build/lib/runtime/BuildEventStreamer.java index e10444b325..dc14a2b09e 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/BuildEventStreamer.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/BuildEventStreamer.java @@ -44,6 +44,7 @@ import com.google.devtools.build.lib.buildeventstream.BuildEventStreamProtos.Bui import com.google.devtools.build.lib.buildeventstream.BuildEventTransport; import com.google.devtools.build.lib.buildeventstream.BuildEventTransportClosedEvent; import com.google.devtools.build.lib.buildeventstream.BuildEventWithOrderConstraint; +import com.google.devtools.build.lib.buildeventstream.NullConfiguration; import com.google.devtools.build.lib.buildeventstream.ProgressEvent; import com.google.devtools.build.lib.buildtool.BuildRequest; import com.google.devtools.build.lib.buildtool.buildevent.BuildCompleteEvent; @@ -332,14 +333,18 @@ public class BuildEventStreamer implements EventHandler { } private void maybeReportConfiguration(BuildConfiguration configuration) { - BuildEventId id = configuration.getEventId(); + BuildEvent event = configuration; + if (configuration == null) { + event = new NullConfiguration(); + } + BuildEventId id = event.getEventId(); synchronized (this) { if (configurationsPosted.contains(id)) { return; } configurationsPosted.add(id); } - post(configuration); + post(event); } @Override |