aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkActionFactory.java49
1 files changed, 35 insertions, 14 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkActionFactory.java b/src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkActionFactory.java
index 5befedce89..110e323a5b 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkActionFactory.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkActionFactory.java
@@ -50,12 +50,15 @@ import com.google.devtools.build.lib.skylarkinterface.SkylarkSignature;
import com.google.devtools.build.lib.skylarkinterface.SkylarkValue;
import com.google.devtools.build.lib.syntax.BaseFunction;
import com.google.devtools.build.lib.syntax.BuiltinFunction;
+import com.google.devtools.build.lib.syntax.Environment;
import com.google.devtools.build.lib.syntax.EvalException;
import com.google.devtools.build.lib.syntax.EvalUtils;
+import com.google.devtools.build.lib.syntax.Mutability;
import com.google.devtools.build.lib.syntax.Runtime;
import com.google.devtools.build.lib.syntax.Runtime.NoneType;
import com.google.devtools.build.lib.syntax.SkylarkDict;
import com.google.devtools.build.lib.syntax.SkylarkList;
+import com.google.devtools.build.lib.syntax.SkylarkMutable;
import com.google.devtools.build.lib.syntax.SkylarkNestedSet;
import com.google.devtools.build.lib.syntax.SkylarkSemanticsOptions;
import com.google.devtools.build.lib.syntax.SkylarkSignatureProcessor;
@@ -65,6 +68,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
+import javax.annotation.Nullable;
/**
* Provides a Skylark interface for all action creation needs.
@@ -869,9 +873,8 @@ public class SkylarkActionFactory implements SkylarkValue {
+ "# ]"
+ "</pre>"
)
- static class Args implements SkylarkValue {
-
- private final SkylarkRuleContext context;
+ static class Args extends SkylarkMutable {
+ private final Mutability mutability;
private final SkylarkCustomCommandLine.Builder commandLine;
private ParameterFileType parameterFileType = ParameterFileType.SHELL_QUOTED;
private String flagFormatString;
@@ -1101,11 +1104,11 @@ public class SkylarkActionFactory implements SkylarkValue {
this.parameterFileType = parameterFileType;
}
- public Args(
- SkylarkRuleContext context,
+ private Args(
+ @Nullable Mutability mutability,
SkylarkSemanticsOptions skylarkSemantics,
EventHandler eventHandler) {
- this.context = context;
+ this.mutability = mutability != null ? mutability : Mutability.IMMUTABLE;
this.commandLine = new SkylarkCustomCommandLine.Builder(skylarkSemantics, eventHandler);
}
@@ -1114,8 +1117,8 @@ public class SkylarkActionFactory implements SkylarkValue {
}
@Override
- public boolean isImmutable() {
- return context.isImmutable();
+ public Mutability mutability() {
+ return mutability;
}
@Override
@@ -1128,14 +1131,28 @@ public class SkylarkActionFactory implements SkylarkValue {
}
}
- @SkylarkCallable(
+ @SkylarkSignature(
name = "args",
- doc = "returns an Args object that can be used to build memory-efficient command lines."
+ doc = "returns an Args object that can be used to build memory-efficient command lines.",
+ objectType = SkylarkActionFactory.class,
+ returnType = Args.class,
+ parameters = {
+ @Param(
+ name = "self",
+ type = SkylarkActionFactory.class,
+ doc = "This 'actions' object."
+ )
+ },
+ useEnvironment = true
)
- public Args args() {
- return new Args(
- context, skylarkSemanticsOptions, ruleContext.getAnalysisEnvironment().getEventHandler());
- }
+ public static final BuiltinFunction args =
+ new BuiltinFunction("args") {
+ public Args invoke(SkylarkActionFactory self, Environment env) {
+ return new Args(env.mutability(),
+ env.getSemantics(),
+ self.ruleContext.getAnalysisEnvironment().getEventHandler());
+ }
+ };
@Override
public boolean isImmutable() {
@@ -1151,4 +1168,8 @@ public class SkylarkActionFactory implements SkylarkValue {
void nullify() {
ruleContext = null;
}
+
+ static {
+ SkylarkSignatureProcessor.configureSkylarkFunctions(SkylarkActionFactory.class);
+ }
}