aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/actions
diff options
context:
space:
mode:
authorGravatar Klaus Aehlig <aehlig@google.com>2017-07-13 13:22:44 +0200
committerGravatar László Csomor <laszlocsomor@google.com>2017-07-14 10:49:59 +0200
commitce1c36d5e1865cb033c7da338b3fbe643e145e55 (patch)
tree15a4856bf023542ffba0300d79547edaf489dda2 /src/main/java/com/google/devtools/build/lib/actions
parent34bf0c6e3a7f07679ff29f983c348e2e88a96591 (diff)
BEP: Report configuration for all actions
Whenever we report an action in the build event protocol that has a configuration associated with it, report the configuration as well in the protocol (and not only the checksum, if the configuration is not that of one of the top-level configured targets). Change-Id: I9b085d5381b3c3509b4f3b99c8a77bc8fba6abfe PiperOrigin-RevId: 161789745
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/actions')
-rw-r--r--src/main/java/com/google/devtools/build/lib/actions/ActionExecutedEvent.java28
-rw-r--r--src/main/java/com/google/devtools/build/lib/actions/ActionOwner.java21
2 files changed, 40 insertions, 9 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 e00555edb0..c8d957224c 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
@@ -19,7 +19,9 @@ import com.google.devtools.build.lib.buildeventstream.BuildEvent;
import com.google.devtools.build.lib.buildeventstream.BuildEventConverters;
import com.google.devtools.build.lib.buildeventstream.BuildEventId;
import com.google.devtools.build.lib.buildeventstream.BuildEventStreamProtos;
+import com.google.devtools.build.lib.buildeventstream.BuildEventWithConfiguration;
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;
@@ -30,7 +32,7 @@ import java.util.Collection;
* This event is fired during the build, when an action is executed. It contains information about
* the action: the Action itself, and the output file names its stdout and stderr are recorded in.
*/
-public class ActionExecutedEvent implements BuildEvent {
+public class ActionExecutedEvent implements BuildEventWithConfiguration {
private final Action action;
private final ActionExecutionException exception;
private final Path stdout;
@@ -84,6 +86,19 @@ public class ActionExecutedEvent implements BuildEvent {
}
@Override
+ public Collection<BuildEvent> getConfigurations() {
+ if (action.getOwner() != null) {
+ BuildEvent configuration = action.getOwner().getConfiguration();
+ if (configuration == null) {
+ configuration = new NullConfiguration();
+ }
+ return ImmutableList.of(configuration);
+ } else {
+ return ImmutableList.<BuildEvent>of();
+ }
+ }
+
+ @Override
public BuildEventStreamProtos.BuildEvent asStreamProto(BuildEventConverters converters) {
PathConverter pathConverter = converters.pathConverter();
BuildEventStreamProtos.ActionExecuted.Builder actionBuilder =
@@ -108,13 +123,12 @@ public class ActionExecutedEvent implements BuildEvent {
if (action.getOwner() != null && action.getOwner().getLabel() != null) {
actionBuilder.setLabel(action.getOwner().getLabel().toString());
}
- // TODO(aehlig): ensure the configuration is shown in the stream, even if it is not
- // one of the configurations of a top-level configured target.
if (action.getOwner() != null) {
- actionBuilder.setConfiguration(
- BuildEventStreamProtos.BuildEventId.ConfigurationId.newBuilder()
- .setId(action.getOwner().getConfigurationChecksum())
- .build());
+ BuildEvent configuration = action.getOwner().getConfiguration();
+ if (configuration == null) {
+ configuration = new NullConfiguration();
+ }
+ actionBuilder.setConfiguration(configuration.getEventId().asStreamProto().getConfiguration());
}
if (exception == null) {
actionBuilder.setPrimaryOutput(
diff --git a/src/main/java/com/google/devtools/build/lib/actions/ActionOwner.java b/src/main/java/com/google/devtools/build/lib/actions/ActionOwner.java
index 72ca914811..b8c0dc883f 100644
--- a/src/main/java/com/google/devtools/build/lib/actions/ActionOwner.java
+++ b/src/main/java/com/google/devtools/build/lib/actions/ActionOwner.java
@@ -15,6 +15,7 @@ package com.google.devtools.build.lib.actions;
import com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableList;
+import com.google.devtools.build.lib.buildeventstream.BuildEvent;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable;
import com.google.devtools.build.lib.events.Location;
@@ -34,8 +35,15 @@ import javax.annotation.Nullable;
public abstract class ActionOwner {
/** An action owner for special cases. Usage is strongly discouraged. */
public static final ActionOwner SYSTEM_ACTION_OWNER =
- ActionOwner.create(null, ImmutableList.<AspectDescriptor>of(),
- null, "system", "empty target kind", "system", null);
+ ActionOwner.create(
+ null,
+ ImmutableList.<AspectDescriptor>of(),
+ null,
+ "system",
+ "empty target kind",
+ "system",
+ null,
+ null);
public static ActionOwner create(
@Nullable Label label,
@@ -44,6 +52,7 @@ public abstract class ActionOwner {
@Nullable String mnemonic,
@Nullable String targetKind,
String configurationChecksum,
+ @Nullable BuildEvent configuration,
@Nullable String additionalProgressInfo) {
return new AutoValue_ActionOwner(
location,
@@ -51,6 +60,7 @@ public abstract class ActionOwner {
aspectDescriptors,
mnemonic,
Preconditions.checkNotNull(configurationChecksum),
+ configuration,
targetKind,
additionalProgressInfo);
}
@@ -77,6 +87,13 @@ public abstract class ActionOwner {
*/
public abstract String getConfigurationChecksum();
+ /**
+ * Return the configuration of the action owner, if any, as it should be reported in the build
+ * event protocol.
+ */
+ @Nullable
+ public abstract BuildEvent getConfiguration();
+
/** Returns the target kind (rule class name) for this ActionOwner, if any; null otherwise. */
@Nullable
public abstract String getTargetKind();