From 6b76d7332deb4be5d6fdf0a9307ce2177400fa90 Mon Sep 17 00:00:00 2001 From: Jakob Buchgraber Date: Thu, 27 Apr 2017 14:56:16 +0200 Subject: BEP: Report exit code in BuildCompleteEvent We decided to use the exit code as opposed to a status enum as bazel reports the build status as an exit code internally and the number of exit codes is dynamic. That is, a bazel module might add additional exit codes and thus we need to support reporting these. The overall_success field is now redundant and has thus been removed. A build was successfull iff ExitCode.code equals zero. Change-Id: I268db972b09d983f6cd07df34e3a384efb607358 PiperOrigin-RevId: 154413356 --- .../proto/build_event_stream.proto | 22 ++++++++++++++++++++-- .../buildtool/buildevent/BuildCompleteEvent.java | 8 +++++++- 2 files changed, 27 insertions(+), 3 deletions(-) (limited to 'src/main/java/com/google') 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 a59ef39cb3..c4ae568f91 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 @@ -361,8 +361,26 @@ message TestSummary { // Event indicating the end of a build. message BuildFinished { - // If the build succeeded or failed. - bool overall_success = 1; + // Exit code of a build. The possible values correspond to the predefined + // codes in bazel's lib.ExitCode class, as well as any custom exit code a + // module might define. The predefined exit codes are subject to change (but + // rarely do) and are not part of the public API. + // + // A build was successfull iff ExitCode.code equals 0. + message ExitCode { + // The name of the exit code. + string name = 1; + + // The exit code. + int32 code = 2; + } + + reserved 1; + + // The overall status of the build. A build was successfull iff + // ExitCode.code equals 0. + ExitCode exit_code = 3; + // Time in milliseconds since the epoch. // TODO(buchgr): Use google.protobuf.Timestamp once bazel's protoc supports // it. diff --git a/src/main/java/com/google/devtools/build/lib/buildtool/buildevent/BuildCompleteEvent.java b/src/main/java/com/google/devtools/build/lib/buildtool/buildevent/BuildCompleteEvent.java index f8e419e65f..936aeb12a5 100644 --- a/src/main/java/com/google/devtools/build/lib/buildtool/buildevent/BuildCompleteEvent.java +++ b/src/main/java/com/google/devtools/build/lib/buildtool/buildevent/BuildCompleteEvent.java @@ -60,9 +60,15 @@ public final class BuildCompleteEvent implements BuildEvent { @Override public BuildEventStreamProtos.BuildEvent asStreamProto(BuildEventConverters converters) { + BuildEventStreamProtos.BuildFinished.ExitCode exitCode = + BuildFinished.ExitCode.newBuilder() + .setName(result.getExitCondition().name()) + .setCode(result.getExitCondition().getNumericExitCode()) + .build(); + BuildFinished finished = BuildFinished.newBuilder() - .setOverallSuccess(result.getSuccess()) + .setExitCode(exitCode) .setFinishTimeMillis(result.getStopTime()) .build(); return GenericBuildEvent.protoChaining(this).setFinished(finished).build(); -- cgit v1.2.3