blob: 8427b2261cfda94ebcb94294a85e9c23aab4f117 [file] [log] [blame]
cparsonsabbb9002018-05-11 11:54:17 -07001// Copyright 2018 The Bazel Authors. All rights reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package com.google.devtools.build.lib.skylarkbuildapi;
16
17import com.google.common.collect.ImmutableList;
18import com.google.devtools.build.lib.cmdline.Label;
adonovanbc74d1d2020-04-30 12:08:31 -070019import com.google.devtools.build.lib.collect.nestedset.Depset;
jcater880b5f72019-12-06 07:49:43 -080020import com.google.devtools.build.lib.skylarkbuildapi.core.ProviderApi;
21import com.google.devtools.build.lib.skylarkbuildapi.core.StructApi;
22import com.google.devtools.build.lib.skylarkbuildapi.core.TransitiveInfoCollectionApi;
jcater5bd63692019-12-13 08:58:16 -080023import com.google.devtools.build.lib.skylarkbuildapi.platform.ConstraintValueInfoApi;
juliexxia0a0a13b2020-04-21 15:55:00 -070024import com.google.devtools.build.lib.skylarkbuildapi.platform.ExecGroupCollectionApi;
jcatereaf2b542019-12-06 09:21:31 -080025import com.google.devtools.build.lib.skylarkbuildapi.platform.ToolchainContextApi;
cparsonsabbb9002018-05-11 11:54:17 -070026import com.google.devtools.build.lib.syntax.ClassObject;
Googlera9c93632019-11-13 10:48:07 -080027import com.google.devtools.build.lib.syntax.Dict;
cparsonsabbb9002018-05-11 11:54:17 -070028import com.google.devtools.build.lib.syntax.EvalException;
Googler641bdf72019-11-12 10:32:26 -080029import com.google.devtools.build.lib.syntax.NoneType;
Googler4871cb02019-11-12 17:16:42 -080030import com.google.devtools.build.lib.syntax.Sequence;
laurentlb6659b4c2019-02-18 07:23:36 -080031import com.google.devtools.build.lib.syntax.StarlarkSemantics.FlagIdentifier;
Googlera3421e22019-09-26 06:48:32 -070032import com.google.devtools.build.lib.syntax.StarlarkThread;
Googler34f70582019-11-25 12:27:34 -080033import com.google.devtools.build.lib.syntax.StarlarkValue;
Googlercfd681f2019-11-11 07:24:02 -080034import com.google.devtools.build.lib.syntax.Tuple;
cparsonsabbb9002018-05-11 11:54:17 -070035import javax.annotation.Nullable;
adonovanb0174682020-05-18 16:01:53 -070036import net.starlark.java.annot.Param;
37import net.starlark.java.annot.ParamType;
38import net.starlark.java.annot.StarlarkBuiltin;
39import net.starlark.java.annot.StarlarkDocumentationCategory;
40import net.starlark.java.annot.StarlarkMethod;
cparsonsabbb9002018-05-11 11:54:17 -070041
42/** Interface for a context object given to rule implementation functions. */
gregce220a1c82020-05-01 10:19:52 -070043@StarlarkBuiltin(
cparsonsabbb9002018-05-11 11:54:17 -070044 name = "ctx",
gregce220a1c82020-05-01 10:19:52 -070045 category = StarlarkDocumentationCategory.BUILTIN,
Googler34f70582019-11-25 12:27:34 -080046 doc =
47 "A context object that is passed to the implementation function for a rule or aspect. It"
48 + " provides access to the information and methods needed to analyze the current"
49 + " target.<p>In particular, it lets the implementation function access the current"
50 + " target's label, attributes, configuration, and the providers of its dependencies."
51 + " It has methods for declaring output files and the actions that produce them."
52 + "<p>Context objects essentially live for the duration of the call to the"
53 + " implementation function. It is not useful to access these objects outside of their"
Googler510d9e12019-12-01 07:39:55 -080054 + " associated function. See the <a"
Googler34f70582019-11-25 12:27:34 -080055 + " href='../rules.$DOC_EXT#implementation-function'>Rules page</a> for more "
56 + "information.")
gregced281df72020-05-11 12:27:06 -070057public interface StarlarkRuleContextApi<ConstraintValueT extends ConstraintValueInfoApi>
jcater5bd63692019-12-13 08:58:16 -080058 extends StarlarkValue {
cparsonsabbb9002018-05-11 11:54:17 -070059
jcater3ecaa492019-12-09 16:26:00 -080060 String DOC_NEW_FILE_TAIL =
61 "Does not actually create a file on the file system, just declares that some action will do"
62 + " so. You must create an action that generates the file. If the file should be visible"
63 + " to other rules, declare a rule output instead when possible. Doing so enables Blaze"
64 + " to associate a label with the file that rules can refer to (allowing finer"
65 + " dependency control) instead of referencing the whole rule.";
66 String EXECUTABLE_DOC =
Googler057a5e62019-09-24 16:09:29 -070067 "A <code>struct</code> containing executable files defined in <a "
cparsons71915952019-10-31 09:05:36 -070068 + "href='attr.html#label'>label type attributes</a> marked as <a "
69 + "href='attr.html#label.executable'><code>executable=True</code><a>. The struct "
Googler057a5e62019-09-24 16:09:29 -070070 + "fields correspond to the attribute names. Each value in the struct is either a <a "
cparsons71915952019-10-31 09:05:36 -070071 + "href='File.html'><code>File</code></a> or <code>None</code>. If an optional "
Googler057a5e62019-09-24 16:09:29 -070072 + "attribute is not specified in the rule then the corresponding struct value is "
73 + "<code>None</code>. If a label type is not marked as <code>executable=True</code>, no "
74 + "corresponding struct field is generated. <a "
75 + "href=\"https://github.com/bazelbuild/examples/blob/master/rules/actions_run/"
cparsonsabbb9002018-05-11 11:54:17 -070076 + "execute.bzl\">See example of use</a>.";
jcater3ecaa492019-12-09 16:26:00 -080077 String FILES_DOC =
cparsons71915952019-10-31 09:05:36 -070078 "A <code>struct</code> containing files defined in <a href='attr.html#label'>label</a>"
79 + " or <a href='attr.html#label_list'>label list</a> type attributes. The struct"
Googler057a5e62019-09-24 16:09:29 -070080 + " fields correspond to the attribute names. The struct values are <code>list</code> of"
cparsons71915952019-10-31 09:05:36 -070081 + " <a href='File.html'><code>File</code></a>s. It is a shortcut for:<pre"
Googler057a5e62019-09-24 16:09:29 -070082 + " class=language-python>[f for t in ctx.attr.&lt;ATTR&gt; for f in t.files]</pre> In"
83 + " other words, use <code>files</code> to access the <a"
84 + " href=\"../rules.$DOC_EXT#requesting-output-files\">default outputs</a> of a"
85 + " dependency. <a"
86 + " href=\"https://github.com/bazelbuild/examples/blob/master/rules/depsets/foo.bzl\">See"
87 + " example of use</a>.";
jcater3ecaa492019-12-09 16:26:00 -080088 String FILE_DOC =
cparsons71915952019-10-31 09:05:36 -070089 "A <code>struct</code> containing files defined in <a href='attr.html#label'>label type"
Googler057a5e62019-09-24 16:09:29 -070090 + " attributes</a> marked as <a"
cparsons71915952019-10-31 09:05:36 -070091 + " href='attr.html#label.allow_single_file'><code>allow_single_file</code></a>. The"
Googler057a5e62019-09-24 16:09:29 -070092 + " struct fields correspond to the attribute names. The struct value is always a <a"
cparsons71915952019-10-31 09:05:36 -070093 + " href='File.html'><code>File</code></a> or <code>None</code>. If an optional"
Googler057a5e62019-09-24 16:09:29 -070094 + " attribute is not specified in the rule then the corresponding struct value is"
95 + " <code>None</code>. If a label type is not marked as <code>allow_single_file</code>,"
96 + " no corresponding struct field is generated. It is a shortcut for:<pre"
97 + " class=language-python>list(ctx.attr.&lt;ATTR&gt;.files)[0]</pre>In other words, use"
98 + " <code>file</code> to access the (singular) <a"
99 + " href=\"../rules.$DOC_EXT#requesting-output-files\">default output</a> of a"
100 + " dependency. <a"
101 + " href=\"https://github.com/bazelbuild/examples/blob/master/rules/expand_template/hello.bzl\">See"
102 + " example of use</a>.";
jcater3ecaa492019-12-09 16:26:00 -0800103 String ATTR_DOC =
Googler057a5e62019-09-24 16:09:29 -0700104 "A struct to access the values of the <a href='../rules.$DOC_EXT#attributes'>attributes</a>. "
105 + "The values are provided by the user (if not, a default value is used). The attributes "
106 + "of the struct and the types of their values correspond to the keys and values of the "
cparsons71915952019-10-31 09:05:36 -0700107 + "<a href='globals.html#rule.attrs'><code>attrs</code> dict</a> provided to the <a "
108 + "href='globals.html#rule'><code>rule</code> function</a>. <a "
Googler057a5e62019-09-24 16:09:29 -0700109 + "href=\"https://github.com/bazelbuild/examples/blob/master/rules/attributes/"
cparsonsabbb9002018-05-11 11:54:17 -0700110 + "printer.bzl\">See example of use</a>.";
jcater3ecaa492019-12-09 16:26:00 -0800111 String SPLIT_ATTR_DOC =
cparsonsabbb9002018-05-11 11:54:17 -0700112 "A struct to access the values of attributes with split configurations. If the attribute is "
113 + "a label list, the value of split_attr is a dict of the keys of the split (as strings) "
114 + "to lists of the ConfiguredTargets in that branch of the split. If the attribute is a "
115 + "label, then the value of split_attr is a dict of the keys of the split (as strings) "
116 + "to single ConfiguredTargets. Attributes with split configurations still appear in the "
117 + "attr struct, but their values will be single lists with all the branches of the split "
118 + "merged together.";
jcater3ecaa492019-12-09 16:26:00 -0800119 String OUTPUTS_DOC =
cparsonsabbb9002018-05-11 11:54:17 -0700120 "A pseudo-struct containing all the predeclared output files, represented by "
121 + "<a href='File.html'><code>File</code></a> objects. See the "
122 + "<a href='../rules.$DOC_EXT#files'>Rules page</a> for more information and examples."
123 + "<p>This field does not exist on aspect contexts, since aspects do not have "
124 + "predeclared outputs."
125 + "<p>The fields of this object are defined as follows. It is an error if two outputs "
126 + "produce the same field name or have the same label."
127 + "<ul>"
128 + "<li>If the rule declares an <a href='globals.html#rule.outputs'><code>outputs</code>"
129 + "</a> dict, then for every entry in the dict, there is a field whose name is the key "
130 + "and whose value is the corresponding <code>File</code>."
131 + "<li>For every attribute of type <a href='attr.html#output'><code>attr.output</code>"
132 + "</a> that the rule declares, there is a field whose name is the attribute's name. "
133 + "If the target specified a label for that attribute, then the field value is the "
134 + "corresponding <code>File</code>; otherwise the field value is <code>None</code>."
135 + "<li>For every attribute of type <a href='attr.html#output_list'><code>attr.output_list"
136 + "</code></a> that the rule declares, there is a field whose name is the attribute's "
137 + "name. The field value is a list of <code>File</code> objects corresponding to the "
138 + "labels given for that attribute in the target, or an empty list if the attribute was "
139 + "not specified in the target."
140 + "<li><b>(Deprecated)</b> If the rule is marked <a href='globals.html#rule.executable'>"
Googler8c1b44f2018-08-28 07:51:45 -0700141 + "<code>executable</code></a> or <a href='globals.html#rule.test'><code>test</code>"
142 + "</a>, there is a field named <code>\"executable\"</code>, which is the default "
143 + "executable. It is recommended that instead of using this, you pass another file "
144 + "(either predeclared or not) to the <code>executable</code> arg of "
Googler20a6ac72019-03-07 07:23:11 -0800145 + "<a href='DefaultInfo.html'><code>DefaultInfo</code></a>."
cparsonsabbb9002018-05-11 11:54:17 -0700146 + "</ul>";
147
gregce8345b792020-05-15 13:23:29 -0700148 @StarlarkMethod(
Googler20a6ac72019-03-07 07:23:11 -0800149 name = "default_provider",
150 structField = true,
151 doc = "Deprecated. Use <a href=\"DefaultInfo.html\">DefaultInfo</a> instead.")
jcater3ecaa492019-12-09 16:26:00 -0800152 ProviderApi getDefaultProvider();
cparsonsabbb9002018-05-11 11:54:17 -0700153
gregce8345b792020-05-15 13:23:29 -0700154 @StarlarkMethod(
jcater3ecaa492019-12-09 16:26:00 -0800155 name = "actions",
156 structField = true,
157 doc = "Contains methods for declaring output files and the actions that produce them.")
gregceff941232020-04-21 08:03:32 -0700158 StarlarkActionFactoryApi actions();
cparsonsabbb9002018-05-11 11:54:17 -0700159
gregce8345b792020-05-15 13:23:29 -0700160 @StarlarkMethod(
cparsonsabbb9002018-05-11 11:54:17 -0700161 name = "created_actions",
Googler34f70582019-11-25 12:27:34 -0800162 doc =
163 "For rules with <a href=\"globals.html#rule._skylark_testable\">_skylark_testable</a>"
164 + " set to <code>True</code>, this returns an <a"
165 + " href=\"globals.html#Actions\">Actions</a> provider representing all actions"
166 + " created so far for the current rule. For all other rules, returns"
167 + " <code>None</code>. Note that the provider is not updated when subsequent actions"
168 + " are created, so you will have to call this function again if you wish to inspect"
169 + " them. <br/><br/>This is intended to help write tests for rule-implementation"
170 + " helper functions, which may take in a <code>ctx</code> object and create actions"
171 + " on it.")
jcater3ecaa492019-12-09 16:26:00 -0800172 StarlarkValue createdActions() throws EvalException;
cparsonsabbb9002018-05-11 11:54:17 -0700173
gregce8345b792020-05-15 13:23:29 -0700174 @StarlarkMethod(name = "attr", structField = true, doc = ATTR_DOC)
jcater3ecaa492019-12-09 16:26:00 -0800175 StructApi getAttr() throws EvalException;
cparsonsabbb9002018-05-11 11:54:17 -0700176
gregce8345b792020-05-15 13:23:29 -0700177 @StarlarkMethod(name = "split_attr", structField = true, doc = SPLIT_ATTR_DOC)
jcater3ecaa492019-12-09 16:26:00 -0800178 StructApi getSplitAttr() throws EvalException;
cparsonsabbb9002018-05-11 11:54:17 -0700179
gregce8345b792020-05-15 13:23:29 -0700180 @StarlarkMethod(name = "executable", structField = true, doc = EXECUTABLE_DOC)
jcater3ecaa492019-12-09 16:26:00 -0800181 StructApi getExecutable() throws EvalException;
cparsonsabbb9002018-05-11 11:54:17 -0700182
gregce8345b792020-05-15 13:23:29 -0700183 @StarlarkMethod(name = "file", structField = true, doc = FILE_DOC)
jcater3ecaa492019-12-09 16:26:00 -0800184 StructApi getFile() throws EvalException;
cparsonsabbb9002018-05-11 11:54:17 -0700185
gregce8345b792020-05-15 13:23:29 -0700186 @StarlarkMethod(name = "files", structField = true, doc = FILES_DOC)
jcater3ecaa492019-12-09 16:26:00 -0800187 StructApi getFiles() throws EvalException;
cparsonsabbb9002018-05-11 11:54:17 -0700188
gregce8345b792020-05-15 13:23:29 -0700189 @StarlarkMethod(
jcater3ecaa492019-12-09 16:26:00 -0800190 name = "workspace_name",
191 structField = true,
192 doc = "Returns the workspace name as defined in the WORKSPACE file.")
193 String getWorkspaceName() throws EvalException;
cparsonsabbb9002018-05-11 11:54:17 -0700194
gregce8345b792020-05-15 13:23:29 -0700195 @StarlarkMethod(
jcater3ecaa492019-12-09 16:26:00 -0800196 name = "label",
197 structField = true,
198 doc = "The label of the target currently being analyzed.")
199 Label getLabel() throws EvalException;
cparsonsabbb9002018-05-11 11:54:17 -0700200
gregce8345b792020-05-15 13:23:29 -0700201 @StarlarkMethod(
jcater3ecaa492019-12-09 16:26:00 -0800202 name = "fragments",
203 structField = true,
204 doc = "Allows access to configuration fragments in target configuration.")
205 FragmentCollectionApi getFragments() throws EvalException;
cparsonsabbb9002018-05-11 11:54:17 -0700206
gregce8345b792020-05-15 13:23:29 -0700207 @StarlarkMethod(
jcater3ecaa492019-12-09 16:26:00 -0800208 name = "host_fragments",
209 structField = true,
210 doc = "Allows access to configuration fragments in host configuration.")
211 FragmentCollectionApi getHostFragments() throws EvalException;
cparsonsabbb9002018-05-11 11:54:17 -0700212
gregce8345b792020-05-15 13:23:29 -0700213 @StarlarkMethod(
jcater3ecaa492019-12-09 16:26:00 -0800214 name = "configuration",
215 structField = true,
216 doc =
217 "Returns the default configuration. See the <a href=\"configuration.html\">"
218 + "configuration</a> type for more details.")
219 BuildConfigurationApi getConfiguration() throws EvalException;
cparsonsabbb9002018-05-11 11:54:17 -0700220
gregce8345b792020-05-15 13:23:29 -0700221 @StarlarkMethod(
jcater3ecaa492019-12-09 16:26:00 -0800222 name = "host_configuration",
223 structField = true,
224 doc =
225 "Returns the host configuration. See the <a href=\"configuration.html\">"
226 + "configuration</a> type for more details.")
227 BuildConfigurationApi getHostConfiguration() throws EvalException;
cparsonsabbb9002018-05-11 11:54:17 -0700228
gregce8345b792020-05-15 13:23:29 -0700229 @StarlarkMethod(
juliexxia1f332e02018-10-31 14:20:55 -0700230 name = "build_setting_value",
231 structField = true,
juliexxia1f332e02018-10-31 14:20:55 -0700232 doc =
233 "<b>Experimental. This field is experimental and subject to change at any time. Do not "
234 + "depend on it.</b> <p>Returns the value of the build setting that is represented "
235 + "by the current target. It is an error to access this field for rules that do not "
236 + "set the <code>build_setting</code> attribute in their rule definition.")
jcater3ecaa492019-12-09 16:26:00 -0800237 Object getBuildSettingValue() throws EvalException;
juliexxia1f332e02018-10-31 14:20:55 -0700238
gregce8345b792020-05-15 13:23:29 -0700239 @StarlarkMethod(
laurentlb7dcad732018-10-25 05:17:20 -0700240 name = "coverage_instrumented",
241 doc =
242 "Returns whether code coverage instrumentation should be generated when performing "
243 + "compilation actions for this rule or, if <code>target</code> is provided, the "
244 + "rule specified by that Target. (If a non-rule or a Starlark rule Target is "
245 + "provided, this returns False.) Checks if the sources of the current rule "
246 + "(if no Target is provided) or the sources of Target should be instrumented "
247 + "based on the --instrumentation_filter and "
248 + "--instrument_test_targets config settings. "
Googlerf7dd5c22019-11-13 08:16:20 -0800249 + "This differs from <code>coverage_enabled</code> in the "
laurentlb7dcad732018-10-25 05:17:20 -0700250 + "<a href=\"configuration.html\">configuration</a>, which notes whether coverage "
251 + "data collection is enabled for the entire run, but not whether a specific "
252 + "target should be instrumented.",
253 parameters = {
254 @Param(
255 name = "target",
256 type = TransitiveInfoCollectionApi.class,
257 defaultValue = "None",
258 noneable = true,
259 named = true,
260 doc = "A Target specifying a rule. If not provided, defaults to the current rule.")
261 })
jcater3ecaa492019-12-09 16:26:00 -0800262 boolean instrumentCoverage(Object targetUnchecked) throws EvalException;
cparsonsabbb9002018-05-11 11:54:17 -0700263
gregce8345b792020-05-15 13:23:29 -0700264 @StarlarkMethod(
jcater3ecaa492019-12-09 16:26:00 -0800265 name = "features",
266 structField = true,
laurentlb186062e2020-05-14 08:36:59 -0700267 doc =
268 "Returns the set of features that are explicitly enabled by the user for this rule. "
269 + "<a href=\"https://github.com/bazelbuild/examples/blob/master/rules/"
270 + "features/rule.bzl\">See example of use</a>.")
jcater3ecaa492019-12-09 16:26:00 -0800271 ImmutableList<String> getFeatures() throws EvalException;
cparsonsabbb9002018-05-11 11:54:17 -0700272
gregce8345b792020-05-15 13:23:29 -0700273 @StarlarkMethod(
plf2ad044c2018-05-28 01:08:04 -0700274 name = "disabled_features",
275 structField = true,
276 doc = "Returns the set of features that are explicitly disabled by the user for this rule.")
277 ImmutableList<String> getDisabledFeatures() throws EvalException;
278
gregce8345b792020-05-15 13:23:29 -0700279 @StarlarkMethod(
jcater3ecaa492019-12-09 16:26:00 -0800280 name = "bin_dir",
281 structField = true,
282 doc = "The root corresponding to bin directory.")
283 FileRootApi getBinDirectory() throws EvalException;
cparsonsabbb9002018-05-11 11:54:17 -0700284
gregce8345b792020-05-15 13:23:29 -0700285 @StarlarkMethod(
jcater3ecaa492019-12-09 16:26:00 -0800286 name = "genfiles_dir",
287 structField = true,
288 doc = "The root corresponding to genfiles directory.")
289 FileRootApi getGenfilesDirectory() throws EvalException;
290
gregce8345b792020-05-15 13:23:29 -0700291 @StarlarkMethod(name = "outputs", structField = true, doc = OUTPUTS_DOC)
jcater3ecaa492019-12-09 16:26:00 -0800292 ClassObject outputs() throws EvalException;
cparsonsabbb9002018-05-11 11:54:17 -0700293
gregce8345b792020-05-15 13:23:29 -0700294 @StarlarkMethod(
jcater3ecaa492019-12-09 16:26:00 -0800295 name = "rule",
296 structField = true,
297 doc =
298 "Returns rule attributes descriptor for the rule that aspect is applied to."
299 + " Only available in aspect implementation functions.")
gregce4893ee32020-04-27 11:53:54 -0700300 StarlarkAttributesCollectionApi rule() throws EvalException;
cparsonsabbb9002018-05-11 11:54:17 -0700301
gregce8345b792020-05-15 13:23:29 -0700302 @StarlarkMethod(
jcater3ecaa492019-12-09 16:26:00 -0800303 name = "aspect_ids",
304 structField = true,
305 doc =
306 "Returns a list ids for all aspects applied to the target."
307 + " Only available in aspect implementation functions.")
308 ImmutableList<String> aspectIds() throws EvalException;
cparsonsabbb9002018-05-11 11:54:17 -0700309
gregce8345b792020-05-15 13:23:29 -0700310 @StarlarkMethod(
Googlera9c93632019-11-13 10:48:07 -0800311 name = "var",
312 structField = true,
313 doc = "Dictionary (String to String) of configuration variables.")
jcater3ecaa492019-12-09 16:26:00 -0800314 Dict<String, String> var() throws EvalException;
cparsonsabbb9002018-05-11 11:54:17 -0700315
gregce8345b792020-05-15 13:23:29 -0700316 @StarlarkMethod(
jcatereaf2b542019-12-06 09:21:31 -0800317 name = "toolchains",
318 structField = true,
juliexxia0a0a13b2020-04-21 15:55:00 -0700319 doc = "Toolchains for the default exec group of this rule.")
jcater3ecaa492019-12-09 16:26:00 -0800320 ToolchainContextApi toolchains() throws EvalException;
cparsonsabbb9002018-05-11 11:54:17 -0700321
gregce8345b792020-05-15 13:23:29 -0700322 @StarlarkMethod(
jcater0a1e9eb2019-12-17 09:58:38 -0800323 name = "target_platform_has_constraint",
324 doc = "Returns true if the given constraint value is part of the current target platform.",
325 parameters = {
326 @Param(
327 name = "constraintValue",
328 positional = true,
329 named = false,
330 type = ConstraintValueInfoApi.class,
331 doc = "The constraint value to check the target platform against.")
332 })
333 boolean targetPlatformHasConstraint(ConstraintValueT constraintValue);
334
gregce8345b792020-05-15 13:23:29 -0700335 @StarlarkMethod(
juliexxia0a0a13b2020-04-21 15:55:00 -0700336 name = "exec_groups",
337 structField = true,
338 enableOnlyWithFlag = FlagIdentifier.EXPERIMENTAL_EXEC_GROUPS,
339 // TODO(b/151742236) update this doc when this becomes non-experimental.
340 doc =
341 "<i>experimental</i> A collection of the execution groups available for this rule,"
342 + " indexed by their name. Access with <code>ctx.exec_groups[name_of_group]</code>.")
343 ExecGroupCollectionApi execGroups() throws EvalException;
344
gregce8345b792020-05-15 13:23:29 -0700345 @StarlarkMethod(
Googler42720ad2019-09-18 10:33:21 -0700346 name = "tokenize",
347 doc = "Splits a shell command into a list of tokens.",
348 // TODO(cparsons): Look into flipping this to true.
349 documented = false,
350 parameters = {
351 @Param(
352 name = "option",
353 positional = true,
354 named = false,
355 type = String.class,
356 doc = "The string to split."),
357 })
jcater3ecaa492019-12-09 16:26:00 -0800358 Sequence<String> tokenize(String optionString) throws EvalException;
cparsonsabbb9002018-05-11 11:54:17 -0700359
gregce8345b792020-05-15 13:23:29 -0700360 @StarlarkMethod(
Googler42720ad2019-09-18 10:33:21 -0700361 name = "expand",
362 doc =
363 "Expands all references to labels embedded within a string for all files using a mapping "
364 + "from definition labels (i.e. the label in the output type attribute) to files. "
365 + "Deprecated.",
366 // TODO(cparsons): Look into flipping this to true.
367 documented = false,
368 parameters = {
369 @Param(
370 name = "expression",
371 positional = true,
372 named = false,
373 type = String.class,
374 doc = "The string expression to expand."),
375 @Param(
376 name = "files",
377 positional = true,
378 named = false,
Googler4871cb02019-11-12 17:16:42 -0800379 type = Sequence.class,
Googler42720ad2019-09-18 10:33:21 -0700380 doc = "The list of files."),
381 @Param(
382 name = "label_resolver",
383 positional = true,
384 named = false,
385 type = Label.class,
386 doc = "The label resolver."),
387 })
jcater3ecaa492019-12-09 16:26:00 -0800388 String expand(
cparsons0451e582019-10-21 16:10:45 -0700389 @Nullable String expression,
Googler4871cb02019-11-12 17:16:42 -0800390 Sequence<?> artifacts, // <FileT>
cparsons0451e582019-10-21 16:10:45 -0700391 Label labelResolver)
Googler42720ad2019-09-18 10:33:21 -0700392 throws EvalException;
cparsonsabbb9002018-05-11 11:54:17 -0700393
gregce8345b792020-05-15 13:23:29 -0700394 @StarlarkMethod(
cparsons238e3442018-10-24 09:41:02 -0700395 name = "new_file",
396 doc =
397 "DEPRECATED. Use <a href=\"actions.html#declare_file\">ctx.actions.declare_file</a>. <br>"
398 + "Creates a file object. There are four possible signatures to this method:<br><ul>"
399 + ""
400 + "<li>new_file(filename): Creates a file object with the given filename in the "
401 + "current package.</li>"
402 + ""
403 + "<li>new_file(file_root, filename): Creates a file object with the given "
404 + "filename under the given file root.</li>"
405 + ""
406 + "<li>new_file(sibling_file, filename): Creates a file object in the same "
407 + "directory as the given sibling file.</li>"
408 + ""
409 + "<li>new_file(file_root, sibling_file, suffix): Creates a file object with same "
410 + "base name of the sibling_file but with different given suffix, under the given "
411 + "file root.</li></ul> <br>"
412 + DOC_NEW_FILE_TAIL,
413 parameters = {
jcater3ecaa492019-12-09 16:26:00 -0800414 @Param(
415 name = "var1",
416 allowedTypes = {
417 @ParamType(type = String.class),
418 @ParamType(type = FileRootApi.class),
419 @ParamType(type = FileApi.class),
420 },
421 doc = ""),
422 @Param(
423 name = "var2",
424 allowedTypes = {
425 @ParamType(type = String.class),
426 @ParamType(type = FileApi.class),
427 },
428 defaultValue = "unbound",
429 doc = ""),
430 @Param(
431 name = "var3",
432 allowedTypes = {
433 @ParamType(type = String.class),
434 },
435 defaultValue = "unbound",
436 doc = "")
adonovan7891d3b2020-01-22 12:40:50 -0800437 })
438 FileApi newFile(Object var1, Object var2, Object var3) throws EvalException;
cparsonsabbb9002018-05-11 11:54:17 -0700439
gregce8345b792020-05-15 13:23:29 -0700440 @StarlarkMethod(
cparsons0451e582019-10-21 16:10:45 -0700441 name = "check_placeholders",
442 documented = false,
443 parameters = {
444 @Param(
445 name = "template",
446 positional = true,
447 named = false,
448 type = String.class,
449 doc = "The template."),
450 @Param(
451 name = "allowed_placeholders",
452 positional = true,
453 named = false,
Googler4871cb02019-11-12 17:16:42 -0800454 type = Sequence.class,
cparsons0451e582019-10-21 16:10:45 -0700455 doc = "The allowed placeholders."),
456 })
jcater3ecaa492019-12-09 16:26:00 -0800457 boolean checkPlaceholders(String template, Sequence<?> allowedPlaceholders) // <String>
cparsonsabbb9002018-05-11 11:54:17 -0700458 throws EvalException;
459
gregce8345b792020-05-15 13:23:29 -0700460 @StarlarkMethod(
cparsons88d1cae2018-06-22 15:12:00 -0700461 name = "expand_make_variables",
Sam Rawlins71d0f6c2018-06-07 07:25:49 -0700462 doc =
463 "<b>Deprecated.</b> Use <a href=\"ctx.html#var\">ctx.var</a> to access the variables "
464 + "instead.<br>Returns a string after expanding all references to \"Make "
465 + "variables\". The "
466 + "variables must have the following format: <code>$(VAR_NAME)</code>. Also, "
Googler8c1b44f2018-08-28 07:51:45 -0700467 + "<code>$$VAR_NAME</code> expands to <code>$VAR_NAME</code>. "
Sam Rawlins71d0f6c2018-06-07 07:25:49 -0700468 + "Examples:"
469 + "<pre class=language-python>\n"
470 + "ctx.expand_make_variables(\"cmd\", \"$(MY_VAR)\", {\"MY_VAR\": \"Hi\"}) "
471 + "# == \"Hi\"\n"
472 + "ctx.expand_make_variables(\"cmd\", \"$$PWD\", {}) # == \"$PWD\"\n"
473 + "</pre>"
474 + "Additional variables may come from other places, such as configurations. Note "
cparsons73a7c902018-06-25 10:09:55 -0700475 + "that this function is experimental.",
476 parameters = {
477 @Param(
478 name = "attribute_name",
479 positional = true,
480 named = false,
481 type = String.class,
cparsons0451e582019-10-21 16:10:45 -0700482 doc = "The attribute name. Used for error reporting."),
cparsons73a7c902018-06-25 10:09:55 -0700483 @Param(
484 name = "command",
485 positional = true,
486 named = false,
487 type = String.class,
cparsons0451e582019-10-21 16:10:45 -0700488 doc =
489 "The expression to expand. It can contain references to " + "\"Make variables\"."),
cparsons73a7c902018-06-25 10:09:55 -0700490 @Param(
491 name = "additional_substitutions",
492 positional = true,
493 named = false,
Googlera9c93632019-11-13 10:48:07 -0800494 type = Dict.class,
cparsons0451e582019-10-21 16:10:45 -0700495 doc = "Additional substitutions to make beyond the default make variables."),
496 })
jcater3ecaa492019-12-09 16:26:00 -0800497 String expandMakeVariables(
cparsons0451e582019-10-21 16:10:45 -0700498 String attributeName,
499 String command,
Googlera9c93632019-11-13 10:48:07 -0800500 final Dict<?, ?> additionalSubstitutions) // <String, String>
cparsonsabbb9002018-05-11 11:54:17 -0700501 throws EvalException;
502
gregce8345b792020-05-15 13:23:29 -0700503 @StarlarkMethod(
jcater3ecaa492019-12-09 16:26:00 -0800504 name = "info_file",
505 structField = true,
506 documented = false,
507 doc =
508 "Returns the file that is used to hold the non-volatile workspace status for the "
509 + "current build request.")
510 FileApi getStableWorkspaceStatus() throws InterruptedException, EvalException;
cparsonsabbb9002018-05-11 11:54:17 -0700511
gregce8345b792020-05-15 13:23:29 -0700512 @StarlarkMethod(
jcater3ecaa492019-12-09 16:26:00 -0800513 name = "version_file",
514 structField = true,
515 documented = false,
516 doc =
517 "Returns the file that is used to hold the volatile workspace status for the "
518 + "current build request.")
519 FileApi getVolatileWorkspaceStatus() throws InterruptedException, EvalException;
cparsonsabbb9002018-05-11 11:54:17 -0700520
gregce8345b792020-05-15 13:23:29 -0700521 @StarlarkMethod(
jcater3ecaa492019-12-09 16:26:00 -0800522 name = "build_file_path",
523 structField = true,
524 documented = true,
525 doc = "Returns path to the BUILD file for this rule, relative to the source root.")
526 String getBuildFileRelativePath() throws EvalException;
cparsonsabbb9002018-05-11 11:54:17 -0700527
gregce8345b792020-05-15 13:23:29 -0700528 @StarlarkMethod(
Sam Rawlins71d0f6c2018-06-07 07:25:49 -0700529 name = "action",
530 doc =
531 "DEPRECATED. Use <a href=\"actions.html#run\">ctx.actions.run()</a> or"
532 + " <a href=\"actions.html#run_shell\">ctx.actions.run_shell()</a>. <br>"
533 + "Creates an action that runs an executable or a shell command."
534 + " You must specify either <code>command</code> or <code>executable</code>.\n"
535 + "Actions and genrules are very similar, but have different use cases. Actions are "
536 + "used inside rules, and genrules are used inside macros. Genrules also have make "
537 + "variable expansion.",
538 parameters = {
539 @Param(
540 name = "outputs",
Googler4871cb02019-11-12 17:16:42 -0800541 type = Sequence.class,
Sam Rawlins71d0f6c2018-06-07 07:25:49 -0700542 generic1 = FileApi.class,
543 named = true,
544 positional = false,
545 doc = "List of the output files of the action."),
546 @Param(
547 name = "inputs",
548 allowedTypes = {
Googler4871cb02019-11-12 17:16:42 -0800549 @ParamType(type = Sequence.class),
Googlerd21a0d12019-11-21 13:52:30 -0800550 @ParamType(type = Depset.class),
Sam Rawlins71d0f6c2018-06-07 07:25:49 -0700551 },
552 generic1 = FileApi.class,
553 defaultValue = "[]",
554 named = true,
555 positional = false,
556 doc = "List of the input files of the action."),
557 @Param(
558 name = "executable",
559 type = Object.class,
560 allowedTypes = {
561 @ParamType(type = FileApi.class),
562 @ParamType(type = String.class),
Googler641bdf72019-11-12 10:32:26 -0800563 @ParamType(type = NoneType.class),
Sam Rawlins71d0f6c2018-06-07 07:25:49 -0700564 },
565 noneable = true,
566 defaultValue = "None",
567 named = true,
568 positional = false,
569 doc = "The executable file to be called by the action."),
570 @Param(
571 name = "tools",
572 allowedTypes = {
Googler4871cb02019-11-12 17:16:42 -0800573 @ParamType(type = Sequence.class),
Googlerd21a0d12019-11-21 13:52:30 -0800574 @ParamType(type = Depset.class),
Sam Rawlins71d0f6c2018-06-07 07:25:49 -0700575 },
576 generic1 = FileApi.class,
577 defaultValue = "unbound",
578 named = true,
579 positional = false,
580 doc =
581 "List of the any tools needed by the action. Tools are inputs with additional "
582 + "runfiles that are automatically made available to the action."),
583 @Param(
584 name = "arguments",
585 allowedTypes = {
Googler4871cb02019-11-12 17:16:42 -0800586 @ParamType(type = Sequence.class),
Sam Rawlins71d0f6c2018-06-07 07:25:49 -0700587 },
588 defaultValue = "[]",
589 named = true,
590 positional = false,
591 doc =
592 "Command line arguments of the action. Must be a list of strings or actions.args() "
593 + "objects."),
594 @Param(
595 name = "mnemonic",
596 type = String.class,
597 noneable = true,
598 defaultValue = "None",
599 named = true,
600 positional = false,
601 doc = "A one-word description of the action, e.g. CppCompile or GoLink."),
602 @Param(
603 name = "command",
604 type = Object.class,
605 allowedTypes = {
606 @ParamType(type = String.class),
Googler4871cb02019-11-12 17:16:42 -0800607 @ParamType(type = Sequence.class, generic1 = String.class),
Googler641bdf72019-11-12 10:32:26 -0800608 @ParamType(type = NoneType.class),
Sam Rawlins71d0f6c2018-06-07 07:25:49 -0700609 },
610 noneable = true,
611 defaultValue = "None",
612 named = true,
613 positional = false,
614 doc =
615 "Shell command to execute. It is usually preferable to "
616 + "use <code>executable</code> instead. "
617 + "Arguments are available with <code>$1</code>, <code>$2</code>, etc."),
618 @Param(
619 name = "progress_message",
620 type = String.class,
621 noneable = true,
622 defaultValue = "None",
623 named = true,
624 positional = false,
625 doc =
626 "Progress message to show to the user during the build, "
627 + "e.g. \"Compiling foo.cc to create foo.o\"."),
628 @Param(
629 name = "use_default_shell_env",
630 type = Boolean.class,
631 defaultValue = "False",
632 named = true,
633 positional = false,
634 doc = "Whether the action should use the built in shell environment or not."),
635 @Param(
636 name = "env",
Googlera9c93632019-11-13 10:48:07 -0800637 type = Dict.class,
Sam Rawlins71d0f6c2018-06-07 07:25:49 -0700638 noneable = true,
639 defaultValue = "None",
640 named = true,
641 positional = false,
642 doc = "Sets the dictionary of environment variables."),
643 @Param(
644 name = "execution_requirements",
Googlera9c93632019-11-13 10:48:07 -0800645 type = Dict.class,
Sam Rawlins71d0f6c2018-06-07 07:25:49 -0700646 noneable = true,
647 defaultValue = "None",
648 named = true,
649 positional = false,
650 doc =
651 "Information for scheduling the action. See "
652 + "<a href=\"$BE_ROOT/common-definitions.html#common.tags\">tags</a> "
653 + "for useful keys."),
654 @Param(
655 // TODO(bazel-team): The name here isn't accurate anymore. This is technically
656 // experimental,
657 // so folks shouldn't be too attached, but consider renaming to be more accurate/opaque.
658 name = "input_manifests",
Googler4871cb02019-11-12 17:16:42 -0800659 type = Sequence.class,
Sam Rawlins71d0f6c2018-06-07 07:25:49 -0700660 noneable = true,
661 defaultValue = "None",
662 named = true,
663 positional = false,
664 doc =
665 "(Experimental) sets the input runfiles metadata; "
666 + "they are typically generated by resolve_command.")
667 },
668 allowReturnNones = true,
Googlera3421e22019-09-26 06:48:32 -0700669 useStarlarkThread = true)
jcater3ecaa492019-12-09 16:26:00 -0800670 NoneType action(
Googler4871cb02019-11-12 17:16:42 -0800671 Sequence<?> outputs,
cparsonsabbb9002018-05-11 11:54:17 -0700672 Object inputs,
673 Object executableUnchecked,
674 Object toolsUnchecked,
675 Object arguments,
676 Object mnemonicUnchecked,
677 Object commandUnchecked,
678 Object progressMessage,
679 Boolean useDefaultShellEnv,
680 Object envUnchecked,
681 Object executionRequirementsUnchecked,
682 Object inputManifestsUnchecked,
Googlera3421e22019-09-26 06:48:32 -0700683 StarlarkThread thread)
cparsonsabbb9002018-05-11 11:54:17 -0700684 throws EvalException;
685
gregce8345b792020-05-15 13:23:29 -0700686 @StarlarkMethod(
Googlera3421e22019-09-26 06:48:32 -0700687 name = "expand_location",
688 doc =
689 "Expands all <code>$(location ...)</code> templates in the given string by replacing "
690 + "<code>$(location //x)</code> with the path of the output file of target //x. "
691 + "Expansion only works for labels that point to direct dependencies of this rule or "
692 + "that are explicitly listed in the optional argument <code>targets</code>. "
693 + "<br/><br/>"
694 //
695 + "<code>$(location ...)</code> will cause an error if the referenced target has "
696 + "multiple outputs. In this case, please use <code>$(locations ...)</code> since it "
697 + "produces a space-separated list of output paths. It can be safely used for a "
698 + "single output file, too."
699 + "<br/><br/>"
700 //
701 + "This function is useful to let the user specify a command in a BUILD file (like"
702 + " for <code>genrule</code>). In other cases, it is often better to manipulate"
703 + " labels directly.",
704 parameters = {
705 @Param(name = "input", type = String.class, doc = "String to be expanded."),
706 @Param(
707 name = "targets",
Googler4871cb02019-11-12 17:16:42 -0800708 type = Sequence.class,
Googlera3421e22019-09-26 06:48:32 -0700709 generic1 = TransitiveInfoCollectionApi.class,
710 defaultValue = "[]",
711 named = true,
712 doc = "List of targets for additional lookup information."),
713 },
714 allowReturnNones = true,
Googlera3421e22019-09-26 06:48:32 -0700715 useStarlarkThread = true)
adonovan7891d3b2020-01-22 12:40:50 -0800716 String expandLocation(String input, Sequence<?> targets, StarlarkThread thread)
jcater3ecaa492019-12-09 16:26:00 -0800717 throws EvalException;
cparsonsabbb9002018-05-11 11:54:17 -0700718
gregce8345b792020-05-15 13:23:29 -0700719 @StarlarkMethod(
Googlera3421e22019-09-26 06:48:32 -0700720 name = "file_action",
721 doc =
722 "DEPRECATED. Use <a href =\"actions.html#write\">ctx.actions.write</a> instead. <br>"
723 + "Creates a file write action.",
724 parameters = {
725 @Param(name = "output", type = FileApi.class, named = true, doc = "The output file."),
726 @Param(
727 name = "content",
728 type = String.class,
729 named = true,
730 doc = "The contents of the file."),
731 @Param(
732 name = "executable",
733 type = Boolean.class,
734 defaultValue = "False",
735 named = true,
736 doc = "Whether the output file should be executable (default is False).")
737 },
738 allowReturnNones = true,
Googlera3421e22019-09-26 06:48:32 -0700739 useStarlarkThread = true)
adonovan7891d3b2020-01-22 12:40:50 -0800740 NoneType fileAction(FileApi output, String content, Boolean executable, StarlarkThread thread)
cparsonsabbb9002018-05-11 11:54:17 -0700741 throws EvalException;
742
gregce8345b792020-05-15 13:23:29 -0700743 @StarlarkMethod(
Sam Rawlins71d0f6c2018-06-07 07:25:49 -0700744 name = "runfiles",
745 doc = "Creates a runfiles object.",
746 parameters = {
747 @Param(
748 name = "files",
Googler4871cb02019-11-12 17:16:42 -0800749 type = Sequence.class,
Sam Rawlins71d0f6c2018-06-07 07:25:49 -0700750 generic1 = FileApi.class,
751 named = true,
752 defaultValue = "[]",
753 doc = "The list of files to be added to the runfiles."),
754 // TODO(bazel-team): If we have a memory efficient support for lazy list containing
755 // NestedSets we can remove this and just use files = [file] + list(set)
756 // Also, allow empty set for init
757 @Param(
758 name = "transitive_files",
Googlerd21a0d12019-11-21 13:52:30 -0800759 type = Depset.class,
Sam Rawlins71d0f6c2018-06-07 07:25:49 -0700760 generic1 = FileApi.class,
761 noneable = true,
762 defaultValue = "None",
763 named = true,
764 doc =
765 "The (transitive) set of files to be added to the runfiles. The depset should "
766 + "use the <code>default</code> order (which, as the name implies, is the "
767 + "default)."),
768 @Param(
769 name = "collect_data",
770 type = Boolean.class,
771 defaultValue = "False",
772 named = true,
773 doc =
cparsons354a6fe2019-11-12 13:41:06 -0800774 "<b>Use of this parameter is not recommended. See "
775 + "<a href=\"../rules.html#runfiles\">runfiles guide</a></b>. "
776 + "<p>Whether to collect the data "
Sam Rawlins71d0f6c2018-06-07 07:25:49 -0700777 + "runfiles from the dependencies in srcs, data and deps attributes."),
778 @Param(
779 name = "collect_default",
780 type = Boolean.class,
781 defaultValue = "False",
782 named = true,
783 doc =
cparsons354a6fe2019-11-12 13:41:06 -0800784 "<b>Use of this parameter is not recommended. See "
785 + "<a href=\"../rules.html#runfiles\">runfiles guide</a></b>. "
786 + "<p>Whether to collect the default "
Sam Rawlins71d0f6c2018-06-07 07:25:49 -0700787 + "runfiles from the dependencies in srcs, data and deps attributes."),
788 @Param(
789 name = "symlinks",
Googlera9c93632019-11-13 10:48:07 -0800790 type = Dict.class,
Sam Rawlins71d0f6c2018-06-07 07:25:49 -0700791 defaultValue = "{}",
792 named = true,
793 doc = "The map of symlinks to be added to the runfiles, prefixed by workspace name."),
794 @Param(
795 name = "root_symlinks",
Googlera9c93632019-11-13 10:48:07 -0800796 type = Dict.class,
Sam Rawlins71d0f6c2018-06-07 07:25:49 -0700797 defaultValue = "{}",
798 named = true,
799 doc = "The map of symlinks to be added to the runfiles.")
adonovan7891d3b2020-01-22 12:40:50 -0800800 })
jcater3ecaa492019-12-09 16:26:00 -0800801 RunfilesApi runfiles(
Googler4871cb02019-11-12 17:16:42 -0800802 Sequence<?> files,
cparsonsabbb9002018-05-11 11:54:17 -0700803 Object transitiveFiles,
804 Boolean collectData,
805 Boolean collectDefault,
Googlera9c93632019-11-13 10:48:07 -0800806 Dict<?, ?> symlinks,
adonovan7891d3b2020-01-22 12:40:50 -0800807 Dict<?, ?> rootSymlinks)
cparsonsabbb9002018-05-11 11:54:17 -0700808 throws EvalException;
809
gregce8345b792020-05-15 13:23:29 -0700810 @StarlarkMethod(
laszlocsomoree197c62019-05-08 23:48:33 -0700811 name = "resolve_command",
812 // TODO(bazel-team): The naming here isn't entirely accurate (input_manifests is no longer
813 // manifests), but this is experimental/should be opaque to the end user.
814 doc =
815 "<i>(Experimental)</i> Returns a tuple <code>(inputs, command, input_manifests)</code>"
816 + " of the list of resolved inputs, the argv list for the resolved command, and the"
817 + " runfiles metadata required to run the command, all of them suitable for passing"
818 + " as the same-named arguments of the <code>ctx.action</code> method.<br/><b>Note"
819 + " for Windows users</b>: this method requires Bash (MSYS2). Consider using"
820 + " <code>resolve_tools()</code> instead (if that fits your needs).",
821 parameters = {
822 @Param(
823 name = "command",
824 type = String.class, // string
825 defaultValue = "''",
826 named = true,
827 positional = false,
828 doc = "Command to resolve."),
829 @Param(
830 name = "attribute",
831 type = String.class, // string
832 defaultValue = "None",
833 noneable = true,
834 named = true,
835 positional = false,
836 doc = "Name of the associated attribute for which to issue an error, or None."),
837 @Param(
838 name = "expand_locations",
839 type = Boolean.class,
840 defaultValue = "False",
841 named = true,
842 positional = false,
843 doc =
844 "Shall we expand $(location) variables? See <a"
845 + " href=\"#expand_location\">ctx.expand_location()</a> for more details."),
846 @Param(
847 name = "make_variables",
Googlera9c93632019-11-13 10:48:07 -0800848 type = Dict.class, // dict(string, string)
laszlocsomoree197c62019-05-08 23:48:33 -0700849 noneable = true,
850 defaultValue = "None",
851 named = true,
852 positional = false,
853 doc = "Make variables to expand, or None."),
854 @Param(
855 name = "tools",
856 defaultValue = "[]",
Googler4871cb02019-11-12 17:16:42 -0800857 type = Sequence.class,
laszlocsomoree197c62019-05-08 23:48:33 -0700858 generic1 = TransitiveInfoCollectionApi.class,
859 named = true,
860 positional = false,
861 doc = "List of tools (list of targets)."),
862 @Param(
863 name = "label_dict",
Googlera9c93632019-11-13 10:48:07 -0800864 type = Dict.class,
laszlocsomoree197c62019-05-08 23:48:33 -0700865 defaultValue = "{}",
866 named = true,
867 positional = false,
868 doc =
869 "Dictionary of resolved labels and the corresponding list of Files "
870 + "(a dict of Label : list of Files)."),
871 @Param(
872 name = "execution_requirements",
Googlera9c93632019-11-13 10:48:07 -0800873 type = Dict.class,
laszlocsomoree197c62019-05-08 23:48:33 -0700874 defaultValue = "{}",
875 named = true,
876 positional = false,
877 doc =
878 "Information for scheduling the action to resolve this command. See "
879 + "<a href=\"$BE_ROOT/common-definitions.html#common.tags\">tags</a> "
880 + "for useful keys."),
881 },
Googlera3421e22019-09-26 06:48:32 -0700882 useStarlarkThread = true)
jcater3ecaa492019-12-09 16:26:00 -0800883 Tuple<Object> resolveCommand(
cparsonsabbb9002018-05-11 11:54:17 -0700884 String command,
885 Object attributeUnchecked,
886 Boolean expandLocations,
887 Object makeVariablesUnchecked,
Googler4871cb02019-11-12 17:16:42 -0800888 Sequence<?> tools,
Googlera9c93632019-11-13 10:48:07 -0800889 Dict<?, ?> labelDictUnchecked,
890 Dict<?, ?> executionRequirementsUnchecked,
Googlera3421e22019-09-26 06:48:32 -0700891 StarlarkThread thread)
cparsonsabbb9002018-05-11 11:54:17 -0700892 throws EvalException;
Laszlo Csomor52446a12019-01-24 07:40:50 -0800893
gregce8345b792020-05-15 13:23:29 -0700894 @StarlarkMethod(
Laszlo Csomor52446a12019-01-24 07:40:50 -0800895 name = "resolve_tools",
896 doc =
897 "Returns a tuple <code>(inputs, input_manifests)</code> of the depset of resolved inputs"
898 + " and the runfiles metadata required to run the tools, both of them suitable for"
899 + " passing as the same-named arguments of the <code>ctx.actions.run</code> method."
900 + "<br/><br/>In contrast to <code>ctx.resolve_command</code>, this method does not"
901 + " require that Bash be installed on the machine, so it's suitable for rules built"
902 + " on Windows.",
903 parameters = {
904 @Param(
905 name = "tools",
906 defaultValue = "[]",
Googler4871cb02019-11-12 17:16:42 -0800907 type = Sequence.class,
Laszlo Csomor52446a12019-01-24 07:40:50 -0800908 generic1 = TransitiveInfoCollectionApi.class,
909 named = true,
910 positional = false,
911 doc = "List of tools (list of targets)."),
adonovan7891d3b2020-01-22 12:40:50 -0800912 })
jcater3ecaa492019-12-09 16:26:00 -0800913 Tuple<Object> resolveTools(Sequence<?> tools) throws EvalException;
cparsonsabbb9002018-05-11 11:54:17 -0700914}