Search in sources :

Example 6 with BuildEventTransport

use of com.google.devtools.build.lib.buildeventstream.BuildEventTransport in project bazel by bazelbuild.

the class BuildEventStreamerModule method tryCreateStreamer.

@VisibleForTesting
Optional<BuildEventStreamer> tryCreateStreamer(OptionsProvider optionsProvider, ModuleEnvironment moduleEnvironment) {
    try {
        PathConverter pathConverter;
        if (commandEnvironment == null) {
            pathConverter = new PathConverter() {

                @Override
                public String apply(Path path) {
                    return path.getPathString();
                }
            };
        } else {
            pathConverter = commandEnvironment.getRuntime().getPathToUriConverter();
        }
        BuildEventStreamOptions besOptions = checkNotNull(optionsProvider.getOptions(BuildEventStreamOptions.class), "Could not get BuildEventStreamOptions");
        ImmutableSet<BuildEventTransport> buildEventTransports = createFromOptions(besOptions, pathConverter);
        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();
}
Also used : Path(com.google.devtools.build.lib.vfs.Path) BuildEventStreamOptions(com.google.devtools.build.lib.buildeventstream.transports.BuildEventStreamOptions) BuildEventTransport(com.google.devtools.build.lib.buildeventstream.BuildEventTransport) PathConverter(com.google.devtools.build.lib.buildeventstream.PathConverter) IOException(java.io.IOException) AbruptExitException(com.google.devtools.build.lib.util.AbruptExitException) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

BuildEventTransport (com.google.devtools.build.lib.buildeventstream.BuildEventTransport)6 File (java.io.File)3 Test (org.junit.Test)3 IOException (java.io.IOException)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 NoBuildEvent (com.google.devtools.build.lib.analysis.NoBuildEvent)1 BuildEvent (com.google.devtools.build.lib.buildeventstream.BuildEvent)1 BuildEventId (com.google.devtools.build.lib.buildeventstream.BuildEventId)1 PathConverter (com.google.devtools.build.lib.buildeventstream.PathConverter)1 BuildEventStreamOptions (com.google.devtools.build.lib.buildeventstream.transports.BuildEventStreamOptions)1 AbruptExitException (com.google.devtools.build.lib.util.AbruptExitException)1 Path (com.google.devtools.build.lib.vfs.Path)1