From 2348a75882bda4ed8b983fd4f8af2c45fa292e10 Mon Sep 17 00:00:00 2001 From: tomlu Date: Wed, 4 Jul 2018 08:55:42 -0700 Subject: Include more information about build events' referenced local files. Instead of just a path, events now include information about the type of file (output, source file, stdout/stderr, test logs, etc.). This information can be used by the uploaders to determine a) whether to upload, b) what kind of lease to give the files. RELNOTES: None PiperOrigin-RevId: 203285549 --- .../build/lib/buildeventstream/BuildEvent.java | 61 +++++++++++++++++++--- 1 file changed, 53 insertions(+), 8 deletions(-) (limited to 'src/main/java/com/google/devtools/build/lib/buildeventstream/BuildEvent.java') diff --git a/src/main/java/com/google/devtools/build/lib/buildeventstream/BuildEvent.java b/src/main/java/com/google/devtools/build/lib/buildeventstream/BuildEvent.java index 6d6900687c..cee573cae2 100644 --- a/src/main/java/com/google/devtools/build/lib/buildeventstream/BuildEvent.java +++ b/src/main/java/com/google/devtools/build/lib/buildeventstream/BuildEvent.java @@ -14,10 +14,11 @@ package com.google.devtools.build.lib.buildeventstream; -import com.google.common.collect.ImmutableSet; +import com.google.common.base.Objects; +import com.google.common.collect.ImmutableList; import com.google.devtools.build.lib.events.ExtendedEventHandler; import com.google.devtools.build.lib.vfs.Path; -import java.util.Set; +import java.util.Collection; /** * Interface for objects that can be posted on the public event stream. @@ -27,6 +28,52 @@ import java.util.Set; */ public interface BuildEvent extends ChainableEvent, ExtendedEventHandler.Postable { + /** + * A local file that is referenced by the build event. These can be uploaded to a separate backend + * storage. + */ + final class LocalFile { + + /** + * The type of the local file. This is used by uploaders to determine how long to store the + * associated files for. + */ + public enum LocalFileType { + SOURCE, + OUTPUT, + SUCCESSFUL_TEST_OUTPUT, + FAILED_TEST_OUTPUT, + STDOUT, + STDERR, + LOG, + } + + public final Path path; + public final LocalFileType type; + + public LocalFile(Path path, LocalFileType type) { + this.path = path; + this.type = type; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + LocalFile localFile = (LocalFile) o; + return Objects.equal(path, localFile.path) && type == localFile.type; + } + + @Override + public int hashCode() { + return Objects.hashCode(path, type); + } + } + /** * Returns a list of files that are referenced in the protobuf representation returned by {@link * #asStreamProto(BuildEventContext)}. @@ -35,13 +82,11 @@ public interface BuildEvent extends ChainableEvent, ExtendedEventHandler.Postabl * only returns files directly referenced in the protobuf returned by {@link * #asStreamProto(BuildEventContext)}. * - *

Note the consistency requirement - you must not attempt to pass Path objects to the - * {@link PathConverter} unless you have returned the Path object here. + *

Note the consistency requirement - you must not attempt to pass Path objects to the {@link + * PathConverter} unless you have returned a corresponding {@link LocalFile} object here. */ - // TODO(ulfjack): Consider moving the upload call to the BuildEventContext and returning a map - // from Path to URI, rather than a callback. - default Set referencedLocalFiles() { - return ImmutableSet.of(); + default Collection referencedLocalFiles() { + return ImmutableList.of(); } /** -- cgit v1.2.3