aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/runtime')
-rw-r--r--src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java14
-rw-r--r--src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandEventHandler.java9
-rw-r--r--src/main/java/com/google/devtools/build/lib/runtime/BuildEventStreamer.java7
-rw-r--r--src/main/java/com/google/devtools/build/lib/runtime/BuildEventStreamerModule.java79
4 files changed, 86 insertions, 23 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 87adbd7374..c16994f0d4 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
@@ -27,8 +27,6 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.collect.ListMultimap;
import com.google.common.io.Flushables;
-import com.google.devtools.build.lib.buildeventstream.BuildEventTransport;
-import com.google.devtools.build.lib.buildeventstream.transports.TextFormatFileTransport;
import com.google.devtools.build.lib.events.Event;
import com.google.devtools.build.lib.events.EventHandler;
import com.google.devtools.build.lib.events.Reporter;
@@ -455,18 +453,6 @@ public class BlazeCommandDispatcher {
Reporter reporter = env.getReporter();
reporter.addHandler(handler);
env.getEventBus().register(handler);
- if (eventHandlerOptions.buildEventTextFile.length() > 0) {
- try {
- BuildEventStreamer streamer =
- new BuildEventStreamer(
- ImmutableSet.<BuildEventTransport>of(
- new TextFormatFileTransport(eventHandlerOptions.buildEventTextFile)));
- reporter.addHandler(streamer);
- env.getEventBus().register(streamer);
- } catch (IOException e) {
- return ExitCode.LOCAL_ENVIRONMENTAL_ERROR.getNumericExitCode();
- }
- }
// We register an ANSI-allowing handler associated with {@code handler} so that ANSI control
// codes can be re-introduced later even if blaze is invoked with --color=no. This is useful
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 7ab613fc3f..601f37f5fd 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
@@ -168,15 +168,6 @@ public class BlazeCommandEventHandler implements EventHandler {
)
public int experimentalUiActionsShown;
-
- @Option(
- name = "experimental_build_event_text_file",
- defaultValue = "",
- category = "hidden",
- help = "If non-empty, write a textual representation of the build event protocol to that file"
- )
- public String buildEventTextFile;
-
public boolean useColor() {
return useColorEnum == UseColor.YES || (useColorEnum == UseColor.AUTO && isATty);
}
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/BuildEventStreamer.java b/src/main/java/com/google/devtools/build/lib/runtime/BuildEventStreamer.java
index 819e2f3c32..812d223449 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/BuildEventStreamer.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/BuildEventStreamer.java
@@ -14,6 +14,8 @@
package com.google.devtools.build.lib.runtime;
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
import com.google.common.eventbus.Subscribe;
import com.google.devtools.build.lib.actions.ActionExecutedEvent;
@@ -156,4 +158,9 @@ public class BuildEventStreamer implements EventHandler {
post(event);
}
+
+ @VisibleForTesting
+ ImmutableSet<BuildEventTransport> getTransports() {
+ return ImmutableSet.copyOf(transports);
+ }
}
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/BuildEventStreamerModule.java b/src/main/java/com/google/devtools/build/lib/runtime/BuildEventStreamerModule.java
new file mode 100644
index 0000000000..b405c79b38
--- /dev/null
+++ b/src/main/java/com/google/devtools/build/lib/runtime/BuildEventStreamerModule.java
@@ -0,0 +1,79 @@
+// Copyright 2016 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 static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
+import static com.google.devtools.build.lib.buildeventstream.transports.BuildEventTransportFactory.createFromOptions;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+import com.google.devtools.build.lib.buildeventstream.BuildEventTransport;
+import com.google.devtools.build.lib.buildeventstream.transports.BuildEventStreamOptions;
+import com.google.devtools.build.lib.util.AbruptExitException;
+import com.google.devtools.build.lib.util.ExitCode;
+import com.google.devtools.common.options.OptionsBase;
+import com.google.devtools.common.options.OptionsProvider;
+import java.io.IOException;
+
+
+/** Module responsible for configuring BuildEventStreamer and transports. */
+public class BuildEventStreamerModule extends BlazeModule {
+
+ private CommandEnvironment commandEnvironment;
+
+ @Override
+ public Iterable<Class<? extends OptionsBase>> getCommandOptions(Command command) {
+ return ImmutableList.<Class<? extends OptionsBase>>of(BuildEventStreamOptions.class);
+ }
+
+ @Override
+ public void beforeCommand(Command command, CommandEnvironment commandEnvironment)
+ throws AbruptExitException {
+ this.commandEnvironment = commandEnvironment;
+ }
+
+ @Override
+ public void handleOptions(OptionsProvider optionsProvider) {
+ checkState(commandEnvironment != null, "Methods called out of order");
+ Optional<BuildEventStreamer> streamer =
+ tryCreateStreamer(optionsProvider, commandEnvironment.getBlazeModuleEnvironment());
+ if (streamer.isPresent()) {
+ commandEnvironment.getReporter().addHandler(streamer.get());
+ commandEnvironment.getEventBus().register(streamer.get());
+ }
+ }
+
+ @VisibleForTesting
+ Optional<BuildEventStreamer> tryCreateStreamer(
+ OptionsProvider optionsProvider, ModuleEnvironment moduleEnvironment) {
+ try {
+ BuildEventStreamOptions besOptions =
+ checkNotNull(
+ optionsProvider.getOptions(BuildEventStreamOptions.class),
+ "Could not get BuildEventStreamOptions");
+ ImmutableSet<BuildEventTransport> buildEventTransports = createFromOptions(besOptions);
+ if (!buildEventTransports.isEmpty()) {
+ BuildEventStreamer streamer = new BuildEventStreamer(buildEventTransports);
+ return Optional.of(streamer);
+ }
+ } catch (IOException e) {
+ moduleEnvironment.exit(new AbruptExitException(ExitCode.LOCAL_ENVIRONMENTAL_ERROR, e));
+ }
+ return Optional.absent();
+ }
+}