aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/runtime
diff options
context:
space:
mode:
authorGravatar Akira Baruah <akira.baruah@gmail.com>2017-12-15 11:30:04 -0800
committerGravatar Copybara-Service <copybara-piper@google.com>2017-12-15 11:32:02 -0800
commitc4071e8b634440cf873b719dd948b8777b03f50e (patch)
tree1a6585f7411d820fda0e14c4b02825c85e566fcb /src/main/java/com/google/devtools/build/lib/runtime
parentc8201d4f94a9df581fe5e94b90b3d57ac3792c4a (diff)
Don't suggest using bazel clean --async when it's unsupported
Fixes #4176 (https://github.com/bazelbuild/bazel/issues/4176). Closes #4236. PiperOrigin-RevId: 179218605
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/runtime')
-rw-r--r--src/main/java/com/google/devtools/build/lib/runtime/commands/CleanCommand.java17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/commands/CleanCommand.java b/src/main/java/com/google/devtools/build/lib/runtime/commands/CleanCommand.java
index dfe0dd3bb1..721a0644fc 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/commands/CleanCommand.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/commands/CleanCommand.java
@@ -13,6 +13,7 @@
// limitations under the License.
package com.google.devtools.build.lib.runtime.commands;
+import com.google.common.annotations.VisibleForTesting;
import com.google.devtools.build.lib.actions.ExecException;
import com.google.devtools.build.lib.analysis.NoBuildEvent;
import com.google.devtools.build.lib.buildtool.BuildRequestOptions;
@@ -112,6 +113,17 @@ public final class CleanCommand implements BlazeCommand {
}
}
+ private final OS os;
+
+ public CleanCommand() {
+ this(OS.getCurrent());
+ }
+
+ @VisibleForTesting
+ public CleanCommand(OS os) {
+ this.os = os;
+ }
+
private static final Logger logger = Logger.getLogger(CleanCommand.class.getName());
@Override
@@ -126,7 +138,8 @@ public final class CleanCommand implements BlazeCommand {
// MacOS and FreeBSD support setsid(2) but don't have /usr/bin/setsid, so if we wanted to
// support --expunge_async on these platforms, we'd have to write a wrapper that calls setsid(2)
// and exec(2).
- if (async && OS.getCurrent() != OS.LINUX) {
+ boolean asyncSupport = os == OS.LINUX;
+ if (async && !asyncSupport) {
String fallbackName = cleanOptions.expunge ? "--expunge" : "synchronous clean";
env.getReporter()
.handle(
@@ -138,7 +151,7 @@ public final class CleanCommand implements BlazeCommand {
}
String cleanBanner =
- async
+ (async || !asyncSupport)
? "Starting clean."
: "Starting clean (this may take a while). "
+ "Consider using --async if the clean takes more than several minutes.";