From 6891ebbd7b9356b8ce5f6835e3eb7acd9cf988d7 Mon Sep 17 00:00:00 2001 From: cparsons Date: Tue, 1 May 2018 15:53:33 -0700 Subject: Migrate AbstractAction and SkylarkActionFactory to buildapi RELNOTES: None. PiperOrigin-RevId: 195011200 --- .../lib/analysis/skylark/SkylarkActionFactory.java | 868 +-------------------- 1 file changed, 26 insertions(+), 842 deletions(-) (limited to 'src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkActionFactory.java') 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 731ccf1cbe..4121df20b1 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 @@ -42,13 +42,12 @@ import com.google.devtools.build.lib.collect.nestedset.NestedSet; import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder; import com.google.devtools.build.lib.events.Location; import com.google.devtools.build.lib.packages.TargetUtils; -import com.google.devtools.build.lib.skylarkinterface.Param; -import com.google.devtools.build.lib.skylarkinterface.ParamType; -import com.google.devtools.build.lib.skylarkinterface.SkylarkCallable; +import com.google.devtools.build.lib.skylarkbuildapi.CommandLineArgsApi; +import com.google.devtools.build.lib.skylarkbuildapi.FileApi; +import com.google.devtools.build.lib.skylarkbuildapi.SkylarkActionFactoryApi; import com.google.devtools.build.lib.skylarkinterface.SkylarkModule; import com.google.devtools.build.lib.skylarkinterface.SkylarkModuleCategory; import com.google.devtools.build.lib.skylarkinterface.SkylarkPrinter; -import com.google.devtools.build.lib.skylarkinterface.SkylarkValue; import com.google.devtools.build.lib.syntax.BaseFunction; import com.google.devtools.build.lib.syntax.Environment; import com.google.devtools.build.lib.syntax.EvalException; @@ -71,14 +70,7 @@ import java.util.UUID; import javax.annotation.Nullable; /** Provides a Skylark interface for all action creation needs. */ -@SkylarkModule( - name = "actions", - category = SkylarkModuleCategory.BUILTIN, - doc = - "Module providing functions to create actions. " - + "Access this module using ctx.actions." -) -public class SkylarkActionFactory implements SkylarkValue { +public class SkylarkActionFactory implements SkylarkActionFactoryApi { private final SkylarkRuleContext context; private final SkylarkSemantics skylarkSemantics; private RuleContext ruleContext; @@ -100,44 +92,7 @@ public class SkylarkActionFactory implements SkylarkValue { : ruleContext.getBinOrGenfilesDirectory(); } - @SkylarkCallable( - name = "declare_file", - doc = - "Declares that the rule or aspect creates a file with the given filename. " - + "If sibling is not specified, the file name is relative to the package" - + "directory, otherwise the file is in the same directory as sibling." - + "Files cannot be created outside of the current package." - + "

Remember that in addition to declaring a file, you must separately create an " - + "action that emits the file. Creating that action will require passing the returned " - + "File object to the action's construction function." - + "

Note that predeclared output files do not " - + "need to be (and cannot be) declared using this function. You can obtain their " - + "File objects from ctx.outputs" - + " instead. " - + "See example of use", - parameters = { - @Param( - name = "filename", - type = String.class, - doc = - "If no 'sibling' provided, path of the new file, relative " - + "to the current package. Otherwise a base name for a file " - + "('sibling' determines a directory)." - ), - @Param( - name = "sibling", - doc = - "A file that lives in the same directory as the newly created file. " - + "The file must be in the current package.", - type = Artifact.class, - noneable = true, - positional = false, - named = true, - defaultValue = "None" - ) - } - ) + @Override public Artifact declareFile(String filename, Object sibling) throws EvalException { context.checkMutable("actions.declare_file"); if (Runtime.NONE.equals(sibling)) { @@ -149,31 +104,7 @@ public class SkylarkActionFactory implements SkylarkValue { } } - @SkylarkCallable( - name = "declare_directory", - doc = - "Declares that rule or aspect create a directory with the given name, in the " - + "current package. You must create an action that generates the directory.", - parameters = { - @Param( - name = "filename", - type = String.class, - doc = - "If no 'sibling' provided, path of the new directory, relative " - + "to the current package. Otherwise a base name for a file " - + "('sibling' defines a directory)." - ), - @Param( - name = "sibling", - doc = "A file that lives in the same directory as the newly declared directory.", - type = Artifact.class, - noneable = true, - positional = false, - named = true, - defaultValue = "None" - ) - } - ) + @Override public Artifact declareDirectory(String filename, Object sibling) throws EvalException { context.checkMutable("actions.declare_directory"); if (Runtime.NONE.equals(sibling)) { @@ -186,34 +117,7 @@ public class SkylarkActionFactory implements SkylarkValue { } } - - @SkylarkCallable( - name = "do_nothing", - doc = - "Creates an empty action that neither executes a command nor produces any " - + "output, but that is useful for inserting 'extra actions'.", - parameters = { - @Param( - name = "mnemonic", - type = String.class, - named = true, - positional = false, - doc = "A one-word description of the action, for example, CppCompile or GoLink." - ), - @Param( - name = "inputs", - allowedTypes = { - @ParamType(type = SkylarkList.class), - @ParamType(type = SkylarkNestedSet.class), - }, - generic1 = Artifact.class, - named = true, - positional = false, - defaultValue = "[]", - doc = "List of the input files of the action." - ), - } - ) + @Override public void doNothing(String mnemonic, Object inputs) throws EvalException { context.checkMutable("actions.do_nothing"); NestedSet inputSet = inputs instanceof SkylarkNestedSet @@ -235,45 +139,19 @@ public class SkylarkActionFactory implements SkylarkValue { ruleContext.registerAction(action); } - @SkylarkCallable( - name = "write", - doc = - "Creates a file write action. When the action is executed, it will write the given content " - + "to a file. This is used to generate files using information available in the " - + "analysis phase. If the file is large and with a lot of static content, consider " - + "using expand_template.", - parameters = { - @Param(name = "output", type = Artifact.class, doc = "The output file.", named = true), - @Param( - name = "content", - type = Object.class, - allowedTypes = {@ParamType(type = String.class), @ParamType(type = Args.class)}, - doc = - "the contents of the file. " - + "May be a either a string or an " - + "actions.args() object.", - named = true - ), - @Param( - name = "is_executable", - type = Boolean.class, - defaultValue = "False", - doc = "Whether the output file should be executable.", - named = true - ) - } - ) - public void write(Artifact output, Object content, Boolean isExecutable) throws EvalException { + @Override + public void write(FileApi output, Object content, Boolean isExecutable) throws EvalException { context.checkMutable("actions.write"); final Action action; if (content instanceof String) { - action = FileWriteAction.create(ruleContext, output, (String) content, isExecutable); + action = + FileWriteAction.create(ruleContext, (Artifact) output, (String) content, isExecutable); } else if (content instanceof Args) { Args args = (Args) content; action = new ParameterFileWriteAction( ruleContext.getActionOwner(), - output, + (Artifact) output, args.build(), args.parameterFileType, StandardCharsets.UTF_8); @@ -283,138 +161,7 @@ public class SkylarkActionFactory implements SkylarkValue { ruleContext.registerAction(action); } - @SkylarkCallable( - name = "run", - doc = - "Creates an action that runs an executable. " - + "See example of use", - parameters = { - @Param( - name = "outputs", - type = SkylarkList.class, - generic1 = Artifact.class, - named = true, - positional = false, - doc = "List of the output files of the action." - ), - @Param( - name = "inputs", - allowedTypes = { - @ParamType(type = SkylarkList.class), - @ParamType(type = SkylarkNestedSet.class), - }, - generic1 = Artifact.class, - defaultValue = "[]", - named = true, - positional = false, - doc = "List or depset of the input files of the action." - ), - @Param( - name = "executable", - type = Object.class, - allowedTypes = { - @ParamType(type = Artifact.class), - @ParamType(type = String.class), - }, - named = true, - positional = false, - doc = "The executable file to be called by the action." - ), - @Param( - name = "tools", - allowedTypes = { - @ParamType(type = SkylarkList.class), - @ParamType(type = SkylarkNestedSet.class), - }, - generic1 = Artifact.class, - defaultValue = "unbound", - named = true, - positional = false, - doc = - "List or depset of any tools needed by the action. Tools are inputs with additional " - + "runfiles that are automatically made available to the action." - ), - @Param( - name = "arguments", - type = Object.class, - allowedTypes = { - @ParamType(type = SkylarkList.class), - }, - defaultValue = "[]", - named = true, - positional = false, - doc = - "Command line arguments of the action. " - + "Must be a list of strings or " - + "actions.args() objects." - ), - @Param( - name = "mnemonic", - type = String.class, - noneable = true, - defaultValue = "None", - named = true, - positional = false, - doc = "A one-word description of the action, for example, CppCompile or GoLink." - ), - @Param( - name = "progress_message", - type = String.class, - noneable = true, - defaultValue = "None", - named = true, - positional = false, - doc = - "Progress message to show to the user during the build, " - + "for example, \"Compiling foo.cc to create foo.o\"." - ), - @Param( - name = "use_default_shell_env", - type = Boolean.class, - defaultValue = "False", - named = true, - positional = false, - doc = "Whether the action should use the built in shell environment or not." - ), - @Param( - name = "env", - type = SkylarkDict.class, - noneable = true, - defaultValue = "None", - named = true, - positional = false, - doc = "Sets the dictionary of environment variables." - ), - @Param( - name = "execution_requirements", - type = SkylarkDict.class, - noneable = true, - defaultValue = "None", - named = true, - positional = false, - doc = - "Information for scheduling the action. See " - + "tags " - + "for useful keys." - ), - @Param( - // TODO(bazel-team): The name here isn't accurate anymore. - // This is technically experimental, so folks shouldn't be too attached, - // but consider renaming to be more accurate/opaque. - name = "input_manifests", - type = SkylarkList.class, - noneable = true, - defaultValue = "None", - named = true, - positional = false, - doc = - "(Experimental) sets the input runfiles metadata; " - + "they are typically generated by resolve_command." - ) - }, - useLocation = true - ) + @Override public void run( SkylarkList outputs, Object inputs, @@ -485,148 +232,7 @@ public class SkylarkActionFactory implements SkylarkValue { return ruleContext; } - @SkylarkCallable( - name = "run_shell", - doc = - "Creates an action that runs a shell command. " - + "See example of use", - parameters = { - @Param( - name = "outputs", - type = SkylarkList.class, - generic1 = Artifact.class, - named = true, - positional = false, - doc = "List of the output files of the action." - ), - @Param( - name = "inputs", - allowedTypes = { - @ParamType(type = SkylarkList.class), - @ParamType(type = SkylarkNestedSet.class), - }, - generic1 = Artifact.class, - defaultValue = "[]", - named = true, - positional = false, - doc = "List or depset of the input files of the action." - ), - @Param( - name = "tools", - allowedTypes = { - @ParamType(type = SkylarkList.class), - @ParamType(type = SkylarkNestedSet.class), - }, - generic1 = Artifact.class, - defaultValue = "unbound", - named = true, - positional = false, - doc = - "List or depset of any tools needed by the action. Tools are inputs with additional " - + "runfiles that are automatically made available to the action." - ), - @Param( - name = "arguments", - allowedTypes = { - @ParamType(type = SkylarkList.class), - }, - defaultValue = "[]", - named = true, - positional = false, - doc = - "Command line arguments of the action. " - + "Must be a list of strings or " - + "actions.args() objects.
" - + "Blaze passes the elements in this attribute as arguments to the command." - + "The command can access these arguments as $1, $2, etc." - ), - @Param( - name = "mnemonic", - type = String.class, - noneable = true, - defaultValue = "None", - named = true, - positional = false, - doc = "A one-word description of the action, for example, CppCompile or GoLink." - ), - @Param( - name = "command", - type = Object.class, - allowedTypes = { - @ParamType(type = String.class), - @ParamType(type = SkylarkList.class, generic1 = String.class), - @ParamType(type = Runtime.NoneType.class), - }, - named = true, - positional = false, - doc = - "Shell command to execute.

" - + "Passing a sequence of strings to this attribute is deprecated and Blaze may " - + "stop accepting such values in the future.

" - + "The command can access the elements of the arguments object via " - + "$1, $2, etc.
" - + "When this argument is a string, it must be a valid shell command. For example: " - + "\"echo foo > $1\". Blaze uses the same shell to execute the " - + "command as it does for genrules." - ), - @Param( - name = "progress_message", - type = String.class, - noneable = true, - defaultValue = "None", - named = true, - positional = false, - doc = - "Progress message to show to the user during the build, " - + "for example, \"Compiling foo.cc to create foo.o\"." - ), - @Param( - name = "use_default_shell_env", - type = Boolean.class, - defaultValue = "False", - named = true, - positional = false, - doc = "Whether the action should use the built in shell environment or not." - ), - @Param( - name = "env", - type = SkylarkDict.class, - noneable = true, - defaultValue = "None", - named = true, - positional = false, - doc = "Sets the dictionary of environment variables." - ), - @Param( - name = "execution_requirements", - type = SkylarkDict.class, - noneable = true, - defaultValue = "None", - named = true, - positional = false, - doc = - "Information for scheduling the action. See " - + "tags " - + "for useful keys." - ), - @Param( - // TODO(bazel-team): The name here isn't accurate anymore. - // This is technically experimental, so folks shouldn't be too attached, - // but consider renaming to be more accurate/opaque. - name = "input_manifests", - type = SkylarkList.class, - noneable = true, - defaultValue = "None", - named = true, - positional = false, - doc = - "(Experimental) sets the input runfiles metadata; " - + "they are typically generated by resolve_command." - ) - }, - useLocation = true - ) + @Override public void runShell( SkylarkList outputs, Object inputs, @@ -835,52 +441,10 @@ public class SkylarkActionFactory implements SkylarkValue { return mnemonic + "FromSkylark"; } - @SkylarkCallable( - name = "expand_template", - doc = - "Creates a template expansion action. When the action is executed, it will " - + "generate a file based on a template. Parts of the template will be replaced " - + "using the substitutions dictionary. Whenever a key of the " - + "dictionary appears in the template, it is replaced with the associated value. " - + "There is no special syntax for the keys. You may, for example, use curly braces " - + "to avoid conflicts (for example, {KEY}). " - + "" - + "See example of use", - parameters = { - @Param( - name = "template", - type = Artifact.class, - named = true, - positional = false, - doc = "The template file, which is a UTF-8 encoded text file." - ), - @Param( - name = "output", - type = Artifact.class, - named = true, - positional = false, - doc = "The output file, which is a UTF-8 encoded text file." - ), - @Param( - name = "substitutions", - type = SkylarkDict.class, - named = true, - positional = false, - doc = "Substitutions to make when expanding the template." - ), - @Param( - name = "is_executable", - type = Boolean.class, - defaultValue = "False", - named = true, - positional = false, - doc = "Whether the output file should be executable." - ) - } - ) + @Override public void expandTemplate( - Artifact template, - Artifact output, + FileApi template, + FileApi output, SkylarkDict substitutionsUnchecked, Boolean executable) throws EvalException { @@ -901,8 +465,8 @@ public class SkylarkActionFactory implements SkylarkValue { TemplateExpansionAction action = new TemplateExpansionAction( ruleContext.getActionOwner(), - template, - output, + (Artifact) template, + (Artifact) output, substitutionsBuilder.build(), executable); ruleContext.registerAction(action); @@ -1004,7 +568,7 @@ public class SkylarkActionFactory implements SkylarkValue { + "" ) @VisibleForTesting - public static class Args extends SkylarkMutable { + public static class Args extends SkylarkMutable implements CommandLineArgsApi { private final Mutability mutability; private final SkylarkSemantics skylarkSemantics; private final SkylarkCustomCommandLine.Builder commandLine; @@ -1012,95 +576,7 @@ public class SkylarkActionFactory implements SkylarkValue { private String flagFormatString; private boolean useAlways; - @SkylarkCallable( - name = "add", - doc = - "Appends an argument to this command line." - + "" - + "

Deprecation note: The before_each, join_with " - + "and map_fn params are replaced by the " - + "add_all() and add_joined() " - + "methods. These parameters will be removed, and are currently disallowed if the " - + "" - + "--incompatible_disallow_old_style_args_add flag is set. Likewise, " - + "value should now be a scalar value, not a list, tuple, or depset of " - + "items.", - parameters = { - @Param( - name = "arg_name_or_value", - doc = - "If two positional parameters are passed this is interpreted as the arg name. " - + "The arg name is added before the value without any processing. " - + "If only one positional parameter is passed, it is interpreted as " - + "value (see below)." - ), - @Param( - name = "value", - defaultValue = "unbound", - doc = - "The object to append. It will be converted to a string using the standard " - + "conversion mentioned above. Since there is no map_each parameter " - + "for this function, value should be either a string or a " - + "File." - + "" - + "

Deprecated behavior: value may also be a list, tuple, " - + "or depset of multiple items to append." - ), - @Param( - name = "format", - type = String.class, - named = true, - positional = false, - defaultValue = "None", - noneable = true, - doc = - "A format string pattern, to be applied to the stringified version of value" - + "." - + "" - + "

Deprecated behavior: If value is a list or depset, " - + "formatting is applied to each item." - ), - @Param( - name = "before_each", - type = String.class, - named = true, - positional = false, - defaultValue = "None", - noneable = true, - doc = - "Deprecated: Only supported when value is a list, tuple, or " - + "depset. This string will be appended prior to appending each item." - ), - @Param( - name = "join_with", - type = String.class, - named = true, - positional = false, - defaultValue = "None", - noneable = true, - doc = - "Deprecated: Only supported when value is a list, tuple, or " - + "depset. All items will be joined together using this string to form a single " - + "arg to append." - ), - @Param( - name = "map_fn", - type = BaseFunction.class, - named = true, - positional = false, - defaultValue = "None", - noneable = true, - doc = - "Deprecated: Only supported when value is a list, tuple, or " - + "depset. This is a function that transforms the sequence of items into a list " - + "of strings. The sequence of items is given as a positional argument -- the " - + "function must not take any other parameters -- and the returned list's length " - + "must equal the number of items. Use map_each of add_all" - + " or add_joined instead." - ) - }, - useLocation = true - ) + @Override public NoneType addArgument( Object argNameOrValue, Object value, @@ -1169,148 +645,7 @@ public class SkylarkActionFactory implements SkylarkValue { return Runtime.NONE; } - @SkylarkCallable( - name = "add_all", - doc = - "Appends multiple arguments to this command line. For depsets, the items are " - + "evaluated lazily during the execution phase." - + "" - + "

Most of the processing occurs over a list of arguments to be appended, as per " - + "the following steps:" - + "

    " - + "
  1. If map_each is given, it is applied to each input item, and the " - + " resulting lists of strings are concatenated to form the initial argument " - + " list. Otherwise, the initial argument list is the result of applying the " - + " standard conversion to each item." - + "
  2. Each argument in the list is formatted with format_each, if " - + " present." - + "
  3. If uniquify is true, duplicate arguments are removed. The first " - + " occurrence is the one that remains." - + "
  4. If a before_each string is given, it is inserted as a new " - + " argument before each existing argument in the list. This effectively doubles " - + " the number of arguments to be appended by this point." - + "
  5. Except in the case that the list is empty and omit_if_empty is " - + " true (the default), the arg name and terminate_with are " - + " inserted as the first and last arguments, respectively, if they are given." - + "
" - + "Note that empty strings are valid arguments that are subject to all these " - + "processing steps.", - parameters = { - @Param( - name = "arg_name_or_values", - doc = - "If two positional parameters are passed this is interpreted as the arg name. " - + "The arg name is added before the values without any processing. " - + "This arg name will not be added if omit_if_empty is true " - + "(the default) and no other items are appended (as happens if " - + "values is empty or all of its items are filtered). " - + "If only one positional parameter is passed, it is interpreted as " - + "values (see below)." - ), - @Param( - name = "values", - allowedTypes = { - @ParamType(type = SkylarkList.class), - @ParamType(type = SkylarkNestedSet.class), - }, - defaultValue = "unbound", - doc = "The list, tuple, or depset whose items will be appended." - ), - @Param( - name = "map_each", - type = BaseFunction.class, - named = true, - positional = false, - defaultValue = "None", - noneable = true, - doc = - "A function that converts each item to zero or more strings, which may be further " - + "processed before appending. If this param is not provided, the standard " - + "conversion is used." - + "" - + "

The function takes in the item as a positional parameter and must have no " - + "other parameters. The return value's type depends on how many arguments " - + "are to be produced for the item:" - + "

" - + "Returning a single string or None has the same effect as " - + "returning a list of length 1 or length 0 respectively. However, it is more " - + "efficient and readable to avoid creating a list where it is not needed." - + "" - + "

Warning: print() " - + "statements that are executed during the call to map_each will " - + "not produce any visible output." - ), - @Param( - name = "format_each", - type = String.class, - named = true, - positional = false, - defaultValue = "None", - noneable = true, - doc = - "An optional format string pattern, applied to each string returned by the " - + "map_each function. " - + "The format string must have exactly one '%s' placeholder." - ), - @Param( - name = "before_each", - type = String.class, - named = true, - positional = false, - defaultValue = "None", - noneable = true, - doc = - "An optional string to append before each argument derived from values " - + "is appended." - ), - @Param( - name = "omit_if_empty", - type = Boolean.class, - named = true, - positional = false, - defaultValue = "True", - doc = - "If true, if there are no arguments derived from values to be appended, " - + "then all further processing is suppressed and the command line will be " - + "unchanged. If false, the arg name and terminate_with, " - + "if provided, will still be appended regardless of whether or not there are " - + "other arguments." - ), - @Param( - name = "uniquify", - type = Boolean.class, - named = true, - positional = false, - defaultValue = "False", - doc = - "If true, duplicate arguments that are derived from values will be " - + "omitted. Only the first occurrence of each argument will remain. Usually this " - + "feature is not needed because depsets already omit duplicates, but it can be " - + "useful if map_each emits the same string for multiple items." - ), - @Param( - name = "terminate_with", - type = String.class, - named = true, - positional = false, - defaultValue = "None", - noneable = true, - doc = - "An optional string to append after all other arguments. This string will not be " - + "added if omit_if_empty is true (the default) and no other items " - + "are appended (as happens if values is empty or all of its items " - + "are filtered)." - ), - }, - useLocation = true - ) + @Override public NoneType addAll( Object argNameOrValue, Object values, @@ -1350,111 +685,7 @@ public class SkylarkActionFactory implements SkylarkValue { return Runtime.NONE; } - @SkylarkCallable( - name = "add_joined", - doc = - "Appends an argument to this command line by concatenating together multiple values " - + "using a separator. For depsets, the items are evaluated lazily during the " - + "execution phase." - + "" - + "

Processing is similar to add_all(), but " - + "the list of arguments derived from values is combined into a single " - + "argument as if by join_with.join(...), and then formatted using the " - + "given format_joined string template. Unlike add_all(), " - + "there is no before_each or terminate_with parameter " - + "since these are not generally useful when the items are combined into a single " - + "argument." - + "" - + "

If after filtering there are no strings to join into an argument, and if " - + "omit_if_empty is true (the default), no processing is done. " - + "Otherwise if there are no strings to join but omit_if_empty is " - + "false, the joined string will be an empty string.", - parameters = { - @Param( - name = "arg_name_or_values", - doc = - "If two positional parameters are passed this is interpreted as the arg name. " - + "The arg name is added before values without any processing. " - + "This arg will not be added if omit_if_empty is true " - + "(the default) and there are no strings derived from values " - + "to join together (which can happen if values is empty " - + "or all of its items are filtered)." - + "If only one positional parameter is passed, it is interpreted as " - + "values (see below)." - ), - @Param( - name = "values", - allowedTypes = { - @ParamType(type = SkylarkList.class), - @ParamType(type = SkylarkNestedSet.class), - }, - defaultValue = "unbound", - doc = "The list, tuple, or depset whose items will be joined." - ), - @Param( - name = "join_with", - type = String.class, - named = true, - positional = false, - doc = - "A delimiter string used to join together the strings obtained from applying " - + "map_each and format_each, in the same manner as " - + "string.join()." - ), - @Param( - name = "map_each", - type = BaseFunction.class, - named = true, - positional = false, - defaultValue = "None", - noneable = true, - doc = "Same as for add_all." - ), - @Param( - name = "format_each", - type = String.class, - named = true, - positional = false, - defaultValue = "None", - noneable = true, - doc = "Same as for add_all." - ), - @Param( - name = "format_joined", - type = String.class, - named = true, - positional = false, - defaultValue = "None", - noneable = true, - doc = - "An optional format string pattern applied to the joined string. " - + "The format string must have exactly one '%s' placeholder." - ), - @Param( - name = "omit_if_empty", - type = Boolean.class, - named = true, - positional = false, - defaultValue = "True", - doc = - "If true, if there are no strings to join together (either because values" - + " is empty or all its items are filtered), then all further processing " - + "is suppressed and the command line will be unchanged. If false, then even if " - + "there are no strings to join together, two arguments will be appended: " - + "the arg name followed by an empty string (which is the logical join " - + "of zero strings)." - ), - @Param( - name = "uniquify", - type = Boolean.class, - named = true, - positional = false, - defaultValue = "False", - doc = "Same as for add_all." - ) - }, - useLocation = true - ) + @Override public NoneType addJoined( Object argNameOrValue, Object values, @@ -1596,35 +827,7 @@ public class SkylarkActionFactory implements SkylarkValue { } } - @SkylarkCallable( - name = "use_param_file", - doc = - "Spills the args to a params file, replacing them with a pointer to the param file. " - + "Use when your args may be too large for the system's command length limits ", - parameters = { - @Param( - name = "param_file_arg", - type = String.class, - named = true, - doc = - "A format string with a single \"%s\". " - + "If the args are spilled to a params file then they are replaced " - + "with an argument consisting of this string formatted with " - + "the path of the params file." - ), - @Param( - name = "use_always", - type = Boolean.class, - named = true, - positional = false, - defaultValue = "False", - doc = - "Whether to always spill the args to a params file. If false, " - + "bazel will decide whether the arguments need to be spilled " - + "based on your system and arg length." - ) - } - ) + @Override public void useParamsFile(String paramFileArg, Boolean useAlways) throws EvalException { if (isImmutable()) { throw new EvalException(null, "cannot modify frozen value"); @@ -1638,22 +841,7 @@ public class SkylarkActionFactory implements SkylarkValue { this.useAlways = useAlways; } - @SkylarkCallable( - name = "set_param_file_format", - doc = "Sets the format of the param file when written to disk", - parameters = { - @Param( - name = "format", - type = String.class, - named = true, - doc = - "The format of the param file. Must be one of:
" - + "\"shell\": All arguments are shell quoted and separated by whitespace
" - + "\"multiline\": All arguments are unquoted and separated by newline characters" - + "The format defaults to \"shell\" if not called." - ) - } - ) + @Override public void setParamFileFormat(String format) throws EvalException { if (isImmutable()) { throw new EvalException(null, "cannot modify frozen value"); @@ -1695,11 +883,7 @@ public class SkylarkActionFactory implements SkylarkValue { } } - @SkylarkCallable( - name = "args", - doc = "Returns an Args object that can be used to build memory-efficient command lines.", - useEnvironment = true - ) + @Override public Args args(Environment env) { return new Args(env.mutability(), skylarkSemantics); } -- cgit v1.2.3