Trigger a "NoBuildEvent" in cases where we fail early in the BlazeCommandDispatcher. This informs BEP logic that the build has failed, but otherwise doing an orderly completion. RELNOTES: None PiperOrigin-RevId: 238563955
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java b/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java index 52b8c17..eb0823b 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java
@@ -24,6 +24,7 @@ import com.google.common.collect.ImmutableSet; import com.google.common.io.Flushables; import com.google.common.util.concurrent.UncheckedExecutionException; +import com.google.devtools.build.lib.analysis.NoBuildEvent; import com.google.devtools.build.lib.bugreport.BugReport; import com.google.devtools.build.lib.buildtool.buildevent.ProfilerStartedEvent; import com.google.devtools.build.lib.clock.BlazeClock; @@ -330,7 +331,14 @@ // Early exit. We need to guarantee that the ErrOut and Reporter setup below never error out, // so any invariants they need must be checked before this point. if (!earlyExitCode.equals(ExitCode.SUCCESS)) { - return replayEarlyExitEvents(outErr, optionHandler, storedEventHandler, env, earlyExitCode); + return replayEarlyExitEvents( + outErr, + optionHandler, + storedEventHandler, + env, + earlyExitCode, + new NoBuildEvent( + commandName, firstContactTime, false, true, env.getCommandId().toString())); } Reporter reporter = env.getReporter(); @@ -488,7 +496,14 @@ // Parse starlark options. earlyExitCode = optionHandler.parseStarlarkOptions(env, storedEventHandler); if (!earlyExitCode.equals(ExitCode.SUCCESS)) { - return replayEarlyExitEvents(outErr, optionHandler, storedEventHandler, env, earlyExitCode); + return replayEarlyExitEvents( + outErr, + optionHandler, + storedEventHandler, + env, + earlyExitCode, + new NoBuildEvent( + commandName, firstContactTime, false, true, env.getCommandId().toString())); } options = optionHandler.getOptionsResult(); @@ -529,7 +544,8 @@ BlazeOptionHandler optionHandler, StoredEventHandler storedEventHandler, CommandEnvironment env, - ExitCode earlyExitCode) { + ExitCode earlyExitCode, + NoBuildEvent noBuildEvent) { PrintingEventHandler printingEventHandler = new PrintingEventHandler(outErr, EventKind.ALL_EVENTS); for (String note : optionHandler.getRcfileNotes()) { @@ -541,6 +557,7 @@ for (Postable post : storedEventHandler.getPosts()) { env.getEventBus().post(post); } + env.getEventBus().post(noBuildEvent); return BlazeCommandResult.exitCode(earlyExitCode); }