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
@@ -24,6 +24,7 @@ import com.google.common.collect.ImmutableList;
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 @@ public class BlazeCommandDispatcher {
// 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 @@ public class BlazeCommandDispatcher {
// 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 @@ public class BlazeCommandDispatcher {
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 @@ public class BlazeCommandDispatcher {
for (Postable post : storedEventHandler.getPosts()) {
env.getEventBus().post(post);
}
+ env.getEventBus().post(noBuildEvent);
return BlazeCommandResult.exitCode(earlyExitCode);
}
