aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/analysis/actions/SpawnAction.java
diff options
context:
space:
mode:
authorGravatar cpeyser <cpeyser@google.com>2018-02-22 09:27:40 -0800
committerGravatar Copybara-Service <copybara-piper@google.com>2018-02-22 09:29:44 -0800
commita41e01ee7ed395c4913ff31ed8c2e84297fabe1c (patch)
tree0ecb5d6a0bd06c0b0ed54c5c4ec4c5981efbde2b /src/main/java/com/google/devtools/build/lib/analysis/actions/SpawnAction.java
parentca93b67eb4b2c78e82c6f523ebc2e15acb831683 (diff)
Add @AutoCodec to SpawnAction. Refactor the SpawnAction API for extra actions so that it is non-generic and does not persist a GeneratedExtension, which is hard to serialize.
PiperOrigin-RevId: 186627440
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/analysis/actions/SpawnAction.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/actions/SpawnAction.java35
1 files changed, 13 insertions, 22 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/actions/SpawnAction.java b/src/main/java/com/google/devtools/build/lib/analysis/actions/SpawnAction.java
index badf8ef784..23005b7b6c 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/actions/SpawnAction.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/actions/SpawnAction.java
@@ -60,6 +60,7 @@ import com.google.devtools.build.lib.analysis.config.BuildConfiguration;
import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
import com.google.devtools.build.lib.collect.nestedset.NestedSetView;
+import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec;
import com.google.devtools.build.lib.syntax.SkylarkList;
import com.google.devtools.build.lib.util.Fingerprint;
import com.google.devtools.build.lib.util.LazyString;
@@ -68,7 +69,6 @@ import com.google.devtools.build.lib.vfs.PathFragment;
import com.google.errorprone.annotations.CompileTimeConstant;
import com.google.errorprone.annotations.FormatMethod;
import com.google.errorprone.annotations.FormatString;
-import com.google.protobuf.GeneratedMessage.GeneratedExtension;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
@@ -79,22 +79,12 @@ import javax.annotation.CheckReturnValue;
import javax.annotation.Nullable;
/** An Action representing an arbitrary subprocess to be forked and exec'd. */
+@AutoCodec
public class SpawnAction extends AbstractAction implements ExecutionInfoSpecifier, CommandAction {
-
- /** Sets extensions on ExtraActionInfo **/
- protected static class ExtraActionInfoSupplier<T> {
- private final GeneratedExtension<ExtraActionInfo, T> extension;
- private final T value;
-
- protected ExtraActionInfoSupplier(GeneratedExtension<ExtraActionInfo, T> extension, T value) {
- this.extension = extension;
- this.value = value;
- }
-
- void extend(ExtraActionInfo.Builder builder) {
- builder.setExtension(extension, value);
- }
+ /** Sets extensions on {@link ExtraActionInfo}. */
+ public interface ExtraActionInfoSupplier {
+ void extend(ExtraActionInfo.Builder builder);
}
private static final String GUID = "ebd6fce3-093e-45ee-adb6-bf513b602f0d";
@@ -109,7 +99,7 @@ public class SpawnAction extends AbstractAction implements ExecutionInfoSpecifie
private final ResourceSet resourceSet;
private final ImmutableMap<String, String> executionInfo;
- private final ExtraActionInfoSupplier<?> extraActionInfoSupplier;
+ private final ExtraActionInfoSupplier extraActionInfoSupplier;
/**
* Constructs a SpawnAction using direct initialization arguments.
@@ -131,6 +121,7 @@ public class SpawnAction extends AbstractAction implements ExecutionInfoSpecifie
* @param progressMessage the message printed during the progression of the build.
* @param mnemonic the mnemonic that is reported in the master log.
*/
+ @AutoCodec.Instantiator
public SpawnAction(
ActionOwner owner,
Iterable<Artifact> tools,
@@ -197,7 +188,7 @@ public class SpawnAction extends AbstractAction implements ExecutionInfoSpecifie
RunfilesSupplier runfilesSupplier,
String mnemonic,
boolean executeUnconditionally,
- ExtraActionInfoSupplier<?> extraActionInfoSupplier) {
+ ExtraActionInfoSupplier extraActionInfoSupplier) {
super(owner, tools, inputs, runfilesSupplier, outputs, env);
this.resourceSet = resourceSet;
this.executionInfo = executionInfo;
@@ -611,7 +602,7 @@ public class SpawnAction extends AbstractAction implements ExecutionInfoSpecifie
private CharSequence progressMessage;
private String mnemonic = "Unknown";
- protected ExtraActionInfoSupplier<?> extraActionInfoSupplier = null;
+ protected ExtraActionInfoSupplier extraActionInfoSupplier = null;
private boolean disableSandboxing = false;
/**
@@ -1346,9 +1337,8 @@ public class SpawnAction extends AbstractAction implements ExecutionInfoSpecifie
return this;
}
- public <T> Builder setExtraActionInfo(
- GeneratedExtension<ExtraActionInfo, T> extension, T value) {
- this.extraActionInfoSupplier = new ExtraActionInfoSupplier<>(extension, value);
+ public <T> Builder setExtraActionInfo(ExtraActionInfoSupplier extraActionInfoSupplier) {
+ this.extraActionInfoSupplier = extraActionInfoSupplier;
return this;
}
@@ -1362,7 +1352,8 @@ public class SpawnAction extends AbstractAction implements ExecutionInfoSpecifie
* Command line implementation that optimises for containing executable args, command lines, and
* command lines spilled to param files.
*/
- private static class SpawnActionCommandLine extends CommandLine {
+ @AutoCodec
+ static class SpawnActionCommandLine extends CommandLine {
private final Object[] values;
SpawnActionCommandLine(Object[] values) {