aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/analysis/NoBuildEvent.java
diff options
context:
space:
mode:
authorGravatar Klaus Aehlig <aehlig@google.com>2017-06-16 17:30:27 +0200
committerGravatar Philipp Wollermann <philwo@google.com>2017-06-19 18:23:22 +0200
commitd8c286d32513d5696b2ec8c4e7d6ffd4bb332227 (patch)
tree7414f9c39b311dd329a4c0d3065e296fc0200975 /src/main/java/com/google/devtools/build/lib/analysis/NoBuildEvent.java
parentf7bc9e550ef775c029a5eaee615ef74a06b312a5 (diff)
Make NoBuildEvent an instance of BuildEvent
Not all bazel invocations produce a BuildStartingEvent; in fact, not all commands include building. Those invocations produce a NoBuildEvent instead. However, some of those invocations, like "query", might still have important machine-readable information to report, like errors in BUILD files. So, make the NoBuildEvent a build event, capable of starting a stream of build events. Change-Id: I7cab65f029cdc0176ea5c4970308de296fb73177 PiperOrigin-RevId: 159230205
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/analysis/NoBuildEvent.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/NoBuildEvent.java51
1 files changed, 47 insertions, 4 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/NoBuildEvent.java b/src/main/java/com/google/devtools/build/lib/analysis/NoBuildEvent.java
index 152f39f0c0..7974bddaac 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/NoBuildEvent.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/NoBuildEvent.java
@@ -14,7 +14,50 @@
package com.google.devtools.build.lib.analysis;
-/**
- * This event raised to indicate that no build will be happening for the given command.
- */
-public final class NoBuildEvent {}
+import com.google.common.collect.ImmutableList;
+import com.google.devtools.build.lib.buildeventstream.BuildEvent;
+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.buildeventstream.ProgressEvent;
+import java.util.Collection;
+
+/** This event raised to indicate that no build will be happening for the given command. */
+public final class NoBuildEvent implements BuildEvent {
+ private final String command;
+ private final Long startTimeMillis;
+
+ public NoBuildEvent(String command, Long startTimeMillis) {
+ this.command = command;
+ this.startTimeMillis = startTimeMillis;
+ }
+
+ public NoBuildEvent() {
+ this(null, null);
+ }
+
+ @Override
+ public Collection<BuildEventId> getChildrenEvents() {
+ return ImmutableList.of(ProgressEvent.INITIAL_PROGRESS_UPDATE);
+ }
+
+ @Override
+ public BuildEventId getEventId() {
+ return BuildEventId.buildStartedId();
+ }
+
+ @Override
+ public BuildEventStreamProtos.BuildEvent asStreamProto(BuildEventConverters converters) {
+ BuildEventStreamProtos.BuildStarted.Builder started =
+ BuildEventStreamProtos.BuildStarted.newBuilder()
+ .setBuildToolVersion(BlazeVersionInfo.instance().getVersion());
+ if (command != null) {
+ started.setCommand(command);
+ }
+ if (startTimeMillis != null) {
+ started.setStartTimeMillis(startTimeMillis);
+ }
+ return GenericBuildEvent.protoChaining(this).setStarted(started.build()).build();
+ }
+}