From 280a671dba6cdcf3ca8c7a01b21e81d719471de0 Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Fri, 23 Jun 2017 21:12:47 +0200 Subject: BEP: Support longer streams on non building commands While the build event protocol is mainly targeted for commands that actually build, a minimal stream is generated for all commands. For commands like "query", it is desirable that the stream contains the full output of the command. To achieve this, introduce an optional second event indicating the end of the stream; note that the NoBuildEvent has to come before the payload answer as the experimental UI uses this event to determine the transition to the payload answer that is passed through unchanged. RELNOTES: None. PiperOrigin-RevId: 159977543 --- .../google/devtools/build/lib/runtime/commands/QueryCommand.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/main/java/com/google/devtools/build/lib/runtime/commands/QueryCommand.java') diff --git a/src/main/java/com/google/devtools/build/lib/runtime/commands/QueryCommand.java b/src/main/java/com/google/devtools/build/lib/runtime/commands/QueryCommand.java index c9d31ba945..879806de79 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/commands/QueryCommand.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/commands/QueryCommand.java @@ -19,6 +19,7 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Joiner; import com.google.common.collect.ImmutableList; import com.google.devtools.build.lib.analysis.NoBuildEvent; +import com.google.devtools.build.lib.analysis.NoBuildRequestFinishedEvent; import com.google.devtools.build.lib.events.Event; import com.google.devtools.build.lib.packages.Target; import com.google.devtools.build.lib.pkgcache.PackageCacheOptions; @@ -207,7 +208,7 @@ public final class QueryCommand implements BlazeCommand { } } - env.getEventBus().post(new NoBuildEvent(env.getCommandName(), env.getCommandStartTime())); + env.getEventBus().post(new NoBuildEvent(env.getCommandName(), env.getCommandStartTime(), true)); if (!streamResults) { disableAnsiCharactersFiltering(env); try { @@ -241,7 +242,10 @@ public final class QueryCommand implements BlazeCommand { env.getReporter().handle(Event.info("Empty results")); } - return result.getSuccess() ? ExitCode.SUCCESS : ExitCode.PARTIAL_ANALYSIS_FAILURE; + ExitCode exitCode = result.getSuccess() ? ExitCode.SUCCESS : ExitCode.PARTIAL_ANALYSIS_FAILURE; + env.getEventBus() + .post(new NoBuildRequestFinishedEvent(exitCode, runtime.getClock().currentTimeMillis())); + return exitCode; } /** -- cgit v1.2.3