Search in sources :

Example 1 with BuildEventStreamOptions

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

Example 2 with BuildEventStreamOptions

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

the class BuildEventStreamerModuleTest method testReturnsBuildEventStreamerOptions.

@Test
public void testReturnsBuildEventStreamerOptions() throws Exception {
    BuildEventStreamerModule module = new BuildEventStreamerModule();
    Iterable<Class<? extends OptionsBase>> commandOptions = module.getCommandOptions(command);
    assertThat(commandOptions).isNotEmpty();
    OptionsParser optionsParser = OptionsParser.newOptionsParser(commandOptions);
    optionsParser.parse("--experimental_build_event_text_file", "/tmp/foo.txt", "--experimental_build_event_binary_file", "/tmp/foo.bin");
    BuildEventStreamOptions options = optionsParser.getOptions(BuildEventStreamOptions.class);
    assertThat(options.getBuildEventTextFile()).isEqualTo("/tmp/foo.txt");
    assertThat(options.getBuildEventBinaryFile()).isEqualTo("/tmp/foo.bin");
}
Also used : OptionsBase(com.google.devtools.common.options.OptionsBase) BuildEventStreamOptions(com.google.devtools.build.lib.buildeventstream.transports.BuildEventStreamOptions) OptionsParser(com.google.devtools.common.options.OptionsParser) Test(org.junit.Test)

Aggregations

BuildEventStreamOptions (com.google.devtools.build.lib.buildeventstream.transports.BuildEventStreamOptions)2 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 AbruptExitException (com.google.devtools.build.lib.util.AbruptExitException)1 Path (com.google.devtools.build.lib.vfs.Path)1 OptionsBase (com.google.devtools.common.options.OptionsBase)1 OptionsParser (com.google.devtools.common.options.OptionsParser)1 IOException (java.io.IOException)1 Test (org.junit.Test)1