From eeb89700bd859635b79c8beee449960563eea16c Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Thu, 13 Apr 2017 10:10:43 +0000 Subject: BEP: for local transports optionally drop path conversion For transports that are purely local (like the ones writing to a local file), it sometimes can be useful to skip path conversion and use the local paths directly. Support this for the text and binary format file transports. Change-Id: I2ac2e187ebb11ff82c4e1ddf4881ea54f9d4205d PiperOrigin-RevId: 153044267 --- .../transports/BuildEventStreamOptions.java | 28 ++++++++++++++++++++++ .../transports/BuildEventTransportFactory.java | 18 ++++++++++++-- 2 files changed, 44 insertions(+), 2 deletions(-) (limited to 'src/main/java/com/google') diff --git a/src/main/java/com/google/devtools/build/lib/buildeventstream/transports/BuildEventStreamOptions.java b/src/main/java/com/google/devtools/build/lib/buildeventstream/transports/BuildEventStreamOptions.java index c4cb96a36d..67618a3fbb 100644 --- a/src/main/java/com/google/devtools/build/lib/buildeventstream/transports/BuildEventStreamOptions.java +++ b/src/main/java/com/google/devtools/build/lib/buildeventstream/transports/BuildEventStreamOptions.java @@ -38,6 +38,26 @@ public class BuildEventStreamOptions extends OptionsBase { ) public String buildEventBinaryFile; + @Option( + name = "experimental_build_event_text_file_path_conversion", + defaultValue = "true", + category = "hidden", + help = "Convert paths in the text file representation of the build event protocol to more" + + " globally valid URIs whenever possible; if disabled, the file:// uri scheme will always" + + " be used" + ) + public boolean buildEventTextFilePathConversion; + + @Option( + name = "experimental_build_event_binary_file_path_conversion", + defaultValue = "true", + category = "hidden", + help = "Convert paths in the binary file representation of the build event protocol to more" + + " globally valid URIs whenever possible; if disabled, the file:// uri scheme will always" + + " be used" + ) + public boolean buildEventBinaryFilePathConversion; + public String getBuildEventTextFile() { return buildEventTextFile; } @@ -45,4 +65,12 @@ public class BuildEventStreamOptions extends OptionsBase { public String getBuildEventBinaryFile() { return buildEventBinaryFile; } + + public boolean getBuildEventTextFilePathConversion() { + return buildEventTextFilePathConversion; + } + + public boolean getBuildEventBinaryFilePathConversion() { + return buildEventBinaryFilePathConversion; + } } diff --git a/src/main/java/com/google/devtools/build/lib/buildeventstream/transports/BuildEventTransportFactory.java b/src/main/java/com/google/devtools/build/lib/buildeventstream/transports/BuildEventTransportFactory.java index 6d8f97f17f..b89017adc7 100644 --- a/src/main/java/com/google/devtools/build/lib/buildeventstream/transports/BuildEventTransportFactory.java +++ b/src/main/java/com/google/devtools/build/lib/buildeventstream/transports/BuildEventTransportFactory.java @@ -20,6 +20,7 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet.Builder; import com.google.devtools.build.lib.buildeventstream.BuildEventTransport; import com.google.devtools.build.lib.buildeventstream.PathConverter; +import com.google.devtools.build.lib.vfs.Path; import java.io.IOException; /** Factory used to create a Set of BuildEventTransports from BuildEventStreamOptions. */ @@ -33,7 +34,9 @@ public enum BuildEventTransportFactory { @Override protected BuildEventTransport create(BuildEventStreamOptions options, PathConverter pathConverter) throws IOException { - return new TextFormatFileTransport(options.getBuildEventTextFile(), pathConverter); + return new TextFormatFileTransport( + options.getBuildEventTextFile(), + options.getBuildEventTextFilePathConversion() ? pathConverter : new NullPathConverter()); } }, @@ -46,7 +49,11 @@ public enum BuildEventTransportFactory { @Override protected BuildEventTransport create(BuildEventStreamOptions options, PathConverter pathConverter) throws IOException { - return new BinaryFormatFileTransport(options.getBuildEventBinaryFile(), pathConverter); + return new BinaryFormatFileTransport( + options.getBuildEventBinaryFile(), + options.getBuildEventBinaryFilePathConversion() + ? pathConverter + : new NullPathConverter()); } }; @@ -75,4 +82,11 @@ public enum BuildEventTransportFactory { /** Creates a BuildEventTransport from the specified options. */ protected abstract BuildEventTransport create(BuildEventStreamOptions options, PathConverter pathConverter) throws IOException; + + private static class NullPathConverter implements PathConverter { + @Override + public String apply(Path path) { + return "file://" + path; + } + } } -- cgit v1.2.3