diff options
author | Eduardo Colaco <eduardocolaco@google.com> | 2017-07-26 20:33:14 +0200 |
---|---|---|
committer | Jakob Buchgraber <buchgr@google.com> | 2017-07-27 09:05:16 +0200 |
commit | 43bc4923e5b2219924ae95f17ffe8b9f35f32fce (patch) | |
tree | 7bb555d2fc14279ba46266bd6d4f70a3b8ce4917 /src/main/java/com | |
parent | 684d120e6c3b32ddc99e115c54cdbff64f6c519f (diff) |
Add configuration and target label to ActionCompletedId.
This is a first step on moving the configuration checksum and target
label from the ActionExecuted payload and into ActionCompletedId.
Change-Id: I989c9b708cd2a4172f6483d97bc7842d9841e3a8
PiperOrigin-RevId: 163233097
Diffstat (limited to 'src/main/java/com')
6 files changed, 52 insertions, 25 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/actions/ActionExecutedEvent.java b/src/main/java/com/google/devtools/build/lib/actions/ActionExecutedEvent.java index c8d957224c..44b19a509e 100644 --- a/src/main/java/com/google/devtools/build/lib/actions/ActionExecutedEvent.java +++ b/src/main/java/com/google/devtools/build/lib/actions/ActionExecutedEvent.java @@ -23,8 +23,6 @@ import com.google.devtools.build.lib.buildeventstream.BuildEventWithConfiguratio import com.google.devtools.build.lib.buildeventstream.GenericBuildEvent; import com.google.devtools.build.lib.buildeventstream.NullConfiguration; import com.google.devtools.build.lib.buildeventstream.PathConverter; -import com.google.devtools.build.lib.causes.ActionFailed; -import com.google.devtools.build.lib.causes.Cause; import com.google.devtools.build.lib.vfs.Path; import java.util.Collection; @@ -71,12 +69,13 @@ public class ActionExecutedEvent implements BuildEventWithConfiguration { @Override public BuildEventId getEventId() { - if (getException() != null) { - Cause cause = - new ActionFailed(action.getPrimaryOutput().getPath(), action.getOwner().getLabel()); - return BuildEventId.fromCause(cause); - } else { + if (action.getOwner() == null) { return BuildEventId.actionCompleted(action.getPrimaryOutput().getPath()); + } else { + return BuildEventId.actionCompleted( + action.getPrimaryOutput().getPath(), + action.getOwner().getLabel(), + action.getOwner().getConfigurationChecksum()); } } diff --git a/src/main/java/com/google/devtools/build/lib/actions/ActionExecutionException.java b/src/main/java/com/google/devtools/build/lib/actions/ActionExecutionException.java index 315163bcba..59199d626b 100644 --- a/src/main/java/com/google/devtools/build/lib/actions/ActionExecutionException.java +++ b/src/main/java/com/google/devtools/build/lib/actions/ActionExecutionException.java @@ -120,7 +120,10 @@ public class ActionExecutionException extends Exception { ? NestedSetBuilder.<Cause>emptySet(Order.STABLE_ORDER) : NestedSetBuilder.<Cause>create( Order.STABLE_ORDER, - new ActionFailed(action.getPrimaryOutput().getPath(), action.getOwner().getLabel())); + new ActionFailed( + action.getPrimaryOutput().getPath(), + action.getOwner().getLabel(), + action.getOwner().getConfigurationChecksum())); } /** diff --git a/src/main/java/com/google/devtools/build/lib/buildeventstream/BuildEventId.java b/src/main/java/com/google/devtools/build/lib/buildeventstream/BuildEventId.java index 23da261d1a..2acc069c7c 100644 --- a/src/main/java/com/google/devtools/build/lib/buildeventstream/BuildEventId.java +++ b/src/main/java/com/google/devtools/build/lib/buildeventstream/BuildEventId.java @@ -14,6 +14,8 @@ package com.google.devtools.build.lib.buildeventstream; +import com.google.devtools.build.lib.buildeventstream.BuildEventStreamProtos.BuildEventId.ActionCompletedId; +import com.google.devtools.build.lib.buildeventstream.BuildEventStreamProtos.BuildEventId.ConfigurationId; import com.google.devtools.build.lib.causes.Cause; import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.vfs.Path; @@ -21,6 +23,7 @@ import com.google.protobuf.TextFormat; import java.io.Serializable; import java.util.List; import java.util.Objects; +import javax.annotation.Nullable; import javax.annotation.concurrent.Immutable; /** @@ -184,13 +187,21 @@ public final class BuildEventId implements Serializable { } public static BuildEventId actionCompleted(Path path) { + return actionCompleted(path, null, null); + } + + public static BuildEventId actionCompleted( + Path path, @Nullable Label label, @Nullable String configurationChecksum) { + ActionCompletedId.Builder actionId = + ActionCompletedId.newBuilder().setPrimaryOutput(path.toString()); + if (label != null) { + actionId.setLabel(label.toString()); + } + if (configurationChecksum != null) { + actionId.setConfiguration(ConfigurationId.newBuilder().setId(configurationChecksum)); + } return new BuildEventId( - BuildEventStreamProtos.BuildEventId.newBuilder() - .setActionCompleted( - BuildEventStreamProtos.BuildEventId.ActionCompletedId.newBuilder() - .setPrimaryOutput(path.toString()) - .build()) - .build()); + BuildEventStreamProtos.BuildEventId.newBuilder().setActionCompleted(actionId).build()); } public static BuildEventId fromArtifactGroupName(String name) { diff --git a/src/main/java/com/google/devtools/build/lib/buildeventstream/proto/build_event_stream.proto b/src/main/java/com/google/devtools/build/lib/buildeventstream/proto/build_event_stream.proto index 7dcf3f7f35..653ea55bcf 100644 --- a/src/main/java/com/google/devtools/build/lib/buildeventstream/proto/build_event_stream.proto +++ b/src/main/java/com/google/devtools/build/lib/buildeventstream/proto/build_event_stream.proto @@ -122,6 +122,10 @@ message BuildEventId { // this includes all failed actions). message ActionCompletedId { string primary_output = 1; + // Optional, the label of the owner of the action, for reference. + string label = 2; + // Optional, the id of the configuration of the action owner. + ConfigurationId configuration = 3; } // Identifier of an event reporting on an individual test run. The label @@ -347,11 +351,11 @@ message ActionExecuted { // (e.g., a file path). File stderr = 4; - // Optionally, the label of the owner of the action, for reference. - string label = 5; + // Deprecated. This field is now present on ActionCompletedId. + string label = 5 [deprecated = true]; - // Optinally, the id of the configuration of the action owner. - BuildEventId.ConfigurationId configuration = 7; + // Deprecated. This field is now present on ActionCompletedId. + BuildEventId.ConfigurationId configuration = 7 [deprecated = true]; // Primary output; only provided for successful actions. File primary_output = 6; diff --git a/src/main/java/com/google/devtools/build/lib/causes/ActionFailed.java b/src/main/java/com/google/devtools/build/lib/causes/ActionFailed.java index 1b7b0088e8..c537adeba2 100644 --- a/src/main/java/com/google/devtools/build/lib/causes/ActionFailed.java +++ b/src/main/java/com/google/devtools/build/lib/causes/ActionFailed.java @@ -14,8 +14,12 @@ package com.google.devtools.build.lib.causes; import com.google.devtools.build.lib.buildeventstream.BuildEventStreamProtos; +import com.google.devtools.build.lib.buildeventstream.BuildEventStreamProtos.BuildEventId; +import com.google.devtools.build.lib.buildeventstream.BuildEventStreamProtos.BuildEventId.ActionCompletedId; +import com.google.devtools.build.lib.buildeventstream.BuildEventStreamProtos.BuildEventId.ConfigurationId; import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.vfs.Path; +import javax.annotation.Nullable; /** * Class describing a {@link Cause} that is associated with an action. It is uniquely determined by @@ -24,10 +28,12 @@ import com.google.devtools.build.lib.vfs.Path; public class ActionFailed implements Cause { private final Path path; private final Label label; + private final String configurationChecksum; - public ActionFailed(Path path, Label label) { + public ActionFailed(Path path, Label label, @Nullable String configurationChecksum) { this.path = path; this.label = label; + this.configurationChecksum = configurationChecksum; } @Override @@ -42,11 +48,14 @@ public class ActionFailed implements Cause { @Override public BuildEventStreamProtos.BuildEventId getIdProto() { - return BuildEventStreamProtos.BuildEventId.newBuilder() - .setActionCompleted( - BuildEventStreamProtos.BuildEventId.ActionCompletedId.newBuilder() - .setPrimaryOutput(path.toString()) - .build()) - .build(); + ActionCompletedId.Builder actionId = + ActionCompletedId.newBuilder().setPrimaryOutput(path.toString()); + if (label != null) { + actionId.setLabel(label.toString()); + } + if (configurationChecksum != null) { + actionId.setConfiguration(ConfigurationId.newBuilder().setId(configurationChecksum)); + } + return BuildEventId.newBuilder().setActionCompleted(actionId).build(); } } diff --git a/src/main/java/com/google/devtools/build/lib/causes/BUILD b/src/main/java/com/google/devtools/build/lib/causes/BUILD index b03924ef21..3d44ab757a 100644 --- a/src/main/java/com/google/devtools/build/lib/causes/BUILD +++ b/src/main/java/com/google/devtools/build/lib/causes/BUILD @@ -12,5 +12,6 @@ java_library( "//src/main/java/com/google/devtools/build/lib:vfs", "//src/main/java/com/google/devtools/build/lib/buildeventstream/proto:build_event_stream_java_proto", "//src/main/java/com/google/devtools/build/lib/cmdline", + "//third_party:guava", ], ) |