diff options
5 files changed, 49 insertions, 5 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/NoBuildEvent.java b/src/main/java/com/google/devtools/build/lib/analysis/NoBuildEvent.java index cd0b83f170..61f808997d 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/NoBuildEvent.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/NoBuildEvent.java @@ -28,11 +28,21 @@ public final class NoBuildEvent implements BuildEvent { private final String command; private final Long startTimeMillis; private final boolean separateFinishedEvent; + private final boolean keepShowingProgress; - public NoBuildEvent(String command, Long startTimeMillis, boolean separateFinishedEvent) { + public NoBuildEvent( + String command, + Long startTimeMillis, + boolean separateFinishedEvent, + boolean keepShowingProgress) { this.command = command; this.startTimeMillis = startTimeMillis; this.separateFinishedEvent = separateFinishedEvent; + this.keepShowingProgress = keepShowingProgress; + } + + public NoBuildEvent(String command, Long startTimeMillis, boolean separateFinishedEvent) { + this(command, startTimeMillis, separateFinishedEvent, false); } public NoBuildEvent() { @@ -70,4 +80,8 @@ public final class NoBuildEvent implements BuildEvent { public boolean separateFinishedEvent() { return separateFinishedEvent; } + + public boolean keepShowingProgress() { + return keepShowingProgress; + } } diff --git a/src/main/java/com/google/devtools/build/lib/bazel/commands/FetchCommand.java b/src/main/java/com/google/devtools/build/lib/bazel/commands/FetchCommand.java index b47fa353b3..833642b80a 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/commands/FetchCommand.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/commands/FetchCommand.java @@ -111,7 +111,9 @@ public final class FetchCommand implements BlazeCommand { return ExitCode.COMMAND_LINE_ERROR; } - env.getReporter().post(new NoBuildEvent(env.getCommandName(), env.getCommandStartTime(), true)); + env.getReporter() + .post(new NoBuildEvent(env.getCommandName(), env.getCommandStartTime(), true, true)); + // 2. Evaluate expression: try { queryEnv.evaluateQuery(expr, new ThreadSafeOutputFormatterCallback<Target>() { diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/DownloadProgressEvent.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/DownloadProgressEvent.java index 86d2ef6b4d..5d74ddc676 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/DownloadProgressEvent.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/DownloadProgressEvent.java @@ -16,6 +16,8 @@ package com.google.devtools.build.lib.bazel.repository.downloader; import com.google.devtools.build.lib.events.ExtendedEventHandler; import java.net.URL; +import java.text.NumberFormat; +import java.util.Locale; /** * Postable event reporting on progress made downloading an URL. It can be used to report the URL @@ -70,6 +72,12 @@ public class DownloadProgressEvent implements ExtendedEventHandler.FetchProgress @Override public String getProgress() { - return bytesRead > 0 ? "" + bytesRead + "b" : ""; + if (bytesRead > 0) { + NumberFormat formatter = NumberFormat.getIntegerInstance(Locale.ENGLISH); + formatter.setGroupingUsed(true); + return formatter.format(bytesRead) + "b"; + } else { + return ""; + } } } diff --git a/src/main/java/com/google/devtools/build/lib/runtime/ExperimentalEventHandler.java b/src/main/java/com/google/devtools/build/lib/runtime/ExperimentalEventHandler.java index 391a6c1dff..0235a32ff8 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/ExperimentalEventHandler.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/ExperimentalEventHandler.java @@ -22,6 +22,7 @@ import com.google.devtools.build.lib.actions.ActionStartedEvent; import com.google.devtools.build.lib.actions.ActionStatusMessage; import com.google.devtools.build.lib.analysis.AnalysisPhaseCompleteEvent; import com.google.devtools.build.lib.analysis.NoBuildEvent; +import com.google.devtools.build.lib.analysis.NoBuildRequestFinishedEvent; import com.google.devtools.build.lib.buildeventstream.AnnounceBuildEventTransportsEvent; import com.google.devtools.build.lib.buildeventstream.BuildEventTransport; import com.google.devtools.build.lib.buildeventstream.BuildEventTransportClosedEvent; @@ -470,9 +471,11 @@ public class ExperimentalEventHandler implements EventHandler { } } - @Subscribe - public void noBuild(NoBuildEvent event) { + private void completeBuild() { synchronized (this) { + if (buildComplete) { + return; + } buildComplete = true; } stopUpdateThread(); @@ -480,6 +483,19 @@ public class ExperimentalEventHandler implements EventHandler { } @Subscribe + public void noBuild(NoBuildEvent event) { + if (event.keepShowingProgress()) { + return; + } + completeBuild(); + } + + @Subscribe + public void noBuildFinished(NoBuildRequestFinishedEvent event) { + completeBuild(); + } + + @Subscribe public void afterCommand(AfterCommandEvent event) { synchronized (this) { buildComplete = true; diff --git a/src/main/java/com/google/devtools/build/lib/runtime/ExperimentalStateTracker.java b/src/main/java/com/google/devtools/build/lib/runtime/ExperimentalStateTracker.java index ea6329d94e..921a6dccb9 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/ExperimentalStateTracker.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/ExperimentalStateTracker.java @@ -776,6 +776,10 @@ class ExperimentalStateTracker { sampleOldestActions(terminalWriter); } } + if (!shortVersion) { + reportOnDownloads(terminalWriter); + maybeReportBepTransports(terminalWriter); + } } void writeProgressBar(AnsiTerminalWriter terminalWriter, boolean shortVersion) |