docs/versions/6.1.0/rules/lib/ctx.mdx
A context object that is passed to the implementation function for a rule or aspect. It provides access to the information and methods needed to analyze the current target.<p>In particular, it lets the implementation function access the current target's label, attributes, configuration, and the providers of its dependencies. It has methods for declaring output files and the actions that produce them.<p>Context objects essentially live for the duration of the call to the implementation function. It is not useful to access these objects outside of their associated function. See the <a href='https://bazel.build/versions/6.1.0/rules/rules#implementation_function'>Rules page</a> for more information.
<h2>Members</h2> <ul> <li> <a href="#actions">actions</a> </li> <li> <a href="#aspect_ids">aspect_ids</a> </li> <li> <a href="#attr">attr</a> </li> <li> <a href="#bin_dir">bin_dir</a> </li> <li> <a href="#build_file_path">build_file_path</a> </li> <li> <a href="#build_setting_value">build_setting_value</a> </li> <li> <a href="#configuration">configuration</a> </li> <li> <a href="#coverage_instrumented">coverage_instrumented</a> </li> <li> <a href="#created_actions">created_actions</a> </li> <li> <a href="#default_provider">default_provider</a> </li> <li> <a href="#disabled_features">disabled_features</a> </li> <li> <a href="#exec_groups">exec_groups</a> </li> <li> <a href="#executable">executable</a> </li> <li> <a href="#expand_location">expand_location</a> </li> <li> <a href="#expand_make_variables">expand_make_variables</a> </li> <li> <a href="#features">features</a> </li> <li> <a href="#file">file</a> </li> <li> <a href="#files">files</a> </li> <li> <a href="#fragments">fragments</a> </li> <li> <a href="#genfiles_dir">genfiles_dir</a> </li> <li> <a href="#host_configuration">host_configuration</a> </li> <li> <a href="#host_fragments">host_fragments</a> </li> <li> <a href="#info_file">info_file</a> </li> <li> <a href="#label">label</a> </li> <li> <a href="#new_file">new_file</a> </li> <li> <a href="#outputs">outputs</a> </li> <li> <a href="#resolve_command">resolve_command</a> </li> <li> <a href="#resolve_tools">resolve_tools</a> </li> <li> <a href="#rule">rule</a> </li> <li> <a href="#runfiles">runfiles</a> </li> <li> <a href="#split_attr">split_attr</a> </li> <li> <a href="#target_platform_has_constraint">target_platform_has_constraint</a> </li> <li> <a href="#toolchains">toolchains</a> </li> <li> <a href="#var">var</a> </li> <li> <a href="#version_file">version_file</a> </li> <li> <a href="#workspace_name">workspace_name</a> </li> </ul> <h2 id="actions">actions</h2>
<p><pre class="rule-signature"><a class="anchor" href="actions.html">actions</a> ctx.actions</pre></p>
Contains methods for declaring output files and the actions that produce them.
<h2 id="aspect_ids">aspect_ids</h2>
<p><pre class="rule-signature"><a class="anchor" href="list.html">list</a> ctx.aspect_ids</pre></p>
A list of ids for all aspects applied to the target. Only available in aspect implementation functions.
<h2 id="attr">attr</h2>
<p><pre class="rule-signature"><a class="anchor" href="struct.html">struct</a> ctx.attr</pre></p>
A struct to access the values of the <a href='https://bazel.build/versions/6.1.0/rules/rules#attributes'>attributes</a>. The values are provided by the user (if not, a default value is used). The attributes of the struct and the types of their values correspond to the keys and values of the <a href='globals.html#rule.attrs'><code>attrs</code> dict</a> provided to the <a href='globals.html#rule'><code>rule</code> function</a>. <a href="https://github.com/bazelbuild/examples/blob/main/rules/attributes/printer.bzl">See example of use</a>.
<h2 id="bin_dir">bin_dir</h2>
<p><pre class="rule-signature"><a class="anchor" href="root.html">root</a> ctx.bin_dir</pre></p>
The root corresponding to bin directory.
<h2 id="build_file_path">build_file_path</h2>
<p><pre class="rule-signature"><a class="anchor" href="string.html">string</a> ctx.build_file_path</pre></p>
The path to the BUILD file for this rule, relative to the source root.
<h2 id="build_setting_value">build_setting_value</h2>
<p><pre class="rule-signature">unknown ctx.build_setting_value</pre></p>
<b>Experimental. This field is experimental and subject to change at any time. Do not depend on it.</b> <p>The value of the build setting that is represented by the current target. It is an error to access this field for rules that do not set the <code>build_setting</code> attribute in their rule definition.
<h2 id="configuration">configuration</h2>
<p><pre class="rule-signature"><a class="anchor" href="configuration.html">configuration</a> ctx.configuration</pre></p>
The default configuration. See the <a href="configuration.html">configuration</a> type for more details.
<h2 id="coverage_instrumented">coverage_instrumented</h2>
<p><pre class="rule-signature"><a class="anchor" href="bool.html">bool</a> ctx.coverage_instrumented(target=None)</pre></p>
Returns whether code coverage instrumentation should be generated when performing compilation actions for this rule or, if <code>target</code> is provided, the rule specified by that Target. (If a non-rule or a Starlark rule Target is provided, this returns False.) Checks if the sources of the current rule (if no Target is provided) or the sources of Target should be instrumented based on the --instrumentation_filter and --instrument_test_targets config settings. This differs from <code>coverage_enabled</code> in the <a href="configuration.html">configuration</a>, which notes whether coverage data collection is enabled for the entire run, but not whether a specific target should be instrumented.
<!-- hide-from-toc is a class used by DevSite for the public Bazel site
(https://developers.google.com/devsite/reference/styles/headings#hide_headings_from_the_toc) -->
<h3 class="hide-from-toc">Parameters</h3>
<table class="table table-bordered table-condensed table-params">
<colgroup>
<col class="col-param">
<col class="param-description">
</colgroup>
<thead>
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td id="coverage_instrumented.target">
<code>target</code>
</td>
<td>
<code><a class="anchor" href="Target.html">Target</a>; or <a class="anchor" href="globals.html#None">None</a></code>;
default = None
A Target specifying a rule. If not provided, defaults to the current rule.
</td>
</tr>
</tbody>
</table>
<h2 id="created_actions">created_actions</h2>
<p><pre class="rule-signature">StarlarkValue ctx.created_actions()</pre></p>
For rules with <a href="globals.html#rule._skylark_testable">_skylark_testable</a> set to <code>True</code>, this returns an <a href="globals.html#Actions">Actions</a> provider representing all actions created so far for the current rule. For all other rules, returns <code>None</code>. Note that the provider is not updated when subsequent actions are created, so you will have to call this function again if you wish to inspect them.
This is intended to help write tests for rule-implementation helper functions, which may take in a <code>ctx</code> object and create actions on it.
<h2 id="default_provider">default_provider</h2>
<p><pre class="rule-signature"><a class="anchor" href="Provider.html">Provider</a> ctx.default_provider</pre></p>
Deprecated. Use <a href="DefaultInfo.html">DefaultInfo</a> instead.
<h2 id="disabled_features">disabled_features</h2>
<p><pre class="rule-signature"><a class="anchor" href="list.html">list</a> ctx.disabled_features</pre></p>
The set of features that are explicitly disabled by the user for this rule.
<h2 id="exec_groups">exec_groups</h2>
<p><pre class="rule-signature"><a class="anchor" href="ExecGroupCollection.html">ExecGroupCollection</a> ctx.exec_groups</pre></p>
A collection of the execution groups available for this rule, indexed by their name. Access with <code>ctx.exec_groups[name_of_group]</code>.
<h2 id="executable">executable</h2>
<p><pre class="rule-signature"><a class="anchor" href="struct.html">struct</a> ctx.executable</pre></p>
A <code>struct</code> containing executable files defined in <a href='attr.html#label'>label type attributes</a> marked as <a href='attr.html#label.executable'><code>executable=True</code><a>. The struct fields correspond to the attribute names. Each value in the struct is either a <a href='File.html'><code>File</code></a> or <code>None</code>. If an optional attribute is not specified in the rule then the corresponding struct value is <code>None</code>. If a label type is not marked as <code>executable=True</code>, no corresponding struct field is generated. <a href="https://github.com/bazelbuild/examples/blob/main/rules/actions_run/execute.bzl">See example of use</a>.
<h2 id="expand_location">expand_location</h2>
<p><pre class="rule-signature"><a class="anchor" href="string.html">string</a> ctx.expand_location(input, targets=[], short_paths=False)</pre></p>
Expands all <code>$(location ...)</code> templates in the given string by replacing <code>$(location //x)</code> with the path of the output file of target //x. Expansion only works for labels that point to direct dependencies of this rule or that are explicitly listed in the optional argument <code>targets</code>.
<code>$(location ...)</code> will cause an error if the referenced target has multiple outputs. In this case, please use <code>$(locations ...)</code> since it produces a space-separated list of output paths. It can be safely used for a single output file, too.
This function is useful to let the user specify a command in a BUILD file (like for <code>genrule</code>). In other cases, it is often better to manipulate labels directly.
<!-- hide-from-toc is a class used by DevSite for the public Bazel site
(https://developers.google.com/devsite/reference/styles/headings#hide_headings_from_the_toc) -->
<h3 class="hide-from-toc">Parameters</h3>
<table class="table table-bordered table-condensed table-params">
<colgroup>
<col class="col-param">
<col class="param-description">
</colgroup>
<thead>
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td id="expand_location.input">
<code>input</code>
</td>
<td>
required
String to be expanded.
</td>
</tr>
<tr>
<td id="expand_location.targets">
<code>targets</code>
</td>
<td>
<code><a class="anchor" href="list.html">sequence</a> of <a class="anchor" href="Target.html">Target</a>s</code>;
default = []
List of targets for additional lookup information.
</td>
</tr>
<tr>
<td id="expand_location.short_paths">
<code>short_paths</code>
</td>
<td>
default = False
Use root relative paths instead of full exec paths
</td>
</tr>
</tbody>
</table>
May return <code>None</code>.
<h2 id="expand_make_variables">expand_make_variables</h2>
<p><pre class="rule-signature"><a class="anchor" href="string.html">string</a> ctx.expand_make_variables(attribute_name, command, additional_substitutions)</pre></p>
<b>Deprecated.</b> Use <a href="ctx.html#var">ctx.var</a> to access the variables instead.
Returns a string after expanding all references to "Make variables". The variables must have the following format: <code>$(VAR_NAME)</code>. Also, <code>$$VAR_NAME</code> expands to <code>$VAR_NAME</code>. Examples:<pre class=language-python> ctx.expand_make_variables("cmd", "$(MY_VAR)", {"MY_VAR": "Hi"}) # == "Hi" ctx.expand_make_variables("cmd", "$$PWD", {}) # == "$PWD" </pre>Additional variables may come from other places, such as configurations. Note that this function is experimental.
<!-- hide-from-toc is a class used by DevSite for the public Bazel site
(https://developers.google.com/devsite/reference/styles/headings#hide_headings_from_the_toc) -->
<h3 class="hide-from-toc">Parameters</h3>
<table class="table table-bordered table-condensed table-params">
<colgroup>
<col class="col-param">
<col class="param-description">
</colgroup>
<thead>
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td id="expand_make_variables.attribute_name">
<code>attribute_name</code>
</td>
<td>
required
The attribute name. Used for error reporting.
</td>
</tr>
<tr>
<td id="expand_make_variables.command">
<code>command</code>
</td>
<td>
required
The expression to expand. It can contain references to "Make variables".
</td>
</tr>
<tr>
<td id="expand_make_variables.additional_substitutions">
<code>additional_substitutions</code>
</td>
<td>
required
Additional substitutions to make beyond the default make variables.
</td>
</tr>
</tbody>
</table>
<h2 id="features">features</h2>
<p><pre class="rule-signature"><a class="anchor" href="list.html">list</a> ctx.features</pre></p>
The set of features that are explicitly enabled by the user for this rule. <a href="https://github.com/bazelbuild/examples/blob/main/rules/features/rule.bzl">See example of use</a>.
<h2 id="file">file</h2>
<p><pre class="rule-signature"><a class="anchor" href="struct.html">struct</a> ctx.file</pre></p>
A <code>struct</code> containing files defined in <a href='attr.html#label'>label type attributes</a> marked as <a href='attr.html#label.allow_single_file'><code>allow_single_file</code></a>. The struct fields correspond to the attribute names. The struct value is always a <a href='File.html'><code>File</code></a> or <code>None</code>. If an optional attribute is not specified in the rule then the corresponding struct value is <code>None</code>. If a label type is not marked as <code>allow_single_file</code>, no corresponding struct field is generated. It is a shortcut for:<pre class=language-python>list(ctx.attr.<ATTR>.files)[0]</pre>In other words, use <code>file</code> to access the (singular) <a href="https://bazel.build/versions/6.1.0/rules/rules#requesting_output_files">default output</a> of a dependency. <a href="https://github.com/bazelbuild/examples/blob/main/rules/expand_template/hello.bzl">See example of use</a>.
<h2 id="files">files</h2>
<p><pre class="rule-signature"><a class="anchor" href="struct.html">struct</a> ctx.files</pre></p>
A <code>struct</code> containing files defined in <a href='attr.html#label'>label</a> or <a href='attr.html#label_list'>label list</a> type attributes. The struct fields correspond to the attribute names. The struct values are <code>list</code> of <a href='File.html'><code>File</code></a>s. It is a shortcut for:<pre class=language-python>[f for t in ctx.attr.<ATTR> for f in t.files]</pre> In other words, use <code>files</code> to access the <a href="https://bazel.build/versions/6.1.0/rules/rules#requesting_output_files">default outputs</a> of a dependency. <a href="https://github.com/bazelbuild/examples/blob/main/rules/depsets/foo.bzl">See example of use</a>.
<h2 id="fragments">fragments</h2>
<p><pre class="rule-signature"><a class="anchor" href="fragments.html">fragments</a> ctx.fragments</pre></p>
Allows access to configuration fragments in target configuration.
<h2 id="genfiles_dir">genfiles_dir</h2>
<p><pre class="rule-signature"><a class="anchor" href="root.html">root</a> ctx.genfiles_dir</pre></p>
The root corresponding to genfiles directory.
<h2 id="host_configuration">host_configuration</h2>
<p><pre class="rule-signature"><a class="anchor" href="configuration.html">configuration</a> ctx.host_configuration</pre></p>
The host configuration. See the <a href="configuration.html">configuration</a> type for more details.
<h2 id="host_fragments">host_fragments</h2>
<p><pre class="rule-signature"><a class="anchor" href="fragments.html">fragments</a> ctx.host_fragments</pre></p>
Allows access to configuration fragments in host configuration.
<h2 id="info_file">info_file</h2>
<p><pre class="rule-signature"><a class="anchor" href="File.html">File</a> ctx.info_file</pre></p>
The file that is used to hold the non-volatile workspace status for the current build request. See documentation for --workspace_status_command for more information.
<h2 id="label">label</h2>
<p><pre class="rule-signature"><a class="anchor" href="Label.html">Label</a> ctx.label</pre></p>
The label of the target currently being analyzed.
<h2 id="new_file">new_file</h2>
<p><pre class="rule-signature"><a class="anchor" href="File.html">File</a> ctx.new_file(var1, var2=unbound, var3=unbound)</pre></p>
DEPRECATED. Use <a href="actions.html#declare_file">ctx.actions.declare_file</a>.
Creates a file object. There are four possible signatures to this method:
<ul><li>new_file(filename): Creates a file object with the given filename in the current package.</li><li>new_file(file_root, filename): Creates a file object with the given filename under the given file root.</li><li>new_file(sibling_file, filename): Creates a file object in the same directory as the given sibling file.</li><li>new_file(file_root, sibling_file, suffix): Creates a file object with same base name of the sibling_file but with different given suffix, under the given file root.</li></ul> Does not actually create a file on the file system, just declares that some action will do so. You must create an action that generates the file. If the file should be visible to other rules, declare a rule output instead when possible. Doing so enables Blaze to associate a label with the file that rules can refer to (allowing finer dependency control) instead of referencing the whole rule. <!-- hide-from-toc is a class used by DevSite for the public Bazel site
(https://developers.google.com/devsite/reference/styles/headings#hide_headings_from_the_toc) -->
<h3 class="hide-from-toc">Parameters</h3>
<table class="table table-bordered table-condensed table-params">
<colgroup>
<col class="col-param">
<col class="param-description">
</colgroup>
<thead>
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td id="new_file.var1">
<code>var1</code>
</td>
<td>
<code><a class="anchor" href="string.html">string</a>; or <a class="anchor" href="root.html">root</a>; or <a class="anchor" href="File.html">File</a></code>;
required
</td>
</tr>
<tr>
<td id="new_file.var2">
<code>var2</code>
</td>
<td>
<code><a class="anchor" href="string.html">string</a>; or <a class="anchor" href="File.html">File</a></code>;
default = unbound
</td>
</tr>
<tr>
<td id="new_file.var3">
<code>var3</code>
</td>
<td>
<code><a class="anchor" href="string.html">string</a></code>;
default = unbound
</td>
</tr>
</tbody>
</table>
<h2 id="outputs">outputs</h2>
<p><pre class="rule-signature">structure ctx.outputs</pre></p>
A pseudo-struct containing all the predeclared output files, represented by <a href='File.html'><code>File</code></a> objects. See the <a href='https://bazel.build/versions/6.1.0/rules/rules#files'>Rules page</a> for more information and examples.<p>This field does not exist on aspect contexts, since aspects do not have predeclared outputs.<p>The fields of this object are defined as follows. It is an error if two outputs produce the same field name or have the same label.<ul><li>If the rule declares an <a href='globals.html#rule.outputs'><code>outputs</code></a> dict, then for every entry in the dict, there is a field whose name is the key and whose value is the corresponding <code>File</code>.<li>For every attribute of type <a href='attr.html#output'><code>attr.output</code></a> that the rule declares, there is a field whose name is the attribute's name. If the target specified a label for that attribute, then the field value is the corresponding <code>File</code>; otherwise the field value is <code>None</code>.<li>For every attribute of type <a href='attr.html#output_list'><code>attr.output_list</code></a> that the rule declares, there is a field whose name is the attribute's name. The field value is a list of <code>File</code> objects corresponding to the labels given for that attribute in the target, or an empty list if the attribute was not specified in the target.<li><b>(Deprecated)</b> If the rule is marked <a href='globals.html#rule.executable'><code>executable</code></a> or <a href='globals.html#rule.test'><code>test</code></a>, there is a field named <code>"executable"</code>, which is the default executable. It is recommended that instead of using this, you pass another file (either predeclared or not) to the <code>executable</code> arg of <a href='DefaultInfo.html'><code>DefaultInfo</code></a>.</ul>
<h2 id="resolve_command">resolve_command</h2>
<p><pre class="rule-signature"><a class="anchor" href="tuple.html">tuple</a> ctx.resolve_command(command='', attribute=None, expand_locations=False, make_variables=None, tools=[], label_dict={}, execution_requirements={})</pre></p>
<i>(Experimental)</i> Returns a tuple <code>(inputs, command, input_manifests)</code> of the list of resolved inputs, the argv list for the resolved command, and the runfiles metadata required to run the command, all of them suitable for passing as the same-named arguments of the <code>ctx.action</code> method.
<b>Note for Windows users</b>: this method requires Bash (MSYS2). Consider using <code>resolve_tools()</code> instead (if that fits your needs).
<!-- hide-from-toc is a class used by DevSite for the public Bazel site
(https://developers.google.com/devsite/reference/styles/headings#hide_headings_from_the_toc) -->
<h3 class="hide-from-toc">Parameters</h3>
<table class="table table-bordered table-condensed table-params">
<colgroup>
<col class="col-param">
<col class="param-description">
</colgroup>
<thead>
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td id="resolve_command.command">
<code>command</code>
</td>
<td>
default = ''
Command to resolve.
</td>
</tr>
<tr>
<td id="resolve_command.attribute">
<code>attribute</code>
</td>
<td>
<code><a class="anchor" href="string.html">string</a>; or <a class="anchor" href="globals.html#None">None</a></code>;
default = None
Name of the associated attribute for which to issue an error, or None.
</td>
</tr>
<tr>
<td id="resolve_command.expand_locations">
<code>expand_locations</code>
</td>
<td>
default = False
Shall we expand $(location) variables? See <a href="#expand_location">ctx.expand_location()</a> for more details.
</td>
</tr>
<tr>
<td id="resolve_command.make_variables">
<code>make_variables</code>
</td>
<td>
<code><a class="anchor" href="dict.html">dict</a>; or <a class="anchor" href="globals.html#None">None</a></code>;
default = None
Make variables to expand, or None.
</td>
</tr>
<tr>
<td id="resolve_command.tools">
<code>tools</code>
</td>
<td>
<code><a class="anchor" href="list.html">sequence</a> of <a class="anchor" href="Target.html">Target</a>s</code>;
default = []
List of tools (list of targets).
</td>
</tr>
<tr>
<td id="resolve_command.label_dict">
<code>label_dict</code>
</td>
<td>
default = {}
Dictionary of resolved labels and the corresponding list of Files (a dict of Label : list of Files).
</td>
</tr>
<tr>
<td id="resolve_command.execution_requirements">
<code>execution_requirements</code>
</td>
<td>
default = {}
Information for scheduling the action to resolve this command. See <a href="/versions/6.1.0/reference/be/common-definitions#common.tags">tags</a> for useful keys.
</td>
</tr>
</tbody>
</table>
<h2 id="resolve_tools">resolve_tools</h2>
<p><pre class="rule-signature"><a class="anchor" href="tuple.html">tuple</a> ctx.resolve_tools(tools=[])</pre></p>
Returns a tuple <code>(inputs, input_manifests)</code> of the depset of resolved inputs and the runfiles metadata required to run the tools, both of them suitable for passing as the same-named arguments of the <code>ctx.actions.run</code> method.
In contrast to <code>ctx.resolve_command</code>, this method does not require that Bash be installed on the machine, so it's suitable for rules built on Windows.
<!-- hide-from-toc is a class used by DevSite for the public Bazel site
(https://developers.google.com/devsite/reference/styles/headings#hide_headings_from_the_toc) -->
<h3 class="hide-from-toc">Parameters</h3>
<table class="table table-bordered table-condensed table-params">
<colgroup>
<col class="col-param">
<col class="param-description">
</colgroup>
<thead>
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td id="resolve_tools.tools">
<code>tools</code>
</td>
<td>
<code><a class="anchor" href="list.html">sequence</a> of <a class="anchor" href="Target.html">Target</a>s</code>;
default = []
List of tools (list of targets).
</td>
</tr>
</tbody>
</table>
<h2 id="rule">rule</h2>
<p><pre class="rule-signature"><a class="anchor" href="rule_attributes.html">rule_attributes</a> ctx.rule</pre></p>
Rule attributes descriptor for the rule that the aspect is applied to. Only available in aspect implementation functions.
<h2 id="runfiles">runfiles</h2>
<p><pre class="rule-signature"><a class="anchor" href="runfiles.html">runfiles</a> ctx.runfiles(files=[], transitive_files=None, collect_data=False, collect_default=False, symlinks={}, root_symlinks={})</pre></p>
Creates a runfiles object.
<!-- hide-from-toc is a class used by DevSite for the public Bazel site
(https://developers.google.com/devsite/reference/styles/headings#hide_headings_from_the_toc) -->
<h3 class="hide-from-toc">Parameters</h3>
<table class="table table-bordered table-condensed table-params">
<colgroup>
<col class="col-param">
<col class="param-description">
</colgroup>
<thead>
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td id="runfiles.files">
<code>files</code>
</td>
<td>
<code><a class="anchor" href="list.html">sequence</a> of <a class="anchor" href="File.html">File</a>s</code>;
default = []
The list of files to be added to the runfiles.
</td>
</tr>
<tr>
<td id="runfiles.transitive_files">
<code>transitive_files</code>
</td>
<td>
<code><a class="anchor" href="depset.html">depset</a> of <a class="anchor" href="File.html">File</a>s; or <a class="anchor" href="globals.html#None">None</a></code>;
default = None
The (transitive) set of files to be added to the runfiles. The depset should use the <code>default</code> order (which, as the name implies, is the default).
</td>
</tr>
<tr>
<td id="runfiles.collect_data">
<code>collect_data</code>
</td>
<td>
default = False
<b>Use of this parameter is not recommended. See <a href="https://bazel.build/versions/6.1.0/rules/rules#runfiles">runfiles guide</a></b>. <p>Whether to collect the data runfiles from the dependencies in srcs, data and deps attributes.
</td>
</tr>
<tr>
<td id="runfiles.collect_default">
<code>collect_default</code>
</td>
<td>
default = False
<b>Use of this parameter is not recommended. See <a href="https://bazel.build/versions/6.1.0/rules/rules#runfiles">runfiles guide</a></b>. <p>Whether to collect the default runfiles from the dependencies in srcs, data and deps attributes.
</td>
</tr>
<tr>
<td id="runfiles.symlinks">
<code>symlinks</code>
</td>
<td>
<code><a class="anchor" href="dict.html">dict</a>; or <a class="anchor" href="depset.html">depset</a> of <a class="anchor" href="SymlinkEntry.html">SymlinkEntry</a>s</code>;
default = {}
Either a SymlinkEntry depset or the map of symlinks, prefixed by workspace name, to be added to the runfiles. See <a href="https://bazel.build/versions/6.1.0/rules/rules#runfiles_symlinks">Runfiles symlinks</a> in the rules guide.
</td>
</tr>
<tr>
<td id="runfiles.root_symlinks">
<code>root_symlinks</code>
</td>
<td>
<code><a class="anchor" href="dict.html">dict</a>; or <a class="anchor" href="depset.html">depset</a> of <a class="anchor" href="SymlinkEntry.html">SymlinkEntry</a>s</code>;
default = {}
Either a SymlinkEntry depset or a map of symlinks to be added to the runfiles. See <a href="https://bazel.build/versions/6.1.0/rules/rules#runfiles_symlinks">Runfiles symlinks</a> in the rules guide.
</td>
</tr>
</tbody>
</table>
<h2 id="split_attr">split_attr</h2>
<p><pre class="rule-signature"><a class="anchor" href="struct.html">struct</a> ctx.split_attr</pre></p>
A struct to access the values of attributes with split configurations. If the attribute is a label list, the value of split_attr is a dict of the keys of the split (as strings) to lists of the ConfiguredTargets in that branch of the split. If the attribute is a label, then the value of split_attr is a dict of the keys of the split (as strings) to single ConfiguredTargets. Attributes with split configurations still appear in the attr struct, but their values will be single lists with all the branches of the split merged together.
<h2 id="target_platform_has_constraint">target_platform_has_constraint</h2>
<p><pre class="rule-signature"><a class="anchor" href="bool.html">bool</a> ctx.target_platform_has_constraint(constraintValue)</pre></p>
Returns true if the given constraint value is part of the current target platform.
<!-- hide-from-toc is a class used by DevSite for the public Bazel site
(https://developers.google.com/devsite/reference/styles/headings#hide_headings_from_the_toc) -->
<h3 class="hide-from-toc">Parameters</h3>
<table class="table table-bordered table-condensed table-params">
<colgroup>
<col class="col-param">
<col class="param-description">
</colgroup>
<thead>
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td id="target_platform_has_constraint.constraintValue">
<code>constraintValue</code>
</td>
<td>
required
The constraint value to check the target platform against.
</td>
</tr>
</tbody>
</table>
<h2 id="toolchains">toolchains</h2>
<p><pre class="rule-signature"><a class="anchor" href="ToolchainContext.html">ToolchainContext</a> ctx.toolchains</pre></p>
Toolchains for the default exec group of this rule.
<h2 id="var">var</h2>
<p><pre class="rule-signature"><a class="anchor" href="dict.html">dict</a> ctx.var</pre></p>
Dictionary (String to String) of configuration variables.
<h2 id="version_file">version_file</h2>
<p><pre class="rule-signature"><a class="anchor" href="File.html">File</a> ctx.version_file</pre></p>
The file that is used to hold the volatile workspace status for the current build request. See documentation for --workspace_status_command for more information.
<h2 id="workspace_name">workspace_name</h2>
<p><pre class="rule-signature"><a class="anchor" href="string.html">string</a> ctx.workspace_name</pre></p>
The workspace name as defined in the WORKSPACE file.