From e2f61b197a1375b04222aa99a6bbcb290a19e36c Mon Sep 17 00:00:00 2001 From: brandjon Date: Wed, 15 Aug 2018 13:55:29 -0700 Subject: Clarify docs for ctx.actions.run_shell()'s command/arguments - Clarified incompatibility between giving args and giving list of strings for command. - Added more detail about how $i expansion is done. - Removed incorrect indication that None is allowed for "command". RELNOTES: None PiperOrigin-RevId: 208877037 --- .../skylarkbuildapi/SkylarkActionFactoryApi.java | 48 ++++++++++++++-------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/SkylarkActionFactoryApi.java b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/SkylarkActionFactoryApi.java index 282890de33..51879b72f3 100644 --- a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/SkylarkActionFactoryApi.java +++ b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/SkylarkActionFactoryApi.java @@ -23,7 +23,6 @@ import com.google.devtools.build.lib.skylarkinterface.SkylarkModuleCategory; import com.google.devtools.build.lib.skylarkinterface.SkylarkValue; import com.google.devtools.build.lib.syntax.Environment; import com.google.devtools.build.lib.syntax.EvalException; -import com.google.devtools.build.lib.syntax.Runtime; import com.google.devtools.build.lib.syntax.SkylarkDict; import com.google.devtools.build.lib.syntax.SkylarkList; import com.google.devtools.build.lib.syntax.SkylarkNestedSet; @@ -343,12 +342,17 @@ public interface SkylarkActionFactoryApi extends SkylarkValue { 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." + "Command line arguments of the action. Must be a list of strings or " + + "actions.args() objects." + + "" + + "

Bazel passes the elements in this attribute as arguments to the command." + "The command can access these arguments as $1, $2, " - + "etc."), + + "etc. Args objects are flattened before indexing. It is generally not useful " + + "to have an Args object of unknown size in this list, since that means all " + + "strings in or after that Args object will be at unpredictable indices." + + "" + + "

In the case where command is a list of strings, this " + + "parameter may not be used."), @Param( name = "mnemonic", type = String.class, @@ -363,21 +367,31 @@ public interface SkylarkActionFactoryApi extends SkylarkValue { 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. If a sequence of strings " - + "is passed, then arguments must not be used.

" - + "The command string 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."), + "Shell command to execute. This may either be a string (preferred) or a sequence " + + "of strings (deprecated)." + + "" + + "

If command is a string, then it is executed as if by " + + "sh -c <command> \"\" <arguments> -- that is, the " + + "elements in arguments are made available to the command as " + + "$1, $2, etc. If arguments contains " + + "any actions.args() objects, " + + "their contents are appended one by one to the command line, so " + + "$i can refer to individual strings within an Args " + + "object. Note that it is not useful to pass an Args object of unknown size " + + "as part of arguments, since then the strings would not be at " + + "known indices." + + "" + + "

(Deprecated) If command is a sequence of strings, " + + "the first item is the executable to run and the remaining items are its " + + "arguments. If this form is used, the arguments parameter must " + + "not be supplied." + + "" + + "

Bazel uses the same shell to execute the command as it does for " + + "genrules."), @Param( name = "progress_message", type = String.class, -- cgit v1.2.3