aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Klaus Aehlig <aehlig@google.com>2017-04-13 10:10:43 +0000
committerGravatar Jakob Buchgraber <buchgr@google.com>2017-04-13 12:50:31 +0200
commiteeb89700bd859635b79c8beee449960563eea16c (patch)
tree84ba433c8521cb75dff41188940999aba913d9f3 /src
parentf85290973eaafa10d031a092ed795a7fd8165533 (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/google/devtools/build/lib/buildeventstream/transports/BuildEventStreamOptions.java28
-rw-r--r--src/main/java/com/google/devtools/build/lib/buildeventstream/transports/BuildEventTransportFactory.java18
-rw-r--r--src/test/java/com/google/devtools/build/lib/buildeventstream/transports/BuildEventTransportFactoryTest.java4
3 files changed, 48 insertions, 2 deletions
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;
+ }
+ }
}
diff --git a/src/test/java/com/google/devtools/build/lib/buildeventstream/transports/BuildEventTransportFactoryTest.java b/src/test/java/com/google/devtools/build/lib/buildeventstream/transports/BuildEventTransportFactoryTest.java
index c6762a8b5f..f7f4b91555 100644
--- a/src/test/java/com/google/devtools/build/lib/buildeventstream/transports/BuildEventTransportFactoryTest.java
+++ b/src/test/java/com/google/devtools/build/lib/buildeventstream/transports/BuildEventTransportFactoryTest.java
@@ -83,6 +83,7 @@ public class BuildEventTransportFactoryTest {
public void testCreatesTextFormatFileTransport() throws IOException {
File textFile = tmp.newFile();
when(options.getBuildEventTextFile()).thenReturn(textFile.getAbsolutePath());
+ when(options.getBuildEventTextFilePathConversion()).thenReturn(true);
when(options.getBuildEventBinaryFile()).thenReturn("");
ImmutableSet<BuildEventTransport> transports =
BuildEventTransportFactory.createFromOptions(options, pathConverter);
@@ -97,6 +98,7 @@ public class BuildEventTransportFactoryTest {
File binaryFile = tmp.newFile();
when(options.getBuildEventTextFile()).thenReturn("");
when(options.getBuildEventBinaryFile()).thenReturn(binaryFile.getAbsolutePath());
+ when(options.getBuildEventBinaryFilePathConversion()).thenReturn(true);
ImmutableSet<BuildEventTransport> transports =
BuildEventTransportFactory.createFromOptions(options, pathConverter);
assertThat(FluentIterable.from(transports).transform(GET_CLASS))
@@ -111,6 +113,8 @@ public class BuildEventTransportFactoryTest {
File binaryFile = tmp.newFile();
when(options.getBuildEventTextFile()).thenReturn(textFile.getAbsolutePath());
when(options.getBuildEventBinaryFile()).thenReturn(binaryFile.getAbsolutePath());
+ when(options.getBuildEventBinaryFilePathConversion()).thenReturn(true);
+ when(options.getBuildEventTextFilePathConversion()).thenReturn(true);
ImmutableSet<BuildEventTransport> transports =
BuildEventTransportFactory.createFromOptions(options, pathConverter);
assertThat(FluentIterable.from(transports).transform(GET_CLASS))