Search in sources :

Example 1 with PathConverter

use of com.google.devtools.build.lib.buildeventstream.PathConverter 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

VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 BuildEventTransport (com.google.devtools.build.lib.buildeventstream.BuildEventTransport)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 IOException (java.io.IOException)1