aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build
diff options
context:
space:
mode:
authorGravatar Benjamin Peterson <bp@benjamin.pe>2017-07-28 11:37:30 +0200
committerGravatar Dmitry Lomov <dslomov@google.com>2017-07-31 16:32:02 +0200
commit7c074b5a5f03a05a108fdfed1910fe75a538a323 (patch)
treee7f60d41bf0b121b1a30cef1e3f0db45eaf099cc /src/main/java/com/google/devtools/build
parentc2c938ae2e75b5b881f06b18cce86dc87bae6fe6 (diff)
Only report progress after a build has started.
Rather than assuming that all events are part of a build until NoBuildEvent or BuildCompleteEvent are posted, only start reporting build progress after a BuildStartingEvent or a NoBuildEvent with showProgress() true happens. This fixes https://github.com/bazelbuild/bazel/issues/3449. Change-Id: I78372a2286a4595cf3301c998be2c9036ad0f4b7 PiperOrigin-RevId: 163447622
Diffstat (limited to 'src/main/java/com/google/devtools/build')
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/NoBuildEvent.java13
-rw-r--r--src/main/java/com/google/devtools/build/lib/runtime/ExperimentalEventHandler.java30
2 files changed, 23 insertions, 20 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 61f808997d..3e3192e1c5 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,17 +28,14 @@ public final class NoBuildEvent implements BuildEvent {
private final String command;
private final Long startTimeMillis;
private final boolean separateFinishedEvent;
- private final boolean keepShowingProgress;
+ private final boolean showProgress;
public NoBuildEvent(
- String command,
- Long startTimeMillis,
- boolean separateFinishedEvent,
- boolean keepShowingProgress) {
+ String command, Long startTimeMillis, boolean separateFinishedEvent, boolean showProgress) {
this.command = command;
this.startTimeMillis = startTimeMillis;
this.separateFinishedEvent = separateFinishedEvent;
- this.keepShowingProgress = keepShowingProgress;
+ this.showProgress = showProgress;
}
public NoBuildEvent(String command, Long startTimeMillis, boolean separateFinishedEvent) {
@@ -81,7 +78,7 @@ public final class NoBuildEvent implements BuildEvent {
return separateFinishedEvent;
}
- public boolean keepShowingProgress() {
- return keepShowingProgress;
+ public boolean showProgress() {
+ return showProgress;
}
}
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 0235a32ff8..93931536d1 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
@@ -91,7 +91,7 @@ public class ExperimentalEventHandler implements EventHandler {
private long mustRefreshAfterMillis;
private boolean dateShown;
private int numLinesProgressBar;
- private boolean buildComplete;
+ private boolean buildRunning;
// Number of open build even protocol transports.
private boolean progressBarNeedsRefresh;
private Thread updateThread;
@@ -258,7 +258,7 @@ public class ExperimentalEventHandler implements EventHandler {
}
private synchronized void maybeAddDate() {
- if (!showTimestamp || dateShown || buildComplete) {
+ if (!showTimestamp || dateShown || !buildRunning) {
return;
}
dateShown = true;
@@ -289,7 +289,7 @@ public class ExperimentalEventHandler implements EventHandler {
event.getKind() == EventKind.STDOUT
? outErr.getOutputStream()
: outErr.getErrorStream();
- if (buildComplete) {
+ if (!buildRunning) {
stream.write(event.getMessageBytes());
stream.flush();
} else {
@@ -341,7 +341,7 @@ public class ExperimentalEventHandler implements EventHandler {
case INFO:
case SUBCOMMAND:
boolean incompleteLine;
- if (showProgress && !buildComplete) {
+ if (showProgress && buildRunning) {
clearProgressBar();
}
incompleteLine = flushStdOutStdErrBuffers();
@@ -365,7 +365,7 @@ public class ExperimentalEventHandler implements EventHandler {
if (incompleteLine) {
crlf();
}
- if (showProgress && !buildComplete && cursorControl) {
+ if (showProgress && buildRunning && cursorControl) {
addProgressBar();
}
terminal.flush();
@@ -411,6 +411,9 @@ public class ExperimentalEventHandler implements EventHandler {
@Subscribe
public void buildStarted(BuildStartingEvent event) {
+ synchronized (this) {
+ buildRunning = true;
+ }
maybeAddDate();
stateTracker.buildStarted(event);
// As a new phase started, inform immediately.
@@ -461,7 +464,7 @@ public class ExperimentalEventHandler implements EventHandler {
// After a build has completed, only stop updating the UI if there is no more BEP
// upload happening.
if (stateTracker.pendingTransports() == 0) {
- buildComplete = true;
+ buildRunning = false;
done = true;
}
}
@@ -473,10 +476,10 @@ public class ExperimentalEventHandler implements EventHandler {
private void completeBuild() {
synchronized (this) {
- if (buildComplete) {
+ if (!buildRunning) {
return;
}
- buildComplete = true;
+ buildRunning = false;
}
stopUpdateThread();
flushStdOutStdErrBuffers();
@@ -484,7 +487,10 @@ public class ExperimentalEventHandler implements EventHandler {
@Subscribe
public void noBuild(NoBuildEvent event) {
- if (event.keepShowingProgress()) {
+ if (event.showProgress()) {
+ synchronized (this) {
+ buildRunning = true;
+ }
return;
}
completeBuild();
@@ -498,7 +504,7 @@ public class ExperimentalEventHandler implements EventHandler {
@Subscribe
public void afterCommand(AfterCommandEvent event) {
synchronized (this) {
- buildComplete = true;
+ buildRunning = true;
}
stopUpdateThread();
}
@@ -623,7 +629,7 @@ public class ExperimentalEventHandler implements EventHandler {
}
private void doRefresh(boolean fromUpdateThread) {
- if (buildComplete) {
+ if (!buildRunning) {
return;
}
long nowMillis = clock.currentTimeMillis();
@@ -717,7 +723,7 @@ public class ExperimentalEventHandler implements EventHandler {
// Refuse to start an update thread once the build is complete; such a situation might
// arise if the completion of the build is reported (shortly) before the completion of
// the last action is reported.
- if (!buildComplete && updateThread == null) {
+ if (buildRunning && updateThread == null) {
final ExperimentalEventHandler eventHandler = this;
updateThread =
new Thread(