aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/buildeventstream
diff options
context:
space:
mode:
authorGravatar aehlig <aehlig@google.com>2017-10-26 18:36:14 +0200
committerGravatar Dmitry Lomov <dslomov@google.com>2017-10-27 16:29:30 +0200
commit61c0da151490544d02628199e9d90687c7dbef86 (patch)
treefc38c0b77cd2dea4578ef9556d3019bf3f7d383f /src/main/java/com/google/devtools/build/lib/buildeventstream
parent865e9ca2281a238a45a2afbcb0a4a3a214b5572d (diff)
BEP: Add an additional event with tool statistics
After the completion of the build, also report useful logs/statistics. Do so in a separate event, so that the protocol allows reporting build completion early and purely staticial information later, maybe event after some computations. Change-Id: Ibd221546de76fcffcda7819c300187eac45ebd68 PiperOrigin-RevId: 173548733
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/buildeventstream')
-rw-r--r--src/main/java/com/google/devtools/build/lib/buildeventstream/BuildEventId.java8
-rw-r--r--src/main/java/com/google/devtools/build/lib/buildeventstream/BuildToolLogs.java69
-rw-r--r--src/main/java/com/google/devtools/build/lib/buildeventstream/proto/build_event_stream.proto12
3 files changed, 89 insertions, 0 deletions
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 2479b59b3d..7e582a5794 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
@@ -273,4 +273,12 @@ public final class BuildEventId implements Serializable {
return new BuildEventId(
BuildEventStreamProtos.BuildEventId.newBuilder().setBuildFinished(finishedId).build());
}
+
+ public static BuildEventId buildToolLogs() {
+ return new BuildEventId(
+ BuildEventStreamProtos.BuildEventId.newBuilder()
+ .setBuildToolLogs(
+ BuildEventStreamProtos.BuildEventId.BuildToolLogsId.getDefaultInstance())
+ .build());
+ }
}
diff --git a/src/main/java/com/google/devtools/build/lib/buildeventstream/BuildToolLogs.java b/src/main/java/com/google/devtools/build/lib/buildeventstream/BuildToolLogs.java
new file mode 100644
index 0000000000..23e1b07e53
--- /dev/null
+++ b/src/main/java/com/google/devtools/build/lib/buildeventstream/BuildToolLogs.java
@@ -0,0 +1,69 @@
+// 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 com.google.devtools.build.lib.util.Pair;
+import com.google.devtools.build.lib.vfs.Path;
+import com.google.protobuf.ByteString;
+import java.nio.charset.StandardCharsets;
+import java.util.Collection;
+
+/** Event reporting on statistics about the build. */
+public class BuildToolLogs implements BuildEventWithOrderConstraint {
+ private final Collection<Pair<String, String>> directValues;
+ private final Collection<Pair<String, Path>> logFiles;
+
+ public BuildToolLogs(
+ Collection<Pair<String, String>> directValues, Collection<Pair<String, Path>> logFiles) {
+ this.directValues = directValues;
+ this.logFiles = logFiles;
+ }
+
+ @Override
+ public BuildEventId getEventId() {
+ return BuildEventId.buildToolLogs();
+ }
+
+ @Override
+ public Collection<BuildEventId> getChildrenEvents() {
+ return ImmutableList.<BuildEventId>of();
+ }
+
+ @Override
+ public BuildEventStreamProtos.BuildEvent asStreamProto(BuildEventConverters converters) {
+ BuildEventStreamProtos.BuildToolLogs.Builder toolLogs =
+ BuildEventStreamProtos.BuildToolLogs.newBuilder();
+ for (Pair<String, String> direct : directValues) {
+ toolLogs.addLog(
+ BuildEventStreamProtos.File.newBuilder()
+ .setName(direct.getFirst())
+ .setContents(ByteString.copyFrom(direct.getSecond().getBytes(StandardCharsets.UTF_8)))
+ .build());
+ }
+ for (Pair<String, Path> logFile : logFiles) {
+ toolLogs.addLog(
+ BuildEventStreamProtos.File.newBuilder()
+ .setName(logFile.getFirst())
+ .setUri(converters.pathConverter().apply(logFile.getSecond()))
+ .build());
+ }
+ return GenericBuildEvent.protoChaining(this).setBuildToolLogs(toolLogs.build()).build();
+ }
+
+ @Override
+ public Collection<BuildEventId> postedAfter() {
+ return ImmutableList.of(BuildEventId.buildFinished());
+ }
+}
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 22a5761d49..6b15e27180 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
@@ -174,6 +174,11 @@ message BuildEventId {
message BuildFinishedId {
}
+ // Identifier of an event providing additional logs/statistics after
+ // completion of the build.
+ message BuildToolLogsId {
+ }
+
oneof id {
UnknownBuildEventId unknown = 1;
ProgressId progress = 2;
@@ -194,6 +199,7 @@ message BuildEventId {
TestResultId test_result = 8;
TestSummaryId test_summary = 7;
BuildFinishedId build_finished = 9;
+ BuildToolLogsId build_tool_logs = 20;
}
}
@@ -544,6 +550,11 @@ message BuildFinished {
int64 finish_time_millis = 2;
}
+// Event providing additional statistics/logs after completion of the build.
+message BuildToolLogs {
+ repeated File log = 1;
+}
+
// Message describing a build event. Events will have an identifier that
// is unique within a given build invocation; they also announce follow-up
// events as children. More details, which are specific to the kind of event
@@ -572,5 +583,6 @@ message BuildEvent {
TestResult test_result = 10;
TestSummary test_summary = 9;
BuildFinished finished = 14;
+ BuildToolLogs build_tool_logs = 23;
};
}