| <html devsite> |
| <head> |
| <meta name="project_path" value="/_project.yaml"> |
| <meta name="book_path" value="/versions/8.2.0/_book.yaml"> |
| </head> |
| <body> |
| |
| <h1 class="page-title" id="modules.attr">attr</h1> |
| |
| {% dynamic setvar source_file "src/main/java/com/google/devtools/build/lib/starlarkbuildapi/StarlarkAttrModuleApi.java" %} |
| {% dynamic setvar version "8.2.0" %} |
| {% dynamic setvar original_path "/rules/lib/toplevel/attr" %} |
| {% include "_buttons.html" %} |
| <!-- {% raw %} --> |
| |
| This is a top-level module for defining the attribute schemas of a rule or aspect. Each function returns an object representing the schema of a single attribute. These objects are used as the values of the <code>attrs</code> dictionary argument of <a href="../globals/bzl.html#rule"><code>rule()</code></a>, <a href="../globals/bzl.html#aspect"><code>aspect()</code></a>, <a href="../globals/bzl.html#repository_rule"><code>repository_rule()</code></a> and <a href="../globals/bzl.html#tag_class"><code>tag_class()</code></a>. <p>See the Rules page for more on <a href="https://bazel.build/versions/8.2.0/extending/rules#attributes">defining</a> |
| and <a href="https://bazel.build/versions/8.2.0/extending/rules#implementation_function">using</a> attributes.</p> |
| |
| |
| <h2>Members</h2> |
| <ul> |
| <li> |
| <a href="#bool">bool</a> |
| </li> |
| <li> |
| <a href="#int">int</a> |
| </li> |
| <li> |
| <a href="#int_list">int_list</a> |
| </li> |
| <li> |
| <a href="#label">label</a> |
| </li> |
| <li> |
| <a href="#label_keyed_string_dict">label_keyed_string_dict</a> |
| </li> |
| <li> |
| <a href="#label_list">label_list</a> |
| </li> |
| <li> |
| <a href="#output">output</a> |
| </li> |
| <li> |
| <a href="#output_list">output_list</a> |
| </li> |
| <li> |
| <a href="#string">string</a> |
| </li> |
| <li> |
| <a href="#string_dict">string_dict</a> |
| </li> |
| <li> |
| <a href="#string_keyed_label_dict">string_keyed_label_dict</a> |
| </li> |
| <li> |
| <a href="#string_list">string_list</a> |
| </li> |
| <li> |
| <a href="#string_list_dict">string_list_dict</a> |
| </li> |
| </ul> |
| |
| <h2 id="bool">bool</h2> |
| <p><pre class="rule-signature"><a class="anchor" href="../builtins/Attribute.html">Attribute</a> attr.bool(configurable=unbound, default=False, doc=None, mandatory=False)</pre></p> |
| |
| Creates a schema for a boolean attribute. The corresponding <a href='../builtins/ctx.html#attr'><code>ctx.attr</code></a> attribute will be of type <a href='../core/bool.html'><code>bool</code></a>. |
| |
| <!-- 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="bool.configurable"> |
| <code>configurable</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/bool.html">bool</a>; or unbound; |
| default is <code>unbound</code><br/> |
| This argument can only be specified for an attribute of a symbolic macro.<p>If <code>configurable</code> is explicitly set to <code>False</code>, the symbolic macro attribute is non-configurable - in other words, it cannot take a <code>select()</code> value. If the <code>configurable</code> is either unbound or explicitly set to <code>True</code>, the attribute is configurable and can take a <code>select()</code> value.<p>For an attribute of a rule or aspect, <code>configurable</code> must be left unbound. Most Starlark rule attributes are always configurable, with the exception of <code>attr.output()</code>, <code>attr.output_list()</code>, and <code>attr.license()</code> rule attributes, which are always non-configurable. |
| </td> |
| </tr> |
| <tr> |
| <td id="bool.default"> |
| <code>default</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/bool.html">bool</a>; |
| default is <code>False</code><br/> |
| A default value to use if no value for this attribute is given when instantiating the rule. |
| </td> |
| </tr> |
| <tr> |
| <td id="bool.doc"> |
| <code>doc</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/string.html">string</a>; or <code>None</code>; |
| default is <code>None</code><br/> |
| A description of the attribute that can be extracted by documentation generating tools. |
| </td> |
| </tr> |
| <tr> |
| <td id="bool.mandatory"> |
| <code>mandatory</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/bool.html">bool</a>; |
| default is <code>False</code><br/> |
| If true, the value must be specified explicitly (even if it has a <code>default</code>). |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="int">int</h2> |
| <p><pre class="rule-signature"><a class="anchor" href="../builtins/Attribute.html">Attribute</a> attr.int(configurable=unbound, default=0, doc=None, mandatory=False, values=[])</pre></p> |
| |
| Creates a schema for an integer attribute. The value must be in the signed 32-bit range. The corresponding <a href='../builtins/ctx.html#attr'><code>ctx.attr</code></a> attribute will be of type <a href='../core/int.html'><code>int</code></a>. |
| |
| <!-- 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="int.configurable"> |
| <code>configurable</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/bool.html">bool</a>; or unbound; |
| default is <code>unbound</code><br/> |
| This argument can only be specified for an attribute of a symbolic macro.<p>If <code>configurable</code> is explicitly set to <code>False</code>, the symbolic macro attribute is non-configurable - in other words, it cannot take a <code>select()</code> value. If the <code>configurable</code> is either unbound or explicitly set to <code>True</code>, the attribute is configurable and can take a <code>select()</code> value.<p>For an attribute of a rule or aspect, <code>configurable</code> must be left unbound. Most Starlark rule attributes are always configurable, with the exception of <code>attr.output()</code>, <code>attr.output_list()</code>, and <code>attr.license()</code> rule attributes, which are always non-configurable. |
| </td> |
| </tr> |
| <tr> |
| <td id="int.default"> |
| <code>default</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/int.html">int</a>; |
| default is <code>0</code><br/> |
| A default value to use if no value for this attribute is given when instantiating the rule. |
| </td> |
| </tr> |
| <tr> |
| <td id="int.doc"> |
| <code>doc</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/string.html">string</a>; or <code>None</code>; |
| default is <code>None</code><br/> |
| A description of the attribute that can be extracted by documentation generating tools. |
| </td> |
| </tr> |
| <tr> |
| <td id="int.mandatory"> |
| <code>mandatory</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/bool.html">bool</a>; |
| default is <code>False</code><br/> |
| If true, the value must be specified explicitly (even if it has a <code>default</code>). |
| </td> |
| </tr> |
| <tr> |
| <td id="int.values"> |
| <code>values</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/list.html">sequence</a> of <a class="anchor" href="../core/int.html">int</a>s; |
| default is <code>[]</code><br/> |
| The list of allowed values for the attribute. An error is raised if any other value is given. |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="int_list">int_list</h2> |
| <p><pre class="rule-signature"><a class="anchor" href="../builtins/Attribute.html">Attribute</a> attr.int_list(mandatory=False, allow_empty=True, *, configurable=unbound, default=[], doc=None)</pre></p> |
| |
| Creates a schema for a list-of-integers attribute. Each element must be in the signed 32-bit range. |
| |
| <!-- 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="int_list.mandatory"> |
| <code>mandatory</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/bool.html">bool</a>; |
| default is <code>False</code><br/> |
| If true, the value must be specified explicitly (even if it has a <code>default</code>). |
| </td> |
| </tr> |
| <tr> |
| <td id="int_list.allow_empty"> |
| <code>allow_empty</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/bool.html">bool</a>; |
| default is <code>True</code><br/> |
| True if the attribute can be empty. |
| </td> |
| </tr> |
| <tr> |
| <td id="int_list.configurable"> |
| <code>configurable</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/bool.html">bool</a>; or unbound; |
| default is <code>unbound</code><br/> |
| This argument can only be specified for an attribute of a symbolic macro.<p>If <code>configurable</code> is explicitly set to <code>False</code>, the symbolic macro attribute is non-configurable - in other words, it cannot take a <code>select()</code> value. If the <code>configurable</code> is either unbound or explicitly set to <code>True</code>, the attribute is configurable and can take a <code>select()</code> value.<p>For an attribute of a rule or aspect, <code>configurable</code> must be left unbound. Most Starlark rule attributes are always configurable, with the exception of <code>attr.output()</code>, <code>attr.output_list()</code>, and <code>attr.license()</code> rule attributes, which are always non-configurable. |
| </td> |
| </tr> |
| <tr> |
| <td id="int_list.default"> |
| <code>default</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/list.html">sequence</a> of <a class="anchor" href="../core/int.html">int</a>s; |
| default is <code>[]</code><br/> |
| A default value to use if no value for this attribute is given when instantiating the rule. |
| </td> |
| </tr> |
| <tr> |
| <td id="int_list.doc"> |
| <code>doc</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/string.html">string</a>; or <code>None</code>; |
| default is <code>None</code><br/> |
| A description of the attribute that can be extracted by documentation generating tools. |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="label">label</h2> |
| <p><pre class="rule-signature"><a class="anchor" href="../builtins/Attribute.html">Attribute</a> attr.label(configurable=unbound, default=None, materializer=None, doc=None, executable=False, allow_files=None, allow_single_file=None, mandatory=False, skip_validations=False, providers=[], for_dependency_resolution=unbound, allow_rules=None, cfg=None, aspects=[], flags=[])</pre></p> |
| |
| <p>Creates a schema for a label attribute. This is a dependency attribute.</p><p>This attribute contains unique <a href='../builtins/Label.html'><code>Label</code></a> values. If a string is supplied in place of a <code>Label</code>, it will be converted using the <a href='../builtins/Label.html#Label'>label constructor</a>. The relative parts of the label path, including the (possibly renamed) repository, are resolved with respect to the instantiated target's package.<p>At analysis time (within the rule's implementation function), when retrieving the attribute value from <code>ctx.attr</code>, labels are replaced by the corresponding <a href='../builtins/Target.html'><code>Target</code></a>s. This allows you to access the providers of the current target's dependencies.<p>In addition to ordinary source files, this kind of attribute is often used to refer to a tool -- for example, a compiler. Such tools are considered to be dependencies, just like source files. To avoid requiring users to specify the tool's label every time they use the rule in their BUILD files, you can hard-code the label of a canonical tool as the <code>default</code> value of this attribute. If you also want to prevent users from overriding this default, you can make the attribute private by giving it a name that starts with an underscore. See the <a href='https://bazel.build/versions/8.2.0/extending/rules#private-attributes'>Rules</a> page for more information. |
| |
| <!-- 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="label.configurable"> |
| <code>configurable</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/bool.html">bool</a>; or unbound; |
| default is <code>unbound</code><br/> |
| This argument can only be specified for an attribute of a symbolic macro.<p>If <code>configurable</code> is explicitly set to <code>False</code>, the symbolic macro attribute is non-configurable - in other words, it cannot take a <code>select()</code> value. If the <code>configurable</code> is either unbound or explicitly set to <code>True</code>, the attribute is configurable and can take a <code>select()</code> value.<p>For an attribute of a rule or aspect, <code>configurable</code> must be left unbound. Most Starlark rule attributes are always configurable, with the exception of <code>attr.output()</code>, <code>attr.output_list()</code>, and <code>attr.license()</code> rule attributes, which are always non-configurable. |
| </td> |
| </tr> |
| <tr> |
| <td id="label.default"> |
| <code>default</code> |
| </td> |
| <td> |
| <a class="anchor" href="../builtins/Label.html">Label</a>; or <a class="anchor" href="../core/string.html">string</a>; or <a class="anchor" href="../builtins/LateBoundDefault.html">LateBoundDefault</a>; or NativeComputedDefault; or <a class="anchor" href="../core/function.html">function</a>; or <code>None</code>; |
| default is <code>None</code><br/> |
| A default value to use if no value for this attribute is given when instantiating the rule.Use a string or the <a href="../builtins/Label.html#Label"><code>Label</code></a> function to specify a default value, for example, <code>attr.label(default = "//a:b")</code>. |
| </td> |
| </tr> |
| <tr> |
| <td id="label.materializer"> |
| <code>materializer</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/function.html">function</a>; |
| default is <code>None</code><br/> |
| <b>Experimental</b>. This parameter is experimental and may change at any time. Please do not depend on it. It may be enabled on an experimental basis by setting <code>--experimental_dormant_deps</code> <br>If set, the attribute materializes dormant dependencies from the transitive closure. The value of this parameter must be a functon that gets access to the values of the attributes of the rule that either are not dependencies or are marked as available for dependency resolution. It must return either a dormant dependency or a list of them depending on the type of the attribute |
| </td> |
| </tr> |
| <tr> |
| <td id="label.doc"> |
| <code>doc</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/string.html">string</a>; or <code>None</code>; |
| default is <code>None</code><br/> |
| A description of the attribute that can be extracted by documentation generating tools. |
| </td> |
| </tr> |
| <tr> |
| <td id="label.executable"> |
| <code>executable</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/bool.html">bool</a>; |
| default is <code>False</code><br/> |
| True if the dependency has to be executable. This means the label must refer to an executable file, or to a rule that outputs an executable file. Access the label with <code>ctx.executable.<attribute_name></code>. |
| </td> |
| </tr> |
| <tr> |
| <td id="label.allow_files"> |
| <code>allow_files</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/bool.html">bool</a>; or <a class="anchor" href="../core/list.html">sequence</a> of <a class="anchor" href="../core/string.html">string</a>s; or <code>None</code>; |
| default is <code>None</code><br/> |
| Whether <code>File</code> targets are allowed. Can be <code>True</code>, <code>False</code> (default), or a list of file extensions that are allowed (for example, <code>[".cc", ".cpp"]</code>). |
| </td> |
| </tr> |
| <tr> |
| <td id="label.allow_single_file"> |
| <code>allow_single_file</code> |
| </td> |
| <td> |
| default is <code>None</code><br/> |
| This is similar to <code>allow_files</code>, with the restriction that the label must correspond to a single <a href="../builtins/File.html">File</a>. Access it through <code>ctx.file.<attribute_name></code>. |
| </td> |
| </tr> |
| <tr> |
| <td id="label.mandatory"> |
| <code>mandatory</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/bool.html">bool</a>; |
| default is <code>False</code><br/> |
| If true, the value must be specified explicitly (even if it has a <code>default</code>). |
| </td> |
| </tr> |
| <tr> |
| <td id="label.skip_validations"> |
| <code>skip_validations</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/bool.html">bool</a>; |
| default is <code>False</code><br/> |
| If true, validation actions of transitive dependencies from this attribute will not run. This is a temporary mitigation and WILL be removed in the future. |
| </td> |
| </tr> |
| <tr> |
| <td id="label.providers"> |
| <code>providers</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/list.html">sequence</a>; |
| default is <code>[]</code><br/> |
| The providers that must be given by any dependency appearing in this attribute.<p>The format of this argument is a list of lists of providers -- <code>*Info</code> objects returned by <a href='../globals/bzl.html#provider'><code>provider()</code></a> (or in the case of a legacy provider, its string name). The dependency must return ALL providers mentioned in at least ONE of the inner lists. As a convenience, this argument may also be a single-level list of providers, in which case it is wrapped in an outer list with one element. It is NOT required that the rule of the dependency advertises those providers in its <code>provides</code> parameter, however, it is considered best practice. |
| </td> |
| </tr> |
| <tr> |
| <td id="label.for_dependency_resolution"> |
| <code>for_dependency_resolution</code> |
| </td> |
| <td> |
| default is <code>unbound</code><br/> |
| If this is set, the attribute is available for materializers. Only rules marked with the flag of the same name are allowed to be referenced through such attributes. |
| </td> |
| </tr> |
| <tr> |
| <td id="label.allow_rules"> |
| <code>allow_rules</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/list.html">sequence</a> of <a class="anchor" href="../core/string.html">string</a>s; or <code>None</code>; |
| default is <code>None</code><br/> |
| Which rule targets (name of the classes) are allowed. This is deprecated (kept only for compatibility), use providers instead. |
| </td> |
| </tr> |
| <tr> |
| <td id="label.cfg"> |
| <code>cfg</code> |
| </td> |
| <td> |
| default is <code>None</code><br/> |
| <a href="https://bazel.build/versions/8.2.0/extending/rules#configurations">Configuration</a> of the attribute. It can be either <code>"exec"</code>, which indicates that the dependency is built for the <code>execution platform</code>, or <code>"target"</code>, which indicates that the dependency is build for the <code>target platform</code>. A typical example of the difference is when building mobile apps, where the <code>target platform</code> is <code>Android</code> or <code>iOS</code> while the <code>execution platform</code> is <code>Linux</code>, <code>macOS</code>, or <code>Windows</code>. This parameter is required if <code>executable</code> is True to guard against accidentally building host tools in the target configuration. <code>"target"</code> has no semantic effect, so don't set it when <code>executable</code> is False unless it really helps clarify your intentions. |
| </td> |
| </tr> |
| <tr> |
| <td id="label.aspects"> |
| <code>aspects</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/list.html">sequence</a> of <a class="anchor" href="../builtins/Aspect.html">Aspect</a>s; |
| default is <code>[]</code><br/> |
| Aspects that should be applied to the dependency or dependencies specified by this attribute. |
| </td> |
| </tr> |
| <tr> |
| <td id="label.flags"> |
| <code>flags</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/list.html">sequence</a> of <a class="anchor" href="../core/string.html">string</a>s; |
| default is <code>[]</code><br/> |
| Deprecated, will be removed. |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="label_keyed_string_dict">label_keyed_string_dict</h2> |
| <p><pre class="rule-signature"><a class="anchor" href="../builtins/Attribute.html">Attribute</a> attr.label_keyed_string_dict(allow_empty=True, *, configurable=unbound, default={}, doc=None, allow_files=None, allow_rules=None, providers=[], for_dependency_resolution=unbound, flags=[], mandatory=False, cfg=None, aspects=[])</pre></p> |
| |
| <p>Creates a schema for an attribute holding a dictionary, where the keys are labels and the values are strings. This is a dependency attribute.</p><p>This attribute contains unique <a href='../builtins/Label.html'><code>Label</code></a> values. If a string is supplied in place of a <code>Label</code>, it will be converted using the <a href='../builtins/Label.html#Label'>label constructor</a>. The relative parts of the label path, including the (possibly renamed) repository, are resolved with respect to the instantiated target's package.<p>At analysis time (within the rule's implementation function), when retrieving the attribute value from <code>ctx.attr</code>, labels are replaced by the corresponding <a href='../builtins/Target.html'><code>Target</code></a>s. This allows you to access the providers of the current target's dependencies. |
| |
| <!-- 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="label_keyed_string_dict.allow_empty"> |
| <code>allow_empty</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/bool.html">bool</a>; |
| default is <code>True</code><br/> |
| True if the attribute can be empty. |
| </td> |
| </tr> |
| <tr> |
| <td id="label_keyed_string_dict.configurable"> |
| <code>configurable</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/bool.html">bool</a>; or unbound; |
| default is <code>unbound</code><br/> |
| This argument can only be specified for an attribute of a symbolic macro.<p>If <code>configurable</code> is explicitly set to <code>False</code>, the symbolic macro attribute is non-configurable - in other words, it cannot take a <code>select()</code> value. If the <code>configurable</code> is either unbound or explicitly set to <code>True</code>, the attribute is configurable and can take a <code>select()</code> value.<p>For an attribute of a rule or aspect, <code>configurable</code> must be left unbound. Most Starlark rule attributes are always configurable, with the exception of <code>attr.output()</code>, <code>attr.output_list()</code>, and <code>attr.license()</code> rule attributes, which are always non-configurable. |
| </td> |
| </tr> |
| <tr> |
| <td id="label_keyed_string_dict.default"> |
| <code>default</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/dict.html">dict</a>; or <a class="anchor" href="../core/function.html">function</a>; |
| default is <code>{}</code><br/> |
| A default value to use if no value for this attribute is given when instantiating the rule.Use strings or the <a href="../builtins/Label.html#Label"><code>Label</code></a> function to specify default values, for example, <code>attr.label_keyed_string_dict(default = {"//a:b": "value", "//a:c": "string"})</code>. |
| </td> |
| </tr> |
| <tr> |
| <td id="label_keyed_string_dict.doc"> |
| <code>doc</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/string.html">string</a>; or <code>None</code>; |
| default is <code>None</code><br/> |
| A description of the attribute that can be extracted by documentation generating tools. |
| </td> |
| </tr> |
| <tr> |
| <td id="label_keyed_string_dict.allow_files"> |
| <code>allow_files</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/bool.html">bool</a>; or <a class="anchor" href="../core/list.html">sequence</a> of <a class="anchor" href="../core/string.html">string</a>s; or <code>None</code>; |
| default is <code>None</code><br/> |
| Whether <code>File</code> targets are allowed. Can be <code>True</code>, <code>False</code> (default), or a list of file extensions that are allowed (for example, <code>[".cc", ".cpp"]</code>). |
| </td> |
| </tr> |
| <tr> |
| <td id="label_keyed_string_dict.allow_rules"> |
| <code>allow_rules</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/list.html">sequence</a> of <a class="anchor" href="../core/string.html">string</a>s; or <code>None</code>; |
| default is <code>None</code><br/> |
| Which rule targets (name of the classes) are allowed. This is deprecated (kept only for compatibility), use providers instead. |
| </td> |
| </tr> |
| <tr> |
| <td id="label_keyed_string_dict.providers"> |
| <code>providers</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/list.html">sequence</a>; |
| default is <code>[]</code><br/> |
| The providers that must be given by any dependency appearing in this attribute.<p>The format of this argument is a list of lists of providers -- <code>*Info</code> objects returned by <a href='../globals/bzl.html#provider'><code>provider()</code></a> (or in the case of a legacy provider, its string name). The dependency must return ALL providers mentioned in at least ONE of the inner lists. As a convenience, this argument may also be a single-level list of providers, in which case it is wrapped in an outer list with one element. It is NOT required that the rule of the dependency advertises those providers in its <code>provides</code> parameter, however, it is considered best practice. |
| </td> |
| </tr> |
| <tr> |
| <td id="label_keyed_string_dict.for_dependency_resolution"> |
| <code>for_dependency_resolution</code> |
| </td> |
| <td> |
| default is <code>unbound</code><br/> |
| If this is set, the attribute is available for materializers. Only rules marked with the flag of the same name are allowed to be referenced through such attributes. |
| </td> |
| </tr> |
| <tr> |
| <td id="label_keyed_string_dict.flags"> |
| <code>flags</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/list.html">sequence</a> of <a class="anchor" href="../core/string.html">string</a>s; |
| default is <code>[]</code><br/> |
| Deprecated, will be removed. |
| </td> |
| </tr> |
| <tr> |
| <td id="label_keyed_string_dict.mandatory"> |
| <code>mandatory</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/bool.html">bool</a>; |
| default is <code>False</code><br/> |
| If true, the value must be specified explicitly (even if it has a <code>default</code>). |
| </td> |
| </tr> |
| <tr> |
| <td id="label_keyed_string_dict.cfg"> |
| <code>cfg</code> |
| </td> |
| <td> |
| default is <code>None</code><br/> |
| <a href="https://bazel.build/versions/8.2.0/extending/rules#configurations">Configuration</a> of the attribute. It can be either <code>"exec"</code>, which indicates that the dependency is built for the <code>execution platform</code>, or <code>"target"</code>, which indicates that the dependency is build for the <code>target platform</code>. A typical example of the difference is when building mobile apps, where the <code>target platform</code> is <code>Android</code> or <code>iOS</code> while the <code>execution platform</code> is <code>Linux</code>, <code>macOS</code>, or <code>Windows</code>. |
| </td> |
| </tr> |
| <tr> |
| <td id="label_keyed_string_dict.aspects"> |
| <code>aspects</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/list.html">sequence</a> of <a class="anchor" href="../builtins/Aspect.html">Aspect</a>s; |
| default is <code>[]</code><br/> |
| Aspects that should be applied to the dependency or dependencies specified by this attribute. |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="label_list">label_list</h2> |
| <p><pre class="rule-signature"><a class="anchor" href="../builtins/Attribute.html">Attribute</a> attr.label_list(allow_empty=True, *, configurable=unbound, default=[], materializer=None, doc=None, allow_files=None, allow_rules=None, providers=[], for_dependency_resolution=unbound, flags=[], mandatory=False, skip_validations=False, cfg=None, aspects=[])</pre></p> |
| |
| <p>Creates a schema for a list-of-labels attribute. This is a dependency attribute. The corresponding <a href='../builtins/ctx.html#attr'><code>ctx.attr</code></a> attribute will be of type <a href='../core/list.html'>list</a> of <a href='../builtins/Target.html'><code>Target</code>s</a>.</p><p>This attribute contains unique <a href='../builtins/Label.html'><code>Label</code></a> values. If a string is supplied in place of a <code>Label</code>, it will be converted using the <a href='../builtins/Label.html#Label'>label constructor</a>. The relative parts of the label path, including the (possibly renamed) repository, are resolved with respect to the instantiated target's package.<p>At analysis time (within the rule's implementation function), when retrieving the attribute value from <code>ctx.attr</code>, labels are replaced by the corresponding <a href='../builtins/Target.html'><code>Target</code></a>s. This allows you to access the providers of the current target's dependencies. |
| |
| <!-- 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="label_list.allow_empty"> |
| <code>allow_empty</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/bool.html">bool</a>; |
| default is <code>True</code><br/> |
| True if the attribute can be empty. |
| </td> |
| </tr> |
| <tr> |
| <td id="label_list.configurable"> |
| <code>configurable</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/bool.html">bool</a>; or unbound; |
| default is <code>unbound</code><br/> |
| This argument can only be specified for an attribute of a symbolic macro.<p>If <code>configurable</code> is explicitly set to <code>False</code>, the symbolic macro attribute is non-configurable - in other words, it cannot take a <code>select()</code> value. If the <code>configurable</code> is either unbound or explicitly set to <code>True</code>, the attribute is configurable and can take a <code>select()</code> value.<p>For an attribute of a rule or aspect, <code>configurable</code> must be left unbound. Most Starlark rule attributes are always configurable, with the exception of <code>attr.output()</code>, <code>attr.output_list()</code>, and <code>attr.license()</code> rule attributes, which are always non-configurable. |
| </td> |
| </tr> |
| <tr> |
| <td id="label_list.default"> |
| <code>default</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/list.html">sequence</a> of <a class="anchor" href="../builtins/Label.html">Label</a>s; or <a class="anchor" href="../core/function.html">function</a>; |
| default is <code>[]</code><br/> |
| A default value to use if no value for this attribute is given when instantiating the rule.Use strings or the <a href="../builtins/Label.html#Label"><code>Label</code></a> function to specify default values, for example, <code>attr.label_list(default = ["//a:b", "//a:c"])</code>. |
| </td> |
| </tr> |
| <tr> |
| <td id="label_list.materializer"> |
| <code>materializer</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/function.html">function</a>; |
| default is <code>None</code><br/> |
| <b>Experimental</b>. This parameter is experimental and may change at any time. Please do not depend on it. It may be enabled on an experimental basis by setting <code>--experimental_dormant_deps</code> <br>If set, the attribute materializes dormant dependencies from the transitive closure. The value of this parameter must be a functon that gets access to the values of the attributes of the rule that either are not dependencies or are marked as available for dependency resolution. It must return either a dormant dependency or a list of them depending on the type of the attribute |
| </td> |
| </tr> |
| <tr> |
| <td id="label_list.doc"> |
| <code>doc</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/string.html">string</a>; or <code>None</code>; |
| default is <code>None</code><br/> |
| A description of the attribute that can be extracted by documentation generating tools. |
| </td> |
| </tr> |
| <tr> |
| <td id="label_list.allow_files"> |
| <code>allow_files</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/bool.html">bool</a>; or <a class="anchor" href="../core/list.html">sequence</a> of <a class="anchor" href="../core/string.html">string</a>s; or <code>None</code>; |
| default is <code>None</code><br/> |
| Whether <code>File</code> targets are allowed. Can be <code>True</code>, <code>False</code> (default), or a list of file extensions that are allowed (for example, <code>[".cc", ".cpp"]</code>). |
| </td> |
| </tr> |
| <tr> |
| <td id="label_list.allow_rules"> |
| <code>allow_rules</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/list.html">sequence</a> of <a class="anchor" href="../core/string.html">string</a>s; or <code>None</code>; |
| default is <code>None</code><br/> |
| Which rule targets (name of the classes) are allowed. This is deprecated (kept only for compatibility), use providers instead. |
| </td> |
| </tr> |
| <tr> |
| <td id="label_list.providers"> |
| <code>providers</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/list.html">sequence</a>; |
| default is <code>[]</code><br/> |
| The providers that must be given by any dependency appearing in this attribute.<p>The format of this argument is a list of lists of providers -- <code>*Info</code> objects returned by <a href='../globals/bzl.html#provider'><code>provider()</code></a> (or in the case of a legacy provider, its string name). The dependency must return ALL providers mentioned in at least ONE of the inner lists. As a convenience, this argument may also be a single-level list of providers, in which case it is wrapped in an outer list with one element. It is NOT required that the rule of the dependency advertises those providers in its <code>provides</code> parameter, however, it is considered best practice. |
| </td> |
| </tr> |
| <tr> |
| <td id="label_list.for_dependency_resolution"> |
| <code>for_dependency_resolution</code> |
| </td> |
| <td> |
| default is <code>unbound</code><br/> |
| If this is set, the attribute is available for materializers. Only rules marked with the flag of the same name are allowed to be referenced through such attributes. |
| </td> |
| </tr> |
| <tr> |
| <td id="label_list.flags"> |
| <code>flags</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/list.html">sequence</a> of <a class="anchor" href="../core/string.html">string</a>s; |
| default is <code>[]</code><br/> |
| Deprecated, will be removed. |
| </td> |
| </tr> |
| <tr> |
| <td id="label_list.mandatory"> |
| <code>mandatory</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/bool.html">bool</a>; |
| default is <code>False</code><br/> |
| If true, the value must be specified explicitly (even if it has a <code>default</code>). |
| </td> |
| </tr> |
| <tr> |
| <td id="label_list.skip_validations"> |
| <code>skip_validations</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/bool.html">bool</a>; |
| default is <code>False</code><br/> |
| If true, validation actions of transitive dependencies from this attribute will not run. This is a temporary mitigation and WILL be removed in the future. |
| </td> |
| </tr> |
| <tr> |
| <td id="label_list.cfg"> |
| <code>cfg</code> |
| </td> |
| <td> |
| default is <code>None</code><br/> |
| <a href="https://bazel.build/versions/8.2.0/extending/rules#configurations">Configuration</a> of the attribute. It can be either <code>"exec"</code>, which indicates that the dependency is built for the <code>execution platform</code>, or <code>"target"</code>, which indicates that the dependency is build for the <code>target platform</code>. A typical example of the difference is when building mobile apps, where the <code>target platform</code> is <code>Android</code> or <code>iOS</code> while the <code>execution platform</code> is <code>Linux</code>, <code>macOS</code>, or <code>Windows</code>. |
| </td> |
| </tr> |
| <tr> |
| <td id="label_list.aspects"> |
| <code>aspects</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/list.html">sequence</a> of <a class="anchor" href="../builtins/Aspect.html">Aspect</a>s; |
| default is <code>[]</code><br/> |
| Aspects that should be applied to the dependency or dependencies specified by this attribute. |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="output">output</h2> |
| <p><pre class="rule-signature"><a class="anchor" href="../builtins/Attribute.html">Attribute</a> attr.output(doc=None, mandatory=False)</pre></p> |
| |
| <p>Creates a schema for an output (label) attribute.</p><p>This attribute contains unique <a href='../builtins/Label.html'><code>Label</code></a> values. If a string is supplied in place of a <code>Label</code>, it will be converted using the <a href='../builtins/Label.html#Label'>label constructor</a>. The relative parts of the label path, including the (possibly renamed) repository, are resolved with respect to the instantiated target's package.<p>At analysis time, the corresponding <a href='../builtins/File.html'><code>File</code></a> can be retrieved using <a href='../builtins/ctx.html#outputs'><code>ctx.outputs</code></a>. |
| |
| <!-- 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="output.doc"> |
| <code>doc</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/string.html">string</a>; or <code>None</code>; |
| default is <code>None</code><br/> |
| A description of the attribute that can be extracted by documentation generating tools. |
| </td> |
| </tr> |
| <tr> |
| <td id="output.mandatory"> |
| <code>mandatory</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/bool.html">bool</a>; |
| default is <code>False</code><br/> |
| If true, the value must be specified explicitly (even if it has a <code>default</code>). |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="output_list">output_list</h2> |
| <p><pre class="rule-signature"><a class="anchor" href="../builtins/Attribute.html">Attribute</a> attr.output_list(allow_empty=True, *, doc=None, mandatory=False)</pre></p> |
| |
| Creates a schema for a list-of-outputs attribute.<p>This attribute contains unique <a href='../builtins/Label.html'><code>Label</code></a> values. If a string is supplied in place of a <code>Label</code>, it will be converted using the <a href='../builtins/Label.html#Label'>label constructor</a>. The relative parts of the label path, including the (possibly renamed) repository, are resolved with respect to the instantiated target's package.<p>At analysis time, the corresponding <a href='../builtins/File.html'><code>File</code></a> can be retrieved using <a href='../builtins/ctx.html#outputs'><code>ctx.outputs</code></a>. |
| |
| <!-- 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="output_list.allow_empty"> |
| <code>allow_empty</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/bool.html">bool</a>; |
| default is <code>True</code><br/> |
| True if the attribute can be empty. |
| </td> |
| </tr> |
| <tr> |
| <td id="output_list.doc"> |
| <code>doc</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/string.html">string</a>; or <code>None</code>; |
| default is <code>None</code><br/> |
| A description of the attribute that can be extracted by documentation generating tools. |
| </td> |
| </tr> |
| <tr> |
| <td id="output_list.mandatory"> |
| <code>mandatory</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/bool.html">bool</a>; |
| default is <code>False</code><br/> |
| If true, the value must be specified explicitly (even if it has a <code>default</code>). |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="string">string</h2> |
| <p><pre class="rule-signature"><a class="anchor" href="../builtins/Attribute.html">Attribute</a> attr.string(configurable=unbound, default='', doc=None, mandatory=False, values=[])</pre></p> |
| |
| Creates a schema for a <a href='../core/string.html#attr'>string</a> attribute. |
| |
| <!-- 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="string.configurable"> |
| <code>configurable</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/bool.html">bool</a>; or unbound; |
| default is <code>unbound</code><br/> |
| This argument can only be specified for an attribute of a symbolic macro.<p>If <code>configurable</code> is explicitly set to <code>False</code>, the symbolic macro attribute is non-configurable - in other words, it cannot take a <code>select()</code> value. If the <code>configurable</code> is either unbound or explicitly set to <code>True</code>, the attribute is configurable and can take a <code>select()</code> value.<p>For an attribute of a rule or aspect, <code>configurable</code> must be left unbound. Most Starlark rule attributes are always configurable, with the exception of <code>attr.output()</code>, <code>attr.output_list()</code>, and <code>attr.license()</code> rule attributes, which are always non-configurable. |
| </td> |
| </tr> |
| <tr> |
| <td id="string.default"> |
| <code>default</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/string.html">string</a>; or NativeComputedDefault; |
| default is <code>''</code><br/> |
| A default value to use if no value for this attribute is given when instantiating the rule. |
| </td> |
| </tr> |
| <tr> |
| <td id="string.doc"> |
| <code>doc</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/string.html">string</a>; or <code>None</code>; |
| default is <code>None</code><br/> |
| A description of the attribute that can be extracted by documentation generating tools. |
| </td> |
| </tr> |
| <tr> |
| <td id="string.mandatory"> |
| <code>mandatory</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/bool.html">bool</a>; |
| default is <code>False</code><br/> |
| If true, the value must be specified explicitly (even if it has a <code>default</code>). |
| </td> |
| </tr> |
| <tr> |
| <td id="string.values"> |
| <code>values</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/list.html">sequence</a> of <a class="anchor" href="../core/string.html">string</a>s; |
| default is <code>[]</code><br/> |
| The list of allowed values for the attribute. An error is raised if any other value is given. |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="string_dict">string_dict</h2> |
| <p><pre class="rule-signature"><a class="anchor" href="../builtins/Attribute.html">Attribute</a> attr.string_dict(allow_empty=True, *, configurable=unbound, default={}, doc=None, mandatory=False)</pre></p> |
| |
| Creates a schema for an attribute holding a dictionary, where the keys and values are strings. |
| |
| <!-- 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="string_dict.allow_empty"> |
| <code>allow_empty</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/bool.html">bool</a>; |
| default is <code>True</code><br/> |
| True if the attribute can be empty. |
| </td> |
| </tr> |
| <tr> |
| <td id="string_dict.configurable"> |
| <code>configurable</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/bool.html">bool</a>; or unbound; |
| default is <code>unbound</code><br/> |
| This argument can only be specified for an attribute of a symbolic macro.<p>If <code>configurable</code> is explicitly set to <code>False</code>, the symbolic macro attribute is non-configurable - in other words, it cannot take a <code>select()</code> value. If the <code>configurable</code> is either unbound or explicitly set to <code>True</code>, the attribute is configurable and can take a <code>select()</code> value.<p>For an attribute of a rule or aspect, <code>configurable</code> must be left unbound. Most Starlark rule attributes are always configurable, with the exception of <code>attr.output()</code>, <code>attr.output_list()</code>, and <code>attr.license()</code> rule attributes, which are always non-configurable. |
| </td> |
| </tr> |
| <tr> |
| <td id="string_dict.default"> |
| <code>default</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/dict.html">dict</a>; |
| default is <code>{}</code><br/> |
| A default value to use if no value for this attribute is given when instantiating the rule. |
| </td> |
| </tr> |
| <tr> |
| <td id="string_dict.doc"> |
| <code>doc</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/string.html">string</a>; or <code>None</code>; |
| default is <code>None</code><br/> |
| A description of the attribute that can be extracted by documentation generating tools. |
| </td> |
| </tr> |
| <tr> |
| <td id="string_dict.mandatory"> |
| <code>mandatory</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/bool.html">bool</a>; |
| default is <code>False</code><br/> |
| If true, the value must be specified explicitly (even if it has a <code>default</code>). |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="string_keyed_label_dict">string_keyed_label_dict</h2> |
| <p><pre class="rule-signature"><a class="anchor" href="../builtins/Attribute.html">Attribute</a> attr.string_keyed_label_dict(allow_empty=True, *, configurable=unbound, default={}, doc=None, allow_files=None, allow_rules=None, providers=[], for_dependency_resolution=unbound, flags=[], mandatory=False, cfg=None, aspects=[])</pre></p> |
| |
| <p>Creates a schema for an attribute whose value is a dictionary where the keys are strings and the values are labels. This is a dependency attribute.</p><p>This attribute contains unique <a href='../builtins/Label.html'><code>Label</code></a> values. If a string is supplied in place of a <code>Label</code>, it will be converted using the <a href='../builtins/Label.html#Label'>label constructor</a>. The relative parts of the label path, including the (possibly renamed) repository, are resolved with respect to the instantiated target's package.<p>At analysis time (within the rule's implementation function), when retrieving the attribute value from <code>ctx.attr</code>, labels are replaced by the corresponding <a href='../builtins/Target.html'><code>Target</code></a>s. This allows you to access the providers of the current target's dependencies. |
| |
| <!-- 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="string_keyed_label_dict.allow_empty"> |
| <code>allow_empty</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/bool.html">bool</a>; |
| default is <code>True</code><br/> |
| True if the attribute can be empty. |
| </td> |
| </tr> |
| <tr> |
| <td id="string_keyed_label_dict.configurable"> |
| <code>configurable</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/bool.html">bool</a>; or unbound; |
| default is <code>unbound</code><br/> |
| This argument can only be specified for an attribute of a symbolic macro.<p>If <code>configurable</code> is explicitly set to <code>False</code>, the symbolic macro attribute is non-configurable - in other words, it cannot take a <code>select()</code> value. If the <code>configurable</code> is either unbound or explicitly set to <code>True</code>, the attribute is configurable and can take a <code>select()</code> value.<p>For an attribute of a rule or aspect, <code>configurable</code> must be left unbound. Most Starlark rule attributes are always configurable, with the exception of <code>attr.output()</code>, <code>attr.output_list()</code>, and <code>attr.license()</code> rule attributes, which are always non-configurable. |
| </td> |
| </tr> |
| <tr> |
| <td id="string_keyed_label_dict.default"> |
| <code>default</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/dict.html">dict</a>; or <a class="anchor" href="../core/function.html">function</a>; |
| default is <code>{}</code><br/> |
| A default value to use if no value for this attribute is given when instantiating the rule.Use strings or the <a href="../builtins/Label.html#Label"><code>Label</code></a> function to specify default values, for example, <code>attr.string_keyed_label_dict(default = {"foo": "//a:b", "bar": "//a:c"})</code>. |
| </td> |
| </tr> |
| <tr> |
| <td id="string_keyed_label_dict.doc"> |
| <code>doc</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/string.html">string</a>; or <code>None</code>; |
| default is <code>None</code><br/> |
| A description of the attribute that can be extracted by documentation generating tools. |
| </td> |
| </tr> |
| <tr> |
| <td id="string_keyed_label_dict.allow_files"> |
| <code>allow_files</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/bool.html">bool</a>; or <a class="anchor" href="../core/list.html">sequence</a> of <a class="anchor" href="../core/string.html">string</a>s; or <code>None</code>; |
| default is <code>None</code><br/> |
| Whether <code>File</code> targets are allowed. Can be <code>True</code>, <code>False</code> (default), or a list of file extensions that are allowed (for example, <code>[".cc", ".cpp"]</code>). |
| </td> |
| </tr> |
| <tr> |
| <td id="string_keyed_label_dict.allow_rules"> |
| <code>allow_rules</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/list.html">sequence</a> of <a class="anchor" href="../core/string.html">string</a>s; or <code>None</code>; |
| default is <code>None</code><br/> |
| Which rule targets (name of the classes) are allowed. This is deprecated (kept only for compatibility), use providers instead. |
| </td> |
| </tr> |
| <tr> |
| <td id="string_keyed_label_dict.providers"> |
| <code>providers</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/list.html">sequence</a>; |
| default is <code>[]</code><br/> |
| The providers that must be given by any dependency appearing in this attribute.<p>The format of this argument is a list of lists of providers -- <code>*Info</code> objects returned by <a href='../globals/bzl.html#provider'><code>provider()</code></a> (or in the case of a legacy provider, its string name). The dependency must return ALL providers mentioned in at least ONE of the inner lists. As a convenience, this argument may also be a single-level list of providers, in which case it is wrapped in an outer list with one element. It is NOT required that the rule of the dependency advertises those providers in its <code>provides</code> parameter, however, it is considered best practice. |
| </td> |
| </tr> |
| <tr> |
| <td id="string_keyed_label_dict.for_dependency_resolution"> |
| <code>for_dependency_resolution</code> |
| </td> |
| <td> |
| default is <code>unbound</code><br/> |
| If this is set, the attribute is available for materializers. Only rules marked with the flag of the same name are allowed to be referenced through such attributes. |
| </td> |
| </tr> |
| <tr> |
| <td id="string_keyed_label_dict.flags"> |
| <code>flags</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/list.html">sequence</a> of <a class="anchor" href="../core/string.html">string</a>s; |
| default is <code>[]</code><br/> |
| Deprecated, will be removed. |
| </td> |
| </tr> |
| <tr> |
| <td id="string_keyed_label_dict.mandatory"> |
| <code>mandatory</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/bool.html">bool</a>; |
| default is <code>False</code><br/> |
| If true, the value must be specified explicitly (even if it has a <code>default</code>). |
| </td> |
| </tr> |
| <tr> |
| <td id="string_keyed_label_dict.cfg"> |
| <code>cfg</code> |
| </td> |
| <td> |
| default is <code>None</code><br/> |
| <a href="https://bazel.build/versions/8.2.0/extending/rules#configurations">Configuration</a> of the attribute. It can be either <code>"exec"</code>, which indicates that the dependency is built for the <code>execution platform</code>, or <code>"target"</code>, which indicates that the dependency is build for the <code>target platform</code>. A typical example of the difference is when building mobile apps, where the <code>target platform</code> is <code>Android</code> or <code>iOS</code> while the <code>execution platform</code> is <code>Linux</code>, <code>macOS</code>, or <code>Windows</code>. |
| </td> |
| </tr> |
| <tr> |
| <td id="string_keyed_label_dict.aspects"> |
| <code>aspects</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/list.html">sequence</a> of <a class="anchor" href="../builtins/Aspect.html">Aspect</a>s; |
| default is <code>[]</code><br/> |
| Aspects that should be applied to the dependency or dependencies specified by this attribute. |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="string_list">string_list</h2> |
| <p><pre class="rule-signature"><a class="anchor" href="../builtins/Attribute.html">Attribute</a> attr.string_list(mandatory=False, allow_empty=True, *, configurable=unbound, default=[], doc=None)</pre></p> |
| |
| Creates a schema for a list-of-strings attribute. |
| |
| <!-- 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="string_list.mandatory"> |
| <code>mandatory</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/bool.html">bool</a>; |
| default is <code>False</code><br/> |
| If true, the value must be specified explicitly (even if it has a <code>default</code>). |
| </td> |
| </tr> |
| <tr> |
| <td id="string_list.allow_empty"> |
| <code>allow_empty</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/bool.html">bool</a>; |
| default is <code>True</code><br/> |
| True if the attribute can be empty. |
| </td> |
| </tr> |
| <tr> |
| <td id="string_list.configurable"> |
| <code>configurable</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/bool.html">bool</a>; or unbound; |
| default is <code>unbound</code><br/> |
| This argument can only be specified for an attribute of a symbolic macro.<p>If <code>configurable</code> is explicitly set to <code>False</code>, the symbolic macro attribute is non-configurable - in other words, it cannot take a <code>select()</code> value. If the <code>configurable</code> is either unbound or explicitly set to <code>True</code>, the attribute is configurable and can take a <code>select()</code> value.<p>For an attribute of a rule or aspect, <code>configurable</code> must be left unbound. Most Starlark rule attributes are always configurable, with the exception of <code>attr.output()</code>, <code>attr.output_list()</code>, and <code>attr.license()</code> rule attributes, which are always non-configurable. |
| </td> |
| </tr> |
| <tr> |
| <td id="string_list.default"> |
| <code>default</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/list.html">sequence</a> of <a class="anchor" href="../core/string.html">string</a>s; or NativeComputedDefault; |
| default is <code>[]</code><br/> |
| A default value to use if no value for this attribute is given when instantiating the rule. |
| </td> |
| </tr> |
| <tr> |
| <td id="string_list.doc"> |
| <code>doc</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/string.html">string</a>; or <code>None</code>; |
| default is <code>None</code><br/> |
| A description of the attribute that can be extracted by documentation generating tools. |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="string_list_dict">string_list_dict</h2> |
| <p><pre class="rule-signature"><a class="anchor" href="../builtins/Attribute.html">Attribute</a> attr.string_list_dict(allow_empty=True, *, configurable=unbound, default={}, doc=None, mandatory=False)</pre></p> |
| |
| Creates a schema for an attribute holding a dictionary, where the keys are strings and the values are lists of strings. |
| |
| <!-- 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="string_list_dict.allow_empty"> |
| <code>allow_empty</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/bool.html">bool</a>; |
| default is <code>True</code><br/> |
| True if the attribute can be empty. |
| </td> |
| </tr> |
| <tr> |
| <td id="string_list_dict.configurable"> |
| <code>configurable</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/bool.html">bool</a>; or unbound; |
| default is <code>unbound</code><br/> |
| This argument can only be specified for an attribute of a symbolic macro.<p>If <code>configurable</code> is explicitly set to <code>False</code>, the symbolic macro attribute is non-configurable - in other words, it cannot take a <code>select()</code> value. If the <code>configurable</code> is either unbound or explicitly set to <code>True</code>, the attribute is configurable and can take a <code>select()</code> value.<p>For an attribute of a rule or aspect, <code>configurable</code> must be left unbound. Most Starlark rule attributes are always configurable, with the exception of <code>attr.output()</code>, <code>attr.output_list()</code>, and <code>attr.license()</code> rule attributes, which are always non-configurable. |
| </td> |
| </tr> |
| <tr> |
| <td id="string_list_dict.default"> |
| <code>default</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/dict.html">dict</a>; |
| default is <code>{}</code><br/> |
| A default value to use if no value for this attribute is given when instantiating the rule. |
| </td> |
| </tr> |
| <tr> |
| <td id="string_list_dict.doc"> |
| <code>doc</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/string.html">string</a>; or <code>None</code>; |
| default is <code>None</code><br/> |
| A description of the attribute that can be extracted by documentation generating tools. |
| </td> |
| </tr> |
| <tr> |
| <td id="string_list_dict.mandatory"> |
| <code>mandatory</code> |
| </td> |
| <td> |
| <a class="anchor" href="../core/bool.html">bool</a>; |
| default is <code>False</code><br/> |
| If true, the value must be specified explicitly (even if it has a <code>default</code>). |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| |
| </body> |
| </html> |
| |
| <!-- {% endraw %} --> |