diff options
author | Ulf Adams <ulfjack@google.com> | 2016-02-24 13:23:54 +0000 |
---|---|---|
committer | Philipp Wollermann <philwo@google.com> | 2016-02-24 18:00:59 +0000 |
commit | d6347a971e75eda3fb5029cd8beba67464c7af61 (patch) | |
tree | 20071db5ed2e9f202cc31689a2ba61bb07a51cd0 | |
parent | ac0a16cd4b9b27ff7ec0bdf31a8793d34fb16030 (diff) |
Add an option to enable an experimental UI
By enabling this option (default is off), a new, still experimental
UI will be used. As it is developped from scratch, this commit simply
implements a UI that does not produce any output at all.
--
Change-Id: I895c0e0744c008212efc7bdfca1457f7907c9b64
Reviewed-on: https://bazel-review.googlesource.com/#/c/3009/
MOS_MIGRATED_REVID=115441032
3 files changed, 65 insertions, 2 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java b/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java index 8daee39a0a..262c796db9 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java @@ -624,7 +624,10 @@ public class BlazeCommandDispatcher { private EventHandler createEventHandler(OutErr outErr, BlazeCommandEventHandler.Options eventOptions) { EventHandler eventHandler; - if ((eventOptions.useColor() || eventOptions.useCursorControl())) { + if (eventOptions.experimentalUi) { + // The experimental event handler is not to be rate limited. + return new ExperimentalEventHandler(outErr, eventOptions); + } else if ((eventOptions.useColor() || eventOptions.useCursorControl())) { eventHandler = new FancyTerminalEventHandler(outErr, eventOptions); } else { eventHandler = new BlazeCommandEventHandler(outErr, eventOptions); @@ -640,7 +643,10 @@ public class BlazeCommandDispatcher { if (eventHandler instanceof FancyTerminalEventHandler) { // Make sure that the terminal state of the old event handler is clear // before creating a new one. - ((FancyTerminalEventHandler)eventHandler).resetTerminal(); + ((FancyTerminalEventHandler) eventHandler).resetTerminal(); + } + if (eventHandler instanceof ExperimentalEventHandler) { + ((ExperimentalEventHandler) eventHandler).resetTerminal(); } } diff --git a/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandEventHandler.java b/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandEventHandler.java index 9aadac8bb8..11f3e8e627 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandEventHandler.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandEventHandler.java @@ -141,6 +141,14 @@ public class BlazeCommandEventHandler implements EventHandler { help = "Forces --experimental_external_repositories.") public boolean forceExternalRepositories; + @Option( + name = "experimental_ui", + defaultValue = "false", + category = "hidden", + help = "Enable the experimental new Bazel UI." + ) + public boolean experimentalUi; + public boolean useColor() { return useColorEnum == UseColor.YES || (useColorEnum == UseColor.AUTO && isATty); } 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 new file mode 100644 index 0000000000..b81fddb4ae --- /dev/null +++ b/src/main/java/com/google/devtools/build/lib/runtime/ExperimentalEventHandler.java @@ -0,0 +1,49 @@ +// Copyright 2015 The Bazel Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package com.google.devtools.build.lib.runtime; + +import com.google.devtools.build.lib.events.Event; +import com.google.devtools.build.lib.util.io.AnsiTerminal; +import com.google.devtools.build.lib.util.io.OutErr; + +import java.io.IOException; +import java.util.logging.Logger; + +/** + * An experimental new output stream. + */ +public class ExperimentalEventHandler extends BlazeCommandEventHandler { + private static Logger LOG = Logger.getLogger(ExperimentalEventHandler.class.getName()); + + private final AnsiTerminal terminal; + + public final int terminalWidth; + + public ExperimentalEventHandler(OutErr outErr, BlazeCommandEventHandler.Options options) { + super(outErr, options); + this.terminal = new AnsiTerminal(outErr.getErrorStream()); + this.terminalWidth = (options.terminalColumns > 0 ? options.terminalColumns : 80); + } + + @Override + public void handle(Event event) {} + + public void resetTerminal() { + try { + terminal.resetTerminal(); + } catch (IOException e) { + LOG.warning("IO Error writing to user terminal: " + e); + } + } +} |