Back to Bazel

Attr

docs/versions/6.3.0/rules/lib/attr.mdx

9.1.143.7 KB
Original Source
<html devsite> <head> <meta name="project_path" value="/_project.yaml"> <meta name="book_path" value="/versions/6.3.0/_book.yaml"> </head> <body> <h1 class="page-title" id="modules.attr">attr</h1> <!-- {% 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.html#rule"><code>rule()</code></a> and <a href="globals.html#aspect"><code>aspect()</code></a>.<p>See the Rules page for more on <a href='https://bazel.build/versions/6.3.0/rules/rules#attributes'>defining</a> and <a href='https://bazel.build/versions/6.3.0/rules/rules#implementation_function'>using</a> attributes.

<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_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="Attribute.html">Attribute</a> attr.bool(default=False, doc='', mandatory=False)</pre></p>

Creates a schema for a boolean 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="bool.default">
          <code>default</code>
        </td>
        <td>
                                 default = False

                      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>
                                 default = ''

                      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>
                                 default = False

                      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="Attribute.html">Attribute</a> attr.int(default=0, doc='', mandatory=False, values=[])</pre></p>

Creates a schema for an integer attribute. The value 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.default">
          <code>default</code>
        </td>
        <td>
                                 default = 0

                      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>
                                 default = ''

                      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>
                                 default = False

                      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>
                      <code><a class="anchor" href="list.html">sequence</a> of <a class="anchor" href="int.html">int</a>s</code>;
                                 default = []

                      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="Attribute.html">Attribute</a> attr.int_list(mandatory=False, allow_empty=True, *, default=[], doc='')</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>
                                 default = False

                      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>
                                 default = True

                      True if the attribute can be empty.
        </td>
      </tr>
              <tr>
        <td id="int_list.default">
          <code>default</code>
        </td>
        <td>
                      <code><a class="anchor" href="list.html">sequence</a> of <a class="anchor" href="int.html">int</a>s</code>;
                                 default = []

                      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>
                                 default = ''

                      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="Attribute.html">Attribute</a> attr.label(default=None, doc='', executable=False, allow_files=None, allow_single_file=None, mandatory=False, providers=[], allow_rules=None, cfg=None, aspects=[])</pre></p>

<p>Creates a schema for a label attribute. This is a dependency attribute.</p><p>This attribute contains unique <a href='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='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='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/6.3.0/rules/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.default">
          <code>default</code>
        </td>
        <td>
                      <code><a class="anchor" href="Label.html">Label</a>; or <a class="anchor" href="string.html">string</a>; or <a class="anchor" href="LateBoundDefault.html">LateBoundDefault</a>; or NativeComputedDefault; or <a class="anchor" href="function.html">function</a>; or <a class="anchor" href="globals.html#None">None</a></code>;
                                 default = None

                      A default value to use if no value for this attribute is given when instantiating the rule.Use a string or the <a href="globals.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.doc">
          <code>doc</code>
        </td>
        <td>
                                 default = ''

                      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>
                                 default = False

                      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.&lt;attribute_name&gt;</code>.
        </td>
      </tr>
              <tr>
        <td id="label.allow_files">
          <code>allow_files</code>
        </td>
        <td>
                      <code><a class="anchor" href="bool.html">bool</a>; or <a class="anchor" href="list.html">sequence</a> of <a class="anchor" href="string.html">string</a>s; or <a class="anchor" href="globals.html#None">None</a></code>;
                                 default = None

                      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 = None

                      This is similar to <code>allow_files</code>, with the restriction that the label must correspond to a single <a href="File.html">File</a>. Access it through <code>ctx.file.&lt;attribute_name&gt;</code>.
        </td>
      </tr>
              <tr>
        <td id="label.mandatory">
          <code>mandatory</code>
        </td>
        <td>
                                 default = False

                      If true, the value must be specified explicitly (even if it has a <code>default</code>).
        </td>
      </tr>
              <tr>
        <td id="label.providers">
          <code>providers</code>
        </td>
        <td>
                                 default = []

                      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.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.
        </td>
      </tr>
              <tr>
        <td id="label.allow_rules">
          <code>allow_rules</code>
        </td>
        <td>
                      <code><a class="anchor" href="list.html">sequence</a> of <a class="anchor" href="string.html">string</a>s; or <a class="anchor" href="globals.html#None">None</a></code>;
                                 default = None

                      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 = None

                      <a href="https://bazel.build/versions/6.3.0/rules/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>
                      <code><a class="anchor" href="list.html">sequence</a> of <a class="anchor" href="Aspect.html">Aspect</a>s</code>;
                                 default = []

                      Aspects that should be applied to the dependency or dependencies specified by this attribute.
        </td>
      </tr>
            </tbody>
  </table>

    <h2 id="label_keyed_string_dict">label_keyed_string_dict</h2>
    <p><pre class="rule-signature"><a class="anchor" href="Attribute.html">Attribute</a> attr.label_keyed_string_dict(allow_empty=True, *, default={}, doc='', allow_files=None, allow_rules=None, providers=[], 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='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='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='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>
                                 default = True

                      True if the attribute can be empty.
        </td>
      </tr>
              <tr>
        <td id="label_keyed_string_dict.default">
          <code>default</code>
        </td>
        <td>
                      <code><a class="anchor" href="dict.html">dict</a>; or <a class="anchor" href="function.html">function</a></code>;
                                 default = {}

                      A default value to use if no value for this attribute is given when instantiating the rule.Use strings or the <a href="globals.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>
                                 default = ''

                      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>
                      <code><a class="anchor" href="bool.html">bool</a>; or <a class="anchor" href="list.html">sequence</a> of <a class="anchor" href="string.html">string</a>s; or <a class="anchor" href="globals.html#None">None</a></code>;
                                 default = None

                      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>
                      <code><a class="anchor" href="list.html">sequence</a> of <a class="anchor" href="string.html">string</a>s; or <a class="anchor" href="globals.html#None">None</a></code>;
                                 default = None

                      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>
                                 default = []

                      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.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.
        </td>
      </tr>
              <tr>
        <td id="label_keyed_string_dict.flags">
          <code>flags</code>
        </td>
        <td>
                      <code><a class="anchor" href="list.html">sequence</a> of <a class="anchor" href="string.html">string</a>s</code>;
                                 default = []

                      Deprecated, will be removed.
        </td>
      </tr>
              <tr>
        <td id="label_keyed_string_dict.mandatory">
          <code>mandatory</code>
        </td>
        <td>
                                 default = False

                      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 = None

                      <a href="https://bazel.build/versions/6.3.0/rules/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>
                      <code><a class="anchor" href="list.html">sequence</a> of <a class="anchor" href="Aspect.html">Aspect</a>s</code>;
                                 default = []

                      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="Attribute.html">Attribute</a> attr.label_list(allow_empty=True, *, default=[], doc='', allow_files=None, allow_rules=None, providers=[], flags=[], mandatory=False, cfg=None, aspects=[])</pre></p>

<p>Creates a schema for a list-of-labels attribute. This is a dependency attribute.</p><p>This attribute contains unique <a href='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='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='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>
                                 default = True

                      True if the attribute can be empty.
        </td>
      </tr>
              <tr>
        <td id="label_list.default">
          <code>default</code>
        </td>
        <td>
                      <code><a class="anchor" href="list.html">sequence</a> of <a class="anchor" href="Label.html">Label</a>s; or <a class="anchor" href="function.html">function</a></code>;
                                 default = []

                      A default value to use if no value for this attribute is given when instantiating the rule.Use strings or the <a href="globals.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.doc">
          <code>doc</code>
        </td>
        <td>
                                 default = ''

                      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>
                      <code><a class="anchor" href="bool.html">bool</a>; or <a class="anchor" href="list.html">sequence</a> of <a class="anchor" href="string.html">string</a>s; or <a class="anchor" href="globals.html#None">None</a></code>;
                                 default = None

                      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>
                      <code><a class="anchor" href="list.html">sequence</a> of <a class="anchor" href="string.html">string</a>s; or <a class="anchor" href="globals.html#None">None</a></code>;
                                 default = None

                      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>
                                 default = []

                      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.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.
        </td>
      </tr>
              <tr>
        <td id="label_list.flags">
          <code>flags</code>
        </td>
        <td>
                      <code><a class="anchor" href="list.html">sequence</a> of <a class="anchor" href="string.html">string</a>s</code>;
                                 default = []

                      Deprecated, will be removed.
        </td>
      </tr>
              <tr>
        <td id="label_list.mandatory">
          <code>mandatory</code>
        </td>
        <td>
                                 default = False

                      If true, the value must be specified explicitly (even if it has a <code>default</code>).
        </td>
      </tr>
              <tr>
        <td id="label_list.cfg">
          <code>cfg</code>
        </td>
        <td>
                                 default = None

                      <a href="https://bazel.build/versions/6.3.0/rules/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>
                      <code><a class="anchor" href="list.html">sequence</a> of <a class="anchor" href="Aspect.html">Aspect</a>s</code>;
                                 default = []

                      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="Attribute.html">Attribute</a> attr.output(doc='', mandatory=False)</pre></p>

<p>Creates a schema for an output (label) attribute.</p><p>This attribute contains unique <a href='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='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='File.html'><code>File</code></a> can be retrieved using <code>ctx.outputs</code>.

      <!-- 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>
                                 default = ''

                      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>
                                 default = False

                      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="Attribute.html">Attribute</a> attr.output_list(allow_empty=True, *, doc='', mandatory=False)</pre></p>

Creates a schema for a list-of-outputs attribute.<p>This attribute contains unique <a href='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='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='File.html'><code>File</code></a> can be retrieved using <code>ctx.outputs</code>.

      <!-- 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>
                                 default = True

                      True if the attribute can be empty.
        </td>
      </tr>
              <tr>
        <td id="output_list.doc">
          <code>doc</code>
        </td>
        <td>
                                 default = ''

                      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>
                                 default = False

                      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="Attribute.html">Attribute</a> attr.string(default='', doc='', mandatory=False, values=[])</pre></p>

Creates a schema for a string 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.default">
          <code>default</code>
        </td>
        <td>
                      <code><a class="anchor" href="string.html">string</a>; or NativeComputedDefault</code>;
                                 default = ''

                      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>
                                 default = ''

                      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>
                                 default = False

                      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>
                      <code><a class="anchor" href="list.html">sequence</a> of <a class="anchor" href="string.html">string</a>s</code>;
                                 default = []

                      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="Attribute.html">Attribute</a> attr.string_dict(allow_empty=True, *, default={}, doc='', 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>
                                 default = True

                      True if the attribute can be empty.
        </td>
      </tr>
              <tr>
        <td id="string_dict.default">
          <code>default</code>
        </td>
        <td>
                                 default = {}

                      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>
                                 default = ''

                      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>
                                 default = False

                      If true, the value must be specified explicitly (even if it has a <code>default</code>).
        </td>
      </tr>
            </tbody>
  </table>

    <h2 id="string_list">string_list</h2>
    <p><pre class="rule-signature"><a class="anchor" href="Attribute.html">Attribute</a> attr.string_list(mandatory=False, allow_empty=True, *, default=[], doc='')</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>
                                 default = False

                      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>
                                 default = True

                      True if the attribute can be empty.
        </td>
      </tr>
              <tr>
        <td id="string_list.default">
          <code>default</code>
        </td>
        <td>
                      <code><a class="anchor" href="list.html">sequence</a> of <a class="anchor" href="string.html">string</a>s; or NativeComputedDefault</code>;
                                 default = []

                      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>
                                 default = ''

                      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="Attribute.html">Attribute</a> attr.string_list_dict(allow_empty=True, *, default={}, doc='', 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>
                                 default = True

                      True if the attribute can be empty.
        </td>
      </tr>
              <tr>
        <td id="string_list_dict.default">
          <code>default</code>
        </td>
        <td>
                                 default = {}

                      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>
                                 default = ''

                      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>
                                 default = False

                      If true, the value must be specified explicitly (even if it has a <code>default</code>).
        </td>
      </tr>
            </tbody>
  </table>
</body> </html> <!-- {% endraw %} -->