| <html devsite> |
| <head> |
| <meta name="project_path" value="/_project.yaml"> |
| <meta name="book_path" value="/versions/6.0.0/_book.yaml"> |
| </head> |
| <body> |
| |
| <h1 class="page-title" id="modules.globals">Globals</h1> |
| |
| <!-- {% raw %} --> |
| |
| Objects, functions and modules registered in the global environment. |
| |
| <h2>Members</h2> |
| <ul> |
| <li> |
| <a href="#all">all</a> |
| </li> |
| <li> |
| <a href="#analysis_test_transition">analysis_test_transition</a> |
| </li> |
| <li> |
| <a href="#any">any</a> |
| </li> |
| <li> |
| <a href="#archive_override">archive_override</a> |
| </li> |
| <li> |
| <a href="#aspect">aspect</a> |
| </li> |
| <li> |
| <a href="#bazel_dep">bazel_dep</a> |
| </li> |
| <li> |
| <a href="#bind">bind</a> |
| </li> |
| <li> |
| <a href="#bool">bool</a> |
| </li> |
| <li> |
| <a href="#configuration_field">configuration_field</a> |
| </li> |
| <li> |
| <a href="#depset">depset</a> |
| </li> |
| <li> |
| <a href="#dict">dict</a> |
| </li> |
| <li> |
| <a href="#dir">dir</a> |
| </li> |
| <li> |
| <a href="#enumerate">enumerate</a> |
| </li> |
| <li> |
| <a href="#exec_group">exec_group</a> |
| </li> |
| <li> |
| <a href="#fail">fail</a> |
| </li> |
| <li> |
| <a href="#float">float</a> |
| </li> |
| <li> |
| <a href="#getattr">getattr</a> |
| </li> |
| <li> |
| <a href="#git_override">git_override</a> |
| </li> |
| <li> |
| <a href="#hasattr">hasattr</a> |
| </li> |
| <li> |
| <a href="#hash">hash</a> |
| </li> |
| <li> |
| <a href="#int">int</a> |
| </li> |
| <li> |
| <a href="#len">len</a> |
| </li> |
| <li> |
| <a href="#list">list</a> |
| </li> |
| <li> |
| <a href="#local_path_override">local_path_override</a> |
| </li> |
| <li> |
| <a href="#max">max</a> |
| </li> |
| <li> |
| <a href="#min">min</a> |
| </li> |
| <li> |
| <a href="#module">module</a> |
| </li> |
| <li> |
| <a href="#module_extension">module_extension</a> |
| </li> |
| <li> |
| <a href="#multiple_version_override">multiple_version_override</a> |
| </li> |
| <li> |
| <a href="#print">print</a> |
| </li> |
| <li> |
| <a href="#provider">provider</a> |
| </li> |
| <li> |
| <a href="#range">range</a> |
| </li> |
| <li> |
| <a href="#register_execution_platforms()">register_execution_platforms()</a> |
| </li> |
| <li> |
| <a href="#register_execution_platforms()">register_execution_platforms()</a> |
| </li> |
| <li> |
| <a href="#register_toolchains()">register_toolchains()</a> |
| </li> |
| <li> |
| <a href="#register_toolchains()">register_toolchains()</a> |
| </li> |
| <li> |
| <a href="#repository_rule(implementation, attrs, local, environ, configure, remotable, doc)">repository_rule(implementation, attrs, local, environ, configure, remotable, doc)</a> |
| </li> |
| <li> |
| <a href="#repository_rule(implementation, attrs, local, environ, configure, remotable, doc)">repository_rule(implementation, attrs, local, environ, configure, remotable, doc)</a> |
| </li> |
| <li> |
| <a href="#repr">repr</a> |
| </li> |
| <li> |
| <a href="#reversed">reversed</a> |
| </li> |
| <li> |
| <a href="#rule">rule</a> |
| </li> |
| <li> |
| <a href="#select">select</a> |
| </li> |
| <li> |
| <a href="#single_version_override">single_version_override</a> |
| </li> |
| <li> |
| <a href="#sorted">sorted</a> |
| </li> |
| <li> |
| <a href="#str">str</a> |
| </li> |
| <li> |
| <a href="#tag_class">tag_class</a> |
| </li> |
| <li> |
| <a href="#tuple">tuple</a> |
| </li> |
| <li> |
| <a href="#type">type</a> |
| </li> |
| <li> |
| <a href="#use_extension">use_extension</a> |
| </li> |
| <li> |
| <a href="#use_repo">use_repo</a> |
| </li> |
| <li> |
| <a href="#visibility">visibility</a> |
| </li> |
| <li> |
| <a href="#workspace">workspace</a> |
| </li> |
| <li> |
| <a href="#zip">zip</a> |
| </li> |
| </ul> |
| |
| <h2 id="all">all</h2> |
| <p><pre class="rule-signature"><a class="anchor" href="bool.html">bool</a> all(elements)</pre></p> |
| |
| Returns true if all elements evaluate to True or if the collection is empty. Elements are converted to boolean using the <a href="#bool">bool</a> function.<pre class="language-python">all(["hello", 3, True]) == True |
| all([-1, 0, 1]) == False</pre> |
| |
| <!-- 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="all.elements"> |
| <code>elements</code> |
| </td> |
| <td> |
| required<br/> |
| A string or a collection of elements. |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="analysis_test_transition">analysis_test_transition</h2> |
| <p><pre class="rule-signature"><a class="anchor" href="transition.html">transition</a> analysis_test_transition(settings)</pre></p> |
| |
| <p> Creates a configuration transition to be applied on an analysis-test rule's dependencies. This transition may only be applied on attributes of rules with <code>analysis_test = True</code>. Such rules are restricted in capabilities (for example, the size of their dependency tree is limited), so transitions created using this function are limited in potential scope as compared to transitions created using <a href="transition.html">transition</a>. <p>This function is primarily designed to facilitate the <a href="https://bazel.build/versions/6.0.0/rules/testing">Analysis Test Framework</a> core library. See its documentation (or its implementation) for best practices. |
| |
| <!-- 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="analysis_test_transition.settings"> |
| <code>settings</code> |
| </td> |
| <td> |
| required<br/> |
| A dictionary containing information about configuration settings which should be set by this configuration transition. Keys are build setting labels and values are their new post-transition values. All other settings are unchanged. Use this to declare specific configuration settings that an analysis test requires to be set in order to pass. |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="any">any</h2> |
| <p><pre class="rule-signature"><a class="anchor" href="bool.html">bool</a> any(elements)</pre></p> |
| |
| Returns true if at least one element evaluates to True. Elements are converted to boolean using the <a href="#bool">bool</a> function.<pre class="language-python">any([-1, 0, 1]) == True |
| any([False, 0, ""]) == False</pre> |
| |
| <!-- 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="any.elements"> |
| <code>elements</code> |
| </td> |
| <td> |
| required<br/> |
| A string or a collection of elements. |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="archive_override">archive_override</h2> |
| <p><pre class="rule-signature"><a class="anchor" href="globals.html#None">None</a> archive_override(module_name, urls, integrity='', strip_prefix='', patches=[], patch_cmds=[], patch_strip=0)</pre></p> |
| |
| Specifies that this dependency should come from an archive file (zip, gzip, etc) at a certain location, instead of from a registry. This directive can only be used by the root module; in other words, if a module specifies any overrides, it cannot be used as a dependency by others. |
| |
| <!-- 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="archive_override.module_name"> |
| <code>module_name</code> |
| </td> |
| <td> |
| required<br/> |
| The name of the Bazel module dependency to apply this override to. |
| </td> |
| </tr> |
| <tr> |
| <td id="archive_override.urls"> |
| <code>urls</code> |
| </td> |
| <td> |
| <code><a class="anchor" href="string.html">string</a>; or Iterable of <a class="anchor" href="string.html">string</a>s</code>; |
| required<br/> |
| The URLs of the archive; can be http(s):// or file:// URLs. |
| </td> |
| </tr> |
| <tr> |
| <td id="archive_override.integrity"> |
| <code>integrity</code> |
| </td> |
| <td> |
| default = ''<br/> |
| The expected checksum of the archive file, in Subresource Integrity format. |
| </td> |
| </tr> |
| <tr> |
| <td id="archive_override.strip_prefix"> |
| <code>strip_prefix</code> |
| </td> |
| <td> |
| default = ''<br/> |
| A directory prefix to strip from the extracted files. |
| </td> |
| </tr> |
| <tr> |
| <td id="archive_override.patches"> |
| <code>patches</code> |
| </td> |
| <td> |
| <code>Iterable of <a class="anchor" href="string.html">string</a>s</code>; |
| default = []<br/> |
| A list of labels pointing to patch files to apply for this module. The patch files must exist in the source tree of the top level project. They are applied in the list order. |
| </td> |
| </tr> |
| <tr> |
| <td id="archive_override.patch_cmds"> |
| <code>patch_cmds</code> |
| </td> |
| <td> |
| <code>Iterable of <a class="anchor" href="string.html">string</a>s</code>; |
| default = []<br/> |
| Sequence of Bash commands to be applied on Linux/Macos after patches are applied. |
| </td> |
| </tr> |
| <tr> |
| <td id="archive_override.patch_strip"> |
| <code>patch_strip</code> |
| </td> |
| <td> |
| default = 0<br/> |
| Same as the --strip argument of Unix patch. |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="aspect">aspect</h2> |
| <p><pre class="rule-signature"><a class="anchor" href="Aspect.html">Aspect</a> aspect(implementation, attr_aspects=[], attrs=None, required_providers=[], required_aspect_providers=[], provides=[], requires=[], fragments=[], host_fragments=[], toolchains=[], incompatible_use_toolchain_transition=False, doc='', *, apply_to_generating_rules=False, exec_compatible_with=[], exec_groups=None)</pre></p> |
| |
| Creates a new aspect. The result of this function must be stored in a global value. Please see the <a href="https://bazel.build/versions/6.0.0/extending/aspects">introduction to Aspects</a> for more details. |
| |
| <!-- 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="aspect.implementation"> |
| <code>implementation</code> |
| </td> |
| <td> |
| required<br/> |
| A Starlark function that implements this aspect, with exactly two parameters: <a href="Target.html">Target</a> (the target to which the aspect is applied) and <a href="ctx.html">ctx</a> (the rule context which the targetis created from). Attributes of the target are available via the <code>ctx.rule</code> field. This function is evaluated during the analysis phase for each application of an aspect to a target. |
| </td> |
| </tr> |
| <tr> |
| <td id="aspect.attr_aspects"> |
| <code>attr_aspects</code> |
| </td> |
| <td> |
| <code><a class="anchor" href="list.html">sequence</a> of <a class="anchor" href="string.html">string</a>s</code>; |
| default = []<br/> |
| List of attribute names. The aspect propagates along dependencies specified in the attributes of a target with these names. Common values here include <code>deps</code> and <code>exports</code>. The list can also contain a single string <code>"*"</code> to propagate along all dependencies of a target. |
| </td> |
| </tr> |
| <tr> |
| <td id="aspect.attrs"> |
| <code>attrs</code> |
| </td> |
| <td> |
| <code><a class="anchor" href="dict.html">dict</a>; or <a class="anchor" href="globals.html#None">None</a></code>; |
| default = None<br/> |
| A dictionary declaring all the attributes of the aspect. It maps from an attribute name to an attribute object, like `attr.label` or `attr.string` (see <a href="attr.html">attr</a> module). Aspect attributes are available to implementation function as fields of <code>ctx</code> parameter. <p>Implicit attributes starting with <code>_</code> must have default values, and have type <code>label</code> or <code>label_list</code>. <p>Explicit attributes must have type <code>string</code>, and must use the <code>values</code> restriction. Explicit attributes restrict the aspect to only be used with rules that have attributes of the same name, type, and valid values according to the restriction. |
| </td> |
| </tr> |
| <tr> |
| <td id="aspect.required_providers"> |
| <code>required_providers</code> |
| </td> |
| <td> |
| default = []<br/> |
| This attribute allows the aspect to limit its propagation to only the targets whose rules advertise its required providers. The value must be a list containing either individual providers or lists of providers but not both. For example, <code>[[FooInfo], [BarInfo], [BazInfo, QuxInfo]]</code> is a valid value while <code>[FooInfo, BarInfo, [BazInfo, QuxInfo]]</code> is not valid.<p>An unnested list of providers will automatically be converted to a list containing one list of providers. That is, <code>[FooInfo, BarInfo]</code> will automatically be converted to <code>[[FooInfo, BarInfo]]</code>.<p>To make some rule (e.g. <code>some_rule</code>) targets visible to an aspect, <code>some_rule</code> must advertise all providers from at least one of the required providers lists. For example, if the <code>required_providers</code> of an aspect are <code>[[FooInfo], [BarInfo], [BazInfo, QuxInfo]]</code>, this aspect can only see <code>some_rule</code> targets if and only if <code>some_rule</code> provides <code>FooInfo</code> *or* <code>BarInfo</code> *or* both <code>BazInfo</code> *and* <code>QuxInfo</code>. |
| </td> |
| </tr> |
| <tr> |
| <td id="aspect.required_aspect_providers"> |
| <code>required_aspect_providers</code> |
| </td> |
| <td> |
| default = []<br/> |
| This attribute allows this aspect to inspect other aspects. The value must be a list containing either individual providers or lists of providers but not both. For example, <code>[[FooInfo], [BarInfo], [BazInfo, QuxInfo]]</code> is a valid value while <code>[FooInfo, BarInfo, [BazInfo, QuxInfo]]</code> is not valid.<p>An unnested list of providers will automatically be converted to a list containing one list of providers. That is, <code>[FooInfo, BarInfo]</code> will automatically be converted to <code>[[FooInfo, BarInfo]]</code>. <p>To make another aspect (e.g. <code>other_aspect</code>) visible to this aspect, <code>other_aspect</code> must provide all providers from at least one of the lists. In the example of <code>[[FooInfo], [BarInfo], [BazInfo, QuxInfo]]</code>, this aspect can only see <code>other_aspect</code> if and only if <code>other_aspect</code> provides <code>FooInfo</code> *or* <code>BarInfo</code> *or* both <code>BazInfo</code> *and* <code>QuxInfo</code>. |
| </td> |
| </tr> |
| <tr> |
| <td id="aspect.provides"> |
| <code>provides</code> |
| </td> |
| <td> |
| default = []<br/> |
| A list of providers that the implementation function must return.<p>It is an error if the implementation function omits any of the types of providers listed here from its return value. However, the implementation function may return additional providers not listed here.<p>Each element of the list is an <code>*Info</code> object returned by <a href='globals.html#provider'><code>provider()</code></a>, except that a legacy provider is represented by its string name instead. |
| </td> |
| </tr> |
| <tr> |
| <td id="aspect.requires"> |
| <code>requires</code> |
| </td> |
| <td> |
| <code><a class="anchor" href="list.html">sequence</a> of <a class="anchor" href="Aspect.html">Aspect</a>s</code>; |
| default = []<br/> |
| List of aspects required to be propagated before this aspect. |
| </td> |
| </tr> |
| <tr> |
| <td id="aspect.fragments"> |
| <code>fragments</code> |
| </td> |
| <td> |
| <code><a class="anchor" href="list.html">sequence</a> of <a class="anchor" href="string.html">string</a>s</code>; |
| default = []<br/> |
| List of names of configuration fragments that the aspect requires in target configuration. |
| </td> |
| </tr> |
| <tr> |
| <td id="aspect.host_fragments"> |
| <code>host_fragments</code> |
| </td> |
| <td> |
| <code><a class="anchor" href="list.html">sequence</a> of <a class="anchor" href="string.html">string</a>s</code>; |
| default = []<br/> |
| List of names of configuration fragments that the aspect requires in host configuration. |
| </td> |
| </tr> |
| <tr> |
| <td id="aspect.toolchains"> |
| <code>toolchains</code> |
| </td> |
| <td> |
| <code><a class="anchor" href="list.html">sequence</a></code>; |
| default = []<br/> |
| If set, the set of toolchains this rule requires. The list can contain String, Label, or StarlarkToolchainTypeApi objects, in any combination. Toolchains will be found by checking the current platform, and provided to the rule implementation via <code>ctx.toolchain</code>. |
| </td> |
| </tr> |
| <tr> |
| <td id="aspect.incompatible_use_toolchain_transition"> |
| <code>incompatible_use_toolchain_transition</code> |
| </td> |
| <td> |
| default = False<br/> |
| Deprecated, this is no longer in use and should be removed. |
| </td> |
| </tr> |
| <tr> |
| <td id="aspect.doc"> |
| <code>doc</code> |
| </td> |
| <td> |
| default = ''<br/> |
| A description of the aspect that can be extracted by documentation generating tools. |
| </td> |
| </tr> |
| <tr> |
| <td id="aspect.apply_to_generating_rules"> |
| <code>apply_to_generating_rules</code> |
| </td> |
| <td> |
| default = False<br/> |
| If true, the aspect will, when applied to an output file, instead apply to the output file's generating rule. <p>For example, suppose an aspect propagates transitively through attribute `deps` and it is applied to target `alpha`. Suppose `alpha` has `deps = [':beta_output']`, where `beta_output` is a declared output of a target `beta`. Suppose `beta` has a target `charlie` as one of its `deps`. If `apply_to_generating_rules=True` for the aspect, then the aspect will propagate through `alpha`, `beta`, and `charlie`. If False, then the aspect will propagate only to `alpha`. </p><p>False by default.</p> |
| </td> |
| </tr> |
| <tr> |
| <td id="aspect.exec_compatible_with"> |
| <code>exec_compatible_with</code> |
| </td> |
| <td> |
| <code><a class="anchor" href="list.html">sequence</a> of <a class="anchor" href="string.html">string</a>s</code>; |
| default = []<br/> |
| A list of constraints on the execution platform that apply to all instances of this aspect. |
| </td> |
| </tr> |
| <tr> |
| <td id="aspect.exec_groups"> |
| <code>exec_groups</code> |
| </td> |
| <td> |
| <code><a class="anchor" href="dict.html">dict</a>; or <a class="anchor" href="globals.html#None">None</a></code>; |
| default = None<br/> |
| Dict of execution group name (string) to <a href='globals.html#exec_group'><code>exec_group</code>s</a>. If set, allows aspects to run actions on multiple execution platforms within a single instance. See <a href='/versions/6.0.0/extending/exec-groups'>execution groups documentation</a> for more info. |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="bazel_dep">bazel_dep</h2> |
| <p><pre class="rule-signature"><a class="anchor" href="globals.html#None">None</a> bazel_dep(name, version='', repo_name='', dev_dependency=False)</pre></p> |
| |
| Declares a direct dependency on another Bazel module. |
| |
| <!-- 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="bazel_dep.name"> |
| <code>name</code> |
| </td> |
| <td> |
| required<br/> |
| The name of the module to be added as a direct dependency. |
| </td> |
| </tr> |
| <tr> |
| <td id="bazel_dep.version"> |
| <code>version</code> |
| </td> |
| <td> |
| default = ''<br/> |
| The version of the module to be added as a direct dependency. |
| </td> |
| </tr> |
| <tr> |
| <td id="bazel_dep.repo_name"> |
| <code>repo_name</code> |
| </td> |
| <td> |
| default = ''<br/> |
| The name of the external repo representing this dependency. This is by default the name of the module. |
| </td> |
| </tr> |
| <tr> |
| <td id="bazel_dep.dev_dependency"> |
| <code>dev_dependency</code> |
| </td> |
| <td> |
| default = False<br/> |
| If true, this dependency will be ignored if the current module is not the root module or `--ignore_dev_dependency` is enabled. |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="bind">bind</h2> |
| <p><pre class="rule-signature"><a class="anchor" href="globals.html#None">None</a> bind(name, actual=None)</pre></p> |
| |
| <p>Warning: use of <code>bind()</code> is not recommended. See <a href="https://github.com/bazelbuild/bazel/issues/1952">Consider removing bind</a> for a long discussion of its issues and alternatives.</p> <p>Gives a target an alias in the <code>//external</code> package.</p> |
| |
| <!-- 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="bind.name"> |
| <code>name</code> |
| </td> |
| <td> |
| required<br/> |
| The label under '//external' to serve as the alias name |
| </td> |
| </tr> |
| <tr> |
| <td id="bind.actual"> |
| <code>actual</code> |
| </td> |
| <td> |
| <code><a class="anchor" href="string.html">string</a>; or <a class="anchor" href="globals.html#None">None</a></code>; |
| default = None<br/> |
| The real label to be aliased |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="bool">bool</h2> |
| <p><pre class="rule-signature"><a class="anchor" href="bool.html">bool</a> bool(x=False)</pre></p> |
| |
| Constructor for the bool type. It returns <code>False</code> if the object is <code>None</code>, <code>False</code>, an empty string (<code>""</code>), the number <code>0</code>, or an empty collection (e.g. <code>()</code>, <code>[]</code>). Otherwise, it returns <code>True</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="bool.x"> |
| <code>x</code> |
| </td> |
| <td> |
| default = False<br/> |
| The variable to convert. |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="configuration_field">configuration_field</h2> |
| <p><pre class="rule-signature"><a class="anchor" href="LateBoundDefault.html">LateBoundDefault</a> configuration_field(fragment, name)</pre></p> |
| |
| References a late-bound default value for an attribute of type <a href="attr.html#label">label</a>. A value is 'late-bound' if it requires the configuration to be built before determining the value. Any attribute using this as a value must <a href="https://bazel.build/versions/6.0.0/extending/rules#private-attributes">be private</a>. <p>Example usage: <p>Defining a rule attribute: <br><pre class=language-python>'_foo': attr.label(default=configuration_field(fragment='java', name='toolchain'))</pre><p>Accessing in rule implementation: <br><pre class=language-python> def _rule_impl(ctx): |
| foo_info = ctx.attr._foo |
| ...</pre> |
| |
| <!-- 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="configuration_field.fragment"> |
| <code>fragment</code> |
| </td> |
| <td> |
| required<br/> |
| The name of a configuration fragment which contains the late-bound value. |
| </td> |
| </tr> |
| <tr> |
| <td id="configuration_field.name"> |
| <code>name</code> |
| </td> |
| <td> |
| required<br/> |
| The name of the value to obtain from the configuration fragment. |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="depset">depset</h2> |
| <p><pre class="rule-signature"><a class="anchor" href="depset.html">depset</a> depset(direct=None, order="default", *, transitive=None)</pre></p> |
| |
| Creates a <a href="depset.html">depset</a>. The <code>direct</code> parameter is a list of direct elements of the depset, and <code>transitive</code> parameter is a list of depsets whose elements become indirect elements of the created depset. The order in which elements are returned when the depset is converted to a list is specified by the <code>order</code> parameter. See the <a href="https://bazel.build/versions/6.0.0/extending/depsets">Depsets overview</a> for more information. |
| <p>All elements (direct and indirect) of a depset must be of the same type, as obtained by the expression <code>type(x)</code>. |
| <p>Because a hash-based set is used to eliminate duplicates during iteration, all elements of a depset should be hashable. However, this invariant is not currently checked consistently in all constructors. Use the --incompatible_always_check_depset_elements flag to enable consistent checking; this will be the default behavior in future releases; see <a href='https://github.com/bazelbuild/bazel/issues/10313'>Issue 10313</a>. |
| <p>In addition, elements must currently be immutable, though this restriction will be relaxed in future. |
| <p> The order of the created depset should be <i>compatible</i> with the order of its <code>transitive</code> depsets. <code>"default"</code> order is compatible with any other order, all other orders are only compatible with themselves. |
| <p> Note on backward/forward compatibility. This function currently accepts a positional <code>items</code> parameter. It is deprecated and will be removed in the future, and after its removal <code>direct</code> will become a sole positional parameter of the <code>depset</code> function. Thus, both of the following calls are equivalent and future-proof:<br> |
| <pre class=language-python>depset(['a', 'b'], transitive = [...]) |
| depset(direct = ['a', 'b'], transitive = [...]) |
| </pre> |
| |
| <!-- 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="depset.direct"> |
| <code>direct</code> |
| </td> |
| <td> |
| <code><a class="anchor" href="list.html">sequence</a>; or <a class="anchor" href="globals.html#None">None</a></code>; |
| default = None<br/> |
| A list of <i>direct</i> elements of a depset. |
| </td> |
| </tr> |
| <tr> |
| <td id="depset.order"> |
| <code>order</code> |
| </td> |
| <td> |
| default = "default"<br/> |
| The traversal strategy for the new depset. See <a href="depset.html">here</a> for the possible values. |
| </td> |
| </tr> |
| <tr> |
| <td id="depset.transitive"> |
| <code>transitive</code> |
| </td> |
| <td> |
| <code><a class="anchor" href="list.html">sequence</a> of <a class="anchor" href="depset.html">depset</a>s; or <a class="anchor" href="globals.html#None">None</a></code>; |
| default = None<br/> |
| A list of depsets whose elements will become indirect elements of the depset. |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="dict">dict</h2> |
| <p><pre class="rule-signature"><a class="anchor" href="dict.html">dict</a> dict(pairs=[], **kwargs)</pre></p> |
| |
| Creates a <a href="dict.html">dictionary</a> from an optional positional argument and an optional set of keyword arguments. In the case where the same key is given multiple times, the last value will be used. Entries supplied via keyword arguments are considered to come after entries supplied via the positional argument. |
| |
| <!-- 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="dict.pairs"> |
| <code>pairs</code> |
| </td> |
| <td> |
| default = []<br/> |
| A dict, or an iterable whose elements are each of length 2 (key, value). |
| </td> |
| </tr> |
| <tr> |
| <td id="dict.kwargs"> |
| <code>kwargs</code> |
| </td> |
| <td> |
| required<br/> |
| Dictionary of additional entries. |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="dir">dir</h2> |
| <p><pre class="rule-signature"><a class="anchor" href="list.html">list</a> dir(x)</pre></p> |
| |
| Returns a list of strings: the names of the attributes and methods of the parameter object. |
| |
| <!-- hide-from-toc is a class used by DevSite for the public Bazel site |
| (https://developers.google.com/devsite/reference/styles/headings#hide_headings_from_the_toc) --> |
| <h3 class="hide-from-toc">Parameters</h3> |
| <table class="table table-bordered table-condensed table-params"> |
| <colgroup> |
| <col class="col-param"> |
| <col class="param-description"> |
| </colgroup> |
| <thead> |
| <tr> |
| <th>Parameter</th> |
| <th>Description</th> |
| </tr> |
| </thead> |
| <tbody> |
| <tr> |
| <td id="dir.x"> |
| <code>x</code> |
| </td> |
| <td> |
| required<br/> |
| The object to check. |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="enumerate">enumerate</h2> |
| <p><pre class="rule-signature"><a class="anchor" href="list.html">list</a> enumerate(list, start=0)</pre></p> |
| |
| Returns a list of pairs (two-element tuples), with the index (int) and the item from the input sequence. |
| <pre class="language-python">enumerate([24, 21, 84]) == [(0, 24), (1, 21), (2, 84)]</pre> |
| |
| |
| <!-- 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="enumerate.list"> |
| <code>list</code> |
| </td> |
| <td> |
| required<br/> |
| input sequence. |
| </td> |
| </tr> |
| <tr> |
| <td id="enumerate.start"> |
| <code>start</code> |
| </td> |
| <td> |
| default = 0<br/> |
| start index. |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="exec_group">exec_group</h2> |
| <p><pre class="rule-signature">exec_group exec_group(toolchains=[], exec_compatible_with=[], copy_from_rule=False)</pre></p> |
| |
| Creates an <a href='/versions/6.0.0/extending/exec-groups'>execution group</a> which can be used to create actions for a specific execution platform during rule implementation. |
| |
| <!-- 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="exec_group.toolchains"> |
| <code>toolchains</code> |
| </td> |
| <td> |
| <code><a class="anchor" href="list.html">sequence</a></code>; |
| default = []<br/> |
| The set of toolchains this execution group requires. The list can contain String, Label, or StarlarkToolchainTypeApi objects, in any combination. |
| </td> |
| </tr> |
| <tr> |
| <td id="exec_group.exec_compatible_with"> |
| <code>exec_compatible_with</code> |
| </td> |
| <td> |
| <code><a class="anchor" href="list.html">sequence</a> of <a class="anchor" href="string.html">string</a>s</code>; |
| default = []<br/> |
| A list of constraints on the execution platform. |
| </td> |
| </tr> |
| <tr> |
| <td id="exec_group.copy_from_rule"> |
| <code>copy_from_rule</code> |
| </td> |
| <td> |
| default = False<br/> |
| If set to true, this exec group inherits the toolchains and constraints of the rule to which this group is attached. If set to any other string this will throw an error. |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="fail">fail</h2> |
| <p><pre class="rule-signature"><a class="anchor" href="globals.html#None">None</a> fail(msg=None, attr=None, *args)</pre></p> |
| |
| Causes execution to fail with an error. |
| |
| <!-- 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="fail.msg"> |
| <code>msg</code> |
| </td> |
| <td> |
| default = None<br/> |
| Deprecated: use positional arguments instead. This argument acts like an implicit leading positional argument. |
| </td> |
| </tr> |
| <tr> |
| <td id="fail.attr"> |
| <code>attr</code> |
| </td> |
| <td> |
| <code><a class="anchor" href="string.html">string</a>; or <a class="anchor" href="globals.html#None">None</a></code>; |
| default = None<br/> |
| Deprecated. Causes an optional prefix containing this string to be added to the error message. |
| </td> |
| </tr> |
| <tr> |
| <td id="fail.args"> |
| <code>args</code> |
| </td> |
| <td> |
| required<br/> |
| A list of values, formatted with str and joined with spaces, that appear in the error message. |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="float">float</h2> |
| <p><pre class="rule-signature"><a class="anchor" href="float.html">float</a> float(x=unbound)</pre></p> |
| |
| Returns x as a float value. <ul><li>If <code>x</code> is already a float, <code>float</code> returns it unchanged. <li>If <code>x</code> is a bool, <code>float</code> returns 1.0 for True and 0.0 for False. <li>If <code>x</code> is an int, <code>float</code> returns the nearest finite floating-point value to x, or an error if the magnitude is too large. <li>If <code>x</code> is a string, it must be a valid floating-point literal, or be equal (ignoring case) to <code>NaN</code>, <code>Inf</code>, or <code>Infinity</code>, optionally preceded by a <code>+</code> or <code>-</code> sign. </ul>Any other value causes an error. With no argument, <code>float()</code> returns 0.0. |
| |
| <!-- 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="float.x"> |
| <code>x</code> |
| </td> |
| <td> |
| default = unbound<br/> |
| The value to convert. |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="getattr">getattr</h2> |
| <p><pre class="rule-signature">unknown getattr(x, name, default=unbound)</pre></p> |
| |
| Returns the struct's field of the given name if it exists. If not, it either returns <code>default</code> (if specified) or raises an error. <code>getattr(x, "foobar")</code> is equivalent to <code>x.foobar</code>.<pre class="language-python">getattr(ctx.attr, "myattr") |
| getattr(ctx.attr, "myattr", "mydefault")</pre> |
| |
| <!-- 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="getattr.x"> |
| <code>x</code> |
| </td> |
| <td> |
| required<br/> |
| The struct whose attribute is accessed. |
| </td> |
| </tr> |
| <tr> |
| <td id="getattr.name"> |
| <code>name</code> |
| </td> |
| <td> |
| required<br/> |
| The name of the struct attribute. |
| </td> |
| </tr> |
| <tr> |
| <td id="getattr.default"> |
| <code>default</code> |
| </td> |
| <td> |
| default = unbound<br/> |
| The default value to return in case the struct doesn't have an attribute of the given name. |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="git_override">git_override</h2> |
| <p><pre class="rule-signature"><a class="anchor" href="globals.html#None">None</a> git_override(module_name, remote, commit='', patches=[], patch_cmds=[], patch_strip=0)</pre></p> |
| |
| Specifies that a dependency should come from a certain commit of a Git repository. This directive can only be used by the root module; in other words, if a module specifies any overrides, it cannot be used as a dependency by others. |
| |
| <!-- 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="git_override.module_name"> |
| <code>module_name</code> |
| </td> |
| <td> |
| required<br/> |
| The name of the Bazel module dependency to apply this override to. |
| </td> |
| </tr> |
| <tr> |
| <td id="git_override.remote"> |
| <code>remote</code> |
| </td> |
| <td> |
| required<br/> |
| The URL of the remote Git repository. |
| </td> |
| </tr> |
| <tr> |
| <td id="git_override.commit"> |
| <code>commit</code> |
| </td> |
| <td> |
| default = ''<br/> |
| The commit that should be checked out. |
| </td> |
| </tr> |
| <tr> |
| <td id="git_override.patches"> |
| <code>patches</code> |
| </td> |
| <td> |
| <code>Iterable of <a class="anchor" href="string.html">string</a>s</code>; |
| default = []<br/> |
| A list of labels pointing to patch files to apply for this module. The patch files must exist in the source tree of the top level project. They are applied in the list order. |
| </td> |
| </tr> |
| <tr> |
| <td id="git_override.patch_cmds"> |
| <code>patch_cmds</code> |
| </td> |
| <td> |
| <code>Iterable of <a class="anchor" href="string.html">string</a>s</code>; |
| default = []<br/> |
| Sequence of Bash commands to be applied on Linux/Macos after patches are applied. |
| </td> |
| </tr> |
| <tr> |
| <td id="git_override.patch_strip"> |
| <code>patch_strip</code> |
| </td> |
| <td> |
| default = 0<br/> |
| Same as the --strip argument of Unix patch. |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="hasattr">hasattr</h2> |
| <p><pre class="rule-signature"><a class="anchor" href="bool.html">bool</a> hasattr(x, name)</pre></p> |
| |
| Returns True if the object <code>x</code> has an attribute or method of the given <code>name</code>, otherwise False. Example:<br><pre class="language-python">hasattr(ctx.attr, "myattr")</pre> |
| |
| <!-- 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="hasattr.x"> |
| <code>x</code> |
| </td> |
| <td> |
| required<br/> |
| The object to check. |
| </td> |
| </tr> |
| <tr> |
| <td id="hasattr.name"> |
| <code>name</code> |
| </td> |
| <td> |
| required<br/> |
| The name of the attribute. |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="hash">hash</h2> |
| <p><pre class="rule-signature"><a class="anchor" href="int.html">int</a> hash(value)</pre></p> |
| |
| Return a hash value for a string. This is computed deterministically using the same algorithm as Java's <code>String.hashCode()</code>, namely: <pre class="language-python">s[0] * (31^(n-1)) + s[1] * (31^(n-2)) + ... + s[n-1]</pre> Hashing of values besides strings is not currently supported. |
| |
| <!-- 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="hash.value"> |
| <code>value</code> |
| </td> |
| <td> |
| required<br/> |
| String value to hash. |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="int">int</h2> |
| <p><pre class="rule-signature"><a class="anchor" href="int.html">int</a> int(x, base=unbound)</pre></p> |
| |
| Returns x as an int value.<ul><li>If <code>x</code> is already an int, <code>int</code> returns it unchanged.<li>If <code>x</code> is a bool, <code>int</code> returns 1 for True and 0 for False.<li>If <code>x</code> is a string, it must have the format <code><sign><prefix><digits></code>. <code><sign></code> is either <code>"+"</code>, <code>"-"</code>, or empty (interpreted as positive). <code><digits></code> are a sequence of digits from 0 up to <code>base</code> - 1, where the letters a-z (or equivalently, A-Z) are used as digits for 10-35. In the case where <code>base</code> is 2/8/16, <code><prefix></code> is optional and may be 0b/0o/0x (or equivalently, 0B/0O/0X) respectively; if the <code>base</code> is any other value besides these bases or the special value 0, the prefix must be empty. In the case where <code>base</code> is 0, the string is interpreted as an integer literal, in the sense that one of the bases 2/8/10/16 is chosen depending on which prefix if any is used. If <code>base</code> is 0, no prefix is used, and there is more than one digit, the leading digit cannot be 0; this is to avoid confusion between octal and decimal. The magnitude of the number represented by the string must be within the allowed range for the int type.<li>If <code>x</code> is a float, <code>int</code> returns the integer value of the float, rounding towards zero. It is an error if x is non-finite (NaN or infinity).</ul>This function fails if <code>x</code> is any other type, or if the value is a string not satisfying the above format. Unlike Python's <code>int</code> function, this function does not allow zero arguments, and does not allow extraneous whitespace for string arguments.<p>Examples:<pre class="language-python">int("123") == 123 |
| int("-123") == -123 |
| int("+123") == 123 |
| int("FF", 16) == 255 |
| int("0xFF", 16) == 255 |
| int("10", 0) == 10 |
| int("-0x10", 0) == -16 |
| int("-0x10", 0) == -16 |
| int("123.456") == 123 |
| </pre> |
| |
| <!-- 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.x"> |
| <code>x</code> |
| </td> |
| <td> |
| required<br/> |
| The string to convert. |
| </td> |
| </tr> |
| <tr> |
| <td id="int.base"> |
| <code>base</code> |
| </td> |
| <td> |
| default = unbound<br/> |
| The base used to interpret a string value; defaults to 10. Must be between 2 and 36 (inclusive), or 0 to detect the base as if <code>x</code> were an integer literal. This parameter must not be supplied if the value is not a string. |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="len">len</h2> |
| <p><pre class="rule-signature"><a class="anchor" href="int.html">int</a> len(x)</pre></p> |
| |
| Returns the length of a string, sequence (such as a list or tuple), dict, or other iterable. |
| |
| <!-- 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="len.x"> |
| <code>x</code> |
| </td> |
| <td> |
| required<br/> |
| The value whose length to report. |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="list">list</h2> |
| <p><pre class="rule-signature"><a class="anchor" href="list.html">list</a> list(x=[])</pre></p> |
| |
| Returns a new list with the same elements as the given iterable value.<pre class="language-python">list([1, 2]) == [1, 2] |
| list((2, 3, 2)) == [2, 3, 2] |
| list({5: "a", 2: "b", 4: "c"}) == [5, 2, 4]</pre> |
| |
| <!-- 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="list.x"> |
| <code>x</code> |
| </td> |
| <td> |
| default = []<br/> |
| The object to convert. |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="local_path_override">local_path_override</h2> |
| <p><pre class="rule-signature"><a class="anchor" href="globals.html#None">None</a> local_path_override(module_name, path)</pre></p> |
| |
| Specifies that a dependency should come from a certain directory on local disk. This directive can only be used by the root module; in other words, if a module specifies any overrides, it cannot be used as a dependency by others. |
| |
| <!-- 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="local_path_override.module_name"> |
| <code>module_name</code> |
| </td> |
| <td> |
| required<br/> |
| The name of the Bazel module dependency to apply this override to. |
| </td> |
| </tr> |
| <tr> |
| <td id="local_path_override.path"> |
| <code>path</code> |
| </td> |
| <td> |
| required<br/> |
| The path to the directory where this module is. |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="max">max</h2> |
| <p><pre class="rule-signature">unknown max(*args)</pre></p> |
| |
| Returns the largest one of all given arguments. If only one argument is provided, it must be a non-empty iterable.It is an error if elements are not comparable (for example int with string), or if no arguments are given. <pre class="language-python">max(2, 5, 4) == 5 |
| max([5, 6, 3]) == 6</pre> |
| |
| <!-- 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="max.args"> |
| <code>args</code> |
| </td> |
| <td> |
| required<br/> |
| The elements to be checked. |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="min">min</h2> |
| <p><pre class="rule-signature">unknown min(*args)</pre></p> |
| |
| Returns the smallest one of all given arguments. If only one argument is provided, it must be a non-empty iterable. It is an error if elements are not comparable (for example int with string), or if no arguments are given. <pre class="language-python">min(2, 5, 4) == 2 |
| min([5, 6, 3]) == 3</pre> |
| |
| <!-- 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="min.args"> |
| <code>args</code> |
| </td> |
| <td> |
| required<br/> |
| The elements to be checked. |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="module">module</h2> |
| <p><pre class="rule-signature"><a class="anchor" href="globals.html#None">None</a> module(name='', version='', compatibility_level=0, repo_name='', bazel_compatibility=[])</pre></p> |
| |
| Declares certain properties of the Bazel module represented by the current Bazel repo. These properties are either essential metadata of the module (such as the name and version), or affect behavior of the current module and its dependents. <p>It should be called at most once. It can be omitted only if this module is the root module (as in, if it's not going to be depended on by another module). |
| |
| <!-- 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="module.name"> |
| <code>name</code> |
| </td> |
| <td> |
| default = ''<br/> |
| The name of the module. Can be omitted only if this module is the root module (as in, if it's not going to be depended on by another module). A valid module name must: 1) only contain lowercase letters (a-z), digits (0-9), dots (.), hyphens (-), and underscores (_); 2) begin with a lowercase letter; 3) end with a lowercase letter or digit. |
| </td> |
| </tr> |
| <tr> |
| <td id="module.version"> |
| <code>version</code> |
| </td> |
| <td> |
| default = ''<br/> |
| The version of the module. Can be omitted only if this module is the root module (as in, if it's not going to be depended on by another module). |
| </td> |
| </tr> |
| <tr> |
| <td id="module.compatibility_level"> |
| <code>compatibility_level</code> |
| </td> |
| <td> |
| default = 0<br/> |
| The compatibility level of the module; this should be changed every time a major incompatible change is introduced. This is essentially the "major version" of the module in terms of SemVer, except that it's not embedded in the version string itself, but exists as a separate field. Modules with different compatibility levels participate in version resolution as if they're modules with different names, but the final dependency graph cannot contain multiple modules with the same name but different compatibility levels (unless <code>multiple_version_override</code> is in effect; see there for more details). |
| </td> |
| </tr> |
| <tr> |
| <td id="module.repo_name"> |
| <code>repo_name</code> |
| </td> |
| <td> |
| default = ''<br/> |
| The name of the repository representing this module, as seen by the module itself. By default, the name of the repo is the name of the module. This can be specified to ease migration for projects that have been using a repo name for itself that differs from its module name. |
| </td> |
| </tr> |
| <tr> |
| <td id="module.bazel_compatibility"> |
| <code>bazel_compatibility</code> |
| </td> |
| <td> |
| <code>Iterable of <a class="anchor" href="string.html">string</a>s</code>; |
| default = []<br/> |
| A list of bazel versions that allows users to declare which Bazel versions are compatible with this module. It does NOT affect dependency resolution, but bzlmod will use this information to check if your current Bazel version is compatible. The format of this value is a string of some constraint values separated by comma. Three constraints are supported: <=X.X.X: The Bazel version must be equal or older than X.X.X. Used when there is a known incompatible change in a newer version. >=X.X.X: The Bazel version must be equal or newer than X.X.X.Used when you depend on some features that are only available since X.X.X. -X.X.X: The Bazel version X.X.X is not compatible. Used when there is a bug in X.X.X that breaks you, but fixed in later versions. |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="module_extension">module_extension</h2> |
| <p><pre class="rule-signature">unknown module_extension(implementation, *, tag_classes={}, doc='')</pre></p> |
| |
| Creates a new module extension. Store it in a global value, so that it can be exported and used in a MODULE.bazel file. |
| |
| <!-- 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="module_extension.implementation"> |
| <code>implementation</code> |
| </td> |
| <td> |
| required<br/> |
| The function that implements this module extension. Must take a single parameter, <code><a href="module_ctx.html">module_ctx</a></code>. The function is called once at the beginning of a build to determine the set of available repos. |
| </td> |
| </tr> |
| <tr> |
| <td id="module_extension.tag_classes"> |
| <code>tag_classes</code> |
| </td> |
| <td> |
| default = {}<br/> |
| A dictionary to declare all the tag classes used by the extension. It maps from the name of the tag class to a <code><a href="tag_class.html">tag_class</a></code> object. |
| </td> |
| </tr> |
| <tr> |
| <td id="module_extension.doc"> |
| <code>doc</code> |
| </td> |
| <td> |
| default = ''<br/> |
| A description of the module extension that can be extracted by documentation generating tools. |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="multiple_version_override">multiple_version_override</h2> |
| <p><pre class="rule-signature"><a class="anchor" href="globals.html#None">None</a> multiple_version_override(module_name, versions, registry='')</pre></p> |
| |
| Specifies that a dependency should still come from a registry, but multiple versions of it should be allowed to coexist. This directive can only be used by the root module; in other words, if a module specifies any overrides, it cannot be used as a dependency by others. |
| |
| <!-- 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="multiple_version_override.module_name"> |
| <code>module_name</code> |
| </td> |
| <td> |
| required<br/> |
| The name of the Bazel module dependency to apply this override to. |
| </td> |
| </tr> |
| <tr> |
| <td id="multiple_version_override.versions"> |
| <code>versions</code> |
| </td> |
| <td> |
| <code>Iterable of <a class="anchor" href="string.html">string</a>s</code>; |
| required<br/> |
| Explicitly specifies the versions allowed to coexist. These versions must already be present in the dependency graph pre-selection. Dependencies on this module will be "upgraded" to the nearest higher allowed version at the same compatibility level, whereas dependencies that have a higher version than any allowed versions at the same compatibility level will cause an error. |
| </td> |
| </tr> |
| <tr> |
| <td id="multiple_version_override.registry"> |
| <code>registry</code> |
| </td> |
| <td> |
| default = ''<br/> |
| Overrides the registry for this module; instead of finding this module from the default list of registries, the given registry should be used. |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="print">print</h2> |
| <p><pre class="rule-signature"><a class="anchor" href="globals.html#None">None</a> print(sep=" ", *args)</pre></p> |
| |
| Prints <code>args</code> as debug output. It will be prefixed with the string <code>"DEBUG"</code> and the location (file and line number) of this call. The exact way in which the arguments are converted to strings is unspecified and may change at any time. In particular, it may be different from (and more detailed than) the formatting done by <a href='#str'><code>str()</code></a> and <a href='#repr'><code>repr()</code></a>.<p>Using <code>print</code> in production code is discouraged due to the spam it creates for users. For deprecations, prefer a hard error using <a href="#fail"><code>fail()</code></a> whenever possible. |
| |
| <!-- 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="print.sep"> |
| <code>sep</code> |
| </td> |
| <td> |
| default = " "<br/> |
| The separator string between the objects, default is space (" "). |
| </td> |
| </tr> |
| <tr> |
| <td id="print.args"> |
| <code>args</code> |
| </td> |
| <td> |
| required<br/> |
| The objects to print. |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="provider">provider</h2> |
| <p><pre class="rule-signature">unknown provider(doc='', *, fields=None, init=None)</pre></p> |
| |
| Defines a provider symbol. The provider may be instantiated by calling it, or used directly as a key for retrieving an instance of that provider from a target. Example:<br><pre class="language-python">MyInfo = provider() |
| ... |
| def _my_library_impl(ctx): |
| ... |
| my_info = MyInfo(x = 2, y = 3) |
| # my_info.x == 2 |
| # my_info.y == 3 |
| ...</pre><p>See <a href='https://bazel.build/versions/6.0.0/extending/rules#providers'>Rules (Providers)</a> for a comprehensive guide on how to use providers.<p>Returns a <a href='Provider.html#Provider'><code>Provider</code></a> callable value if <code>init</code> is not specified.<p>If <code>init</code> is specified, returns a tuple of 2 elements: a <a href='Provider.html#Provider'><code>Provider</code></a> callable value and a <em>raw constructor</em> callable value. See <a href='https://bazel.build/versions/6.0.0/extending/rules#custom_initialization_of_providers'>Rules (Custom initialization of custom providers)</a> and the discussion of the <code>init</code> parameter below for details. |
| |
| <!-- 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="provider.doc"> |
| <code>doc</code> |
| </td> |
| <td> |
| default = ''<br/> |
| A description of the provider that can be extracted by documentation generating tools. |
| </td> |
| </tr> |
| <tr> |
| <td id="provider.fields"> |
| <code>fields</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="dict.html">dict</a>; or <a class="anchor" href="globals.html#None">None</a></code>; |
| default = None<br/> |
| If specified, restricts the set of allowed fields. <br>Possible values are:<ul> <li> list of fields:<br> <pre class="language-python">provider(fields = ['a', 'b'])</pre><p> <li> dictionary field name -> documentation:<br> <pre class="language-python">provider( |
| fields = { 'a' : 'Documentation for a', 'b' : 'Documentation for b' })</pre></ul>All fields are optional. |
| </td> |
| </tr> |
| <tr> |
| <td id="provider.init"> |
| <code>init</code> |
| </td> |
| <td> |
| <code>callable; or <a class="anchor" href="globals.html#None">None</a></code>; |
| default = None<br/> |
| An optional callback for preprocessing and validating the provider's field values during instantiation. If <code>init</code> is specified, <code>provider()</code> returns a tuple of 2 elements: the normal provider symbol and a <em>raw constructor</em>.<p>A precise description follows; see <a href='https://bazel.build/versions/6.0.0/extending/rules#custom_initialization_of_providers'>Rules (Custom initialization of providers)</a> for an intuitive discussion and use cases.<p>Let <code>P</code> be the provider symbol created by calling <code>provider()</code>. Conceptually, an instance of <code>P</code> is generated by calling a default constructor function <code>c(*args, **kwargs)</code>, which does the following:<ul><li>If <code>args</code> is non-empty, an error occurs.</li><li>If the <code>fields</code> parameter was specified when <code>provider()</code> was called, and if <code>kwargs</code> contains any key that was not listed in <code>fields</code>, an error occurs.</li><li>Otherwise, <code>c</code> returns a new instance that has, for each <code>k: v</code> entry in <code>kwargs</code>, a field named <code>k</code> with value <code>v</code>.</ul>In the case where an <code>init</code> callback is <em>not</em> given, a call to the symbol <code>P</code> itself acts as a call to the default constructor function <code>c</code>; in other words, <code>P(*args, **kwargs)</code> returns <code>c(*args, **kwargs)</code>. For example,<pre class="language-python">MyInfo = provider() |
| m = MyInfo(foo = 1)</pre>will straightforwardly make it so that <code>m</code> is a <code>MyInfo</code> instance with <code>m.foo == 1</code>.<p>But in the case where <code>init</code> is specified, the call <code>P(*args, **kwargs)</code> will perform the following steps instead:<ol><li>The callback is invoked as <code>init(*args, **kwargs)</code>, that is, with the exact same positional and keyword arguments as were passed to <code>P</code>.</li><li>The return value of <code>init</code> is expected to be a dictionary, <code>d</code>, whose keys are field name strings. If it is not, an error occurs.</li><li>A new instance of <code>P</code> is generated as if by calling the default constructor with <code>d</code>'s entries as keyword arguments, as in <code>c(**d)</code>.</li></ol><p>NB: the above steps imply that an error occurs if <code>*args</code> or <code>**kwargs</code> does not match <code>init</code>'s signature, or the evaluation of <code>init</code>'s body fails (perhaps intentionally via a call to <a href="#fail"><code>fail()</code></a>), or if the return value of <code>init</code> is not a dictionary with the expected schema.<p>In this way, the <code>init</code> callback generalizes normal provider construction by allowing positional arguments and arbitrary logic for preprocessing and validation. It does <em>not</em> enable circumventing the list of allowed <code>fields</code>.<p>When <code>init</code> is specified, the return value of <code>provider()</code> becomes a tuple <code>(P, r)</code>, where <code>r</code> is the <em>raw constructor</em>. In fact, the behavior of <code>r</code> is exactly that of the default constructor function <code>c</code> discussed above. Typically, <code>r</code> is bound to a variable whose name is prefixed with an underscore, so that only the current .bzl file has direct access to it:<pre class="language-python">MyInfo, _new_myinfo = provider(init = ...)</pre> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="range">range</h2> |
| <p><pre class="rule-signature"><a class="anchor" href="list.html">sequence</a> range(start_or_stop, stop_or_none=None, step=1)</pre></p> |
| |
| Creates a list where items go from <code>start</code> to <code>stop</code>, using a <code>step</code> increment. If a single argument is provided, items will range from 0 to that element.<pre class="language-python">range(4) == [0, 1, 2, 3] |
| range(3, 9, 2) == [3, 5, 7] |
| range(3, 0, -1) == [3, 2, 1]</pre> |
| |
| <!-- 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="range.start_or_stop"> |
| <code>start_or_stop</code> |
| </td> |
| <td> |
| required<br/> |
| Value of the start element if stop is provided, otherwise value of stop and the actual start is 0 |
| </td> |
| </tr> |
| <tr> |
| <td id="range.stop_or_none"> |
| <code>stop_or_none</code> |
| </td> |
| <td> |
| <code><a class="anchor" href="int.html">int</a>; or <a class="anchor" href="globals.html#None">None</a></code>; |
| default = None<br/> |
| optional index of the first item <i>not</i> to be included in the resulting list; generation of the list stops before <code>stop</code> is reached. |
| </td> |
| </tr> |
| <tr> |
| <td id="range.step"> |
| <code>step</code> |
| </td> |
| <td> |
| default = 1<br/> |
| The increment (default is 1). It may be negative. |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="register_execution_platforms()">register_execution_platforms()</h2> |
| <p><pre class="rule-signature"><a class="anchor" href="globals.html#None">None</a> register_execution_platforms(*platform_labels)</pre></p> |
| |
| Register an already-defined platform so that Bazel can use it as an <a href="/versions/6.0.0/extending/toolchains#toolchain-resolution">execution platform</a> during <a href="/versions/6.0.0/extending/toolchains">toolchain resolution</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="register_execution_platforms().platform_labels"> |
| <code>platform_labels</code> |
| </td> |
| <td> |
| <code><a class="anchor" href="list.html">sequence</a> of <a class="anchor" href="string.html">string</a>s</code>; |
| required<br/> |
| The labels of the platforms to register. |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="register_execution_platforms()">register_execution_platforms()</h2> |
| <p><pre class="rule-signature"><a class="anchor" href="globals.html#None">None</a> register_execution_platforms(*platform_labels)</pre></p> |
| |
| Specifies already-defined execution platforms to be registered when this module is selected. Should be absolute target patterns (ie. beginning with either <code>@</code> or <code>//</code>). See <a href="/versions/6.0.0/extending/toolchains">toolchain resolution</a> 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="register_execution_platforms().platform_labels"> |
| <code>platform_labels</code> |
| </td> |
| <td> |
| <code><a class="anchor" href="list.html">sequence</a> of <a class="anchor" href="string.html">string</a>s</code>; |
| required<br/> |
| The labels of the platforms to register. |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="register_toolchains()">register_toolchains()</h2> |
| <p><pre class="rule-signature"><a class="anchor" href="globals.html#None">None</a> register_toolchains(*toolchain_labels)</pre></p> |
| |
| Register an already-defined toolchain so that Bazel can use it during <a href="/versions/6.0.0/extending/toolchains">toolchain resolution</a>. See examples of <a href="/versions/6.0.0/extending/toolchains#defining-toolchains">defining</a> and <a href="/versions/6.0.0/extending/toolchains#registering-and-building-with-toolchains">registering toolchains</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="register_toolchains().toolchain_labels"> |
| <code>toolchain_labels</code> |
| </td> |
| <td> |
| <code><a class="anchor" href="list.html">sequence</a> of <a class="anchor" href="string.html">string</a>s</code>; |
| required<br/> |
| The labels of the toolchains to register. |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="register_toolchains()">register_toolchains()</h2> |
| <p><pre class="rule-signature"><a class="anchor" href="globals.html#None">None</a> register_toolchains(*toolchain_labels)</pre></p> |
| |
| Specifies already-defined toolchains to be registered when this module is selected. Should be absolute target patterns (ie. beginning with either <code>@</code> or <code>//</code>). See <a href="/versions/6.0.0/extending/toolchains">toolchain resolution</a> 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="register_toolchains().toolchain_labels"> |
| <code>toolchain_labels</code> |
| </td> |
| <td> |
| <code><a class="anchor" href="list.html">sequence</a> of <a class="anchor" href="string.html">string</a>s</code>; |
| required<br/> |
| The labels of the toolchains to register. |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="repository_rule(implementation, attrs, local, environ, configure, remotable, doc)">repository_rule(implementation, attrs, local, environ, configure, remotable, doc)</h2> |
| <p><pre class="rule-signature">callable repository_rule(implementation, *, attrs=None, local=False, environ=[], configure=False, remotable=False, doc='')</pre></p> |
| |
| Creates a new repository rule. Store it in a global value, so that it can be loaded and called from the WORKSPACE file. |
| |
| <!-- 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="repository_rule(implementation, attrs, local, environ, configure, remotable, doc).implementation"> |
| <code>implementation</code> |
| </td> |
| <td> |
| required<br/> |
| the function that implements this rule. Must have a single parameter, <code><a href="repository_ctx.html">repository_ctx</a></code>. The function is called during the loading phase for each instance of the rule. |
| </td> |
| </tr> |
| <tr> |
| <td id="repository_rule(implementation, attrs, local, environ, configure, remotable, doc).attrs"> |
| <code>attrs</code> |
| </td> |
| <td> |
| <code><a class="anchor" href="dict.html">dict</a>; or <a class="anchor" href="globals.html#None">None</a></code>; |
| default = None<br/> |
| dictionary to declare all the attributes of the rule. It maps from an attribute name to an attribute object (see <a href="attr.html">attr</a> module). Attributes starting with <code>_</code> are private, and can be used to add an implicit dependency on a label to a file (a repository rule cannot depend on a generated artifact). The attribute <code>name</code> is implicitly added and must not be specified. |
| </td> |
| </tr> |
| <tr> |
| <td id="repository_rule(implementation, attrs, local, environ, configure, remotable, doc).local"> |
| <code>local</code> |
| </td> |
| <td> |
| default = False<br/> |
| Indicate that this rule fetches everything from the local system and should be reevaluated at every fetch. |
| </td> |
| </tr> |
| <tr> |
| <td id="repository_rule(implementation, attrs, local, environ, configure, remotable, doc).environ"> |
| <code>environ</code> |
| </td> |
| <td> |
| <code><a class="anchor" href="list.html">sequence</a> of <a class="anchor" href="string.html">string</a>s</code>; |
| default = []<br/> |
| Provides a list of environment variable that this repository rule depends on. If an environment variable in that list change, the repository will be refetched. |
| </td> |
| </tr> |
| <tr> |
| <td id="repository_rule(implementation, attrs, local, environ, configure, remotable, doc).configure"> |
| <code>configure</code> |
| </td> |
| <td> |
| default = False<br/> |
| Indicate that the repository inspects the system for configuration purpose |
| </td> |
| </tr> |
| <tr> |
| <td id="repository_rule(implementation, attrs, local, environ, configure, remotable, doc).remotable"> |
| <code>remotable</code> |
| </td> |
| <td> |
| default = False<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_repo_remote_exec</code> <br>Compatible with remote execution |
| </td> |
| </tr> |
| <tr> |
| <td id="repository_rule(implementation, attrs, local, environ, configure, remotable, doc).doc"> |
| <code>doc</code> |
| </td> |
| <td> |
| default = ''<br/> |
| A description of the repository rule that can be extracted by documentation generating tools. |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="repository_rule(implementation, attrs, local, environ, configure, remotable, doc)">repository_rule(implementation, attrs, local, environ, configure, remotable, doc)</h2> |
| <p><pre class="rule-signature">callable repository_rule(implementation, *, attrs=None, local=False, environ=[], configure=False, remotable=False, doc='')</pre></p> |
| |
| Creates a new repository rule. Store it in a global value, so that it can be loaded and called from the WORKSPACE file. |
| |
| <!-- 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="repository_rule(implementation, attrs, local, environ, configure, remotable, doc).implementation"> |
| <code>implementation</code> |
| </td> |
| <td> |
| required<br/> |
| the function that implements this rule. Must have a single parameter, <code><a href="repository_ctx.html">repository_ctx</a></code>. The function is called during the loading phase for each instance of the rule. |
| </td> |
| </tr> |
| <tr> |
| <td id="repository_rule(implementation, attrs, local, environ, configure, remotable, doc).attrs"> |
| <code>attrs</code> |
| </td> |
| <td> |
| <code><a class="anchor" href="dict.html">dict</a>; or <a class="anchor" href="globals.html#None">None</a></code>; |
| default = None<br/> |
| dictionary to declare all the attributes of the rule. It maps from an attribute name to an attribute object (see <a href="attr.html">attr</a> module). Attributes starting with <code>_</code> are private, and can be used to add an implicit dependency on a label to a file (a repository rule cannot depend on a generated artifact). The attribute <code>name</code> is implicitly added and must not be specified. |
| </td> |
| </tr> |
| <tr> |
| <td id="repository_rule(implementation, attrs, local, environ, configure, remotable, doc).local"> |
| <code>local</code> |
| </td> |
| <td> |
| default = False<br/> |
| Indicate that this rule fetches everything from the local system and should be reevaluated at every fetch. |
| </td> |
| </tr> |
| <tr> |
| <td id="repository_rule(implementation, attrs, local, environ, configure, remotable, doc).environ"> |
| <code>environ</code> |
| </td> |
| <td> |
| <code><a class="anchor" href="list.html">sequence</a> of <a class="anchor" href="string.html">string</a>s</code>; |
| default = []<br/> |
| Provides a list of environment variable that this repository rule depends on. If an environment variable in that list change, the repository will be refetched. |
| </td> |
| </tr> |
| <tr> |
| <td id="repository_rule(implementation, attrs, local, environ, configure, remotable, doc).configure"> |
| <code>configure</code> |
| </td> |
| <td> |
| default = False<br/> |
| Indicate that the repository inspects the system for configuration purpose |
| </td> |
| </tr> |
| <tr> |
| <td id="repository_rule(implementation, attrs, local, environ, configure, remotable, doc).remotable"> |
| <code>remotable</code> |
| </td> |
| <td> |
| default = False<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_repo_remote_exec</code> <br>Compatible with remote execution |
| </td> |
| </tr> |
| <tr> |
| <td id="repository_rule(implementation, attrs, local, environ, configure, remotable, doc).doc"> |
| <code>doc</code> |
| </td> |
| <td> |
| default = ''<br/> |
| A description of the repository rule that can be extracted by documentation generating tools. |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="repr">repr</h2> |
| <p><pre class="rule-signature"><a class="anchor" href="string.html">string</a> repr(x)</pre></p> |
| |
| Converts any object to a string representation. This is useful for debugging.<br><pre class="language-python">repr("ab") == '"ab"'</pre> |
| |
| <!-- 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="repr.x"> |
| <code>x</code> |
| </td> |
| <td> |
| required<br/> |
| The object to convert. |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="reversed">reversed</h2> |
| <p><pre class="rule-signature"><a class="anchor" href="list.html">list</a> reversed(sequence)</pre></p> |
| |
| Returns a new, unfrozen list that contains the elements of the original iterable sequence in reversed order.<pre class="language-python">reversed([3, 5, 4]) == [4, 5, 3]</pre> |
| |
| <!-- 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="reversed.sequence"> |
| <code>sequence</code> |
| </td> |
| <td> |
| required<br/> |
| The iterable sequence (e.g. list) to be reversed. |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="rule">rule</h2> |
| <p><pre class="rule-signature">callable rule(implementation, test=False, attrs=None, outputs=None, executable=False, output_to_genfiles=False, fragments=[], host_fragments=[], _skylark_testable=False, toolchains=[], incompatible_use_toolchain_transition=False, doc='', *, provides=[], exec_compatible_with=[], analysis_test=False, build_setting=None, cfg=None, exec_groups=None, compile_one_filetype=None, name=None)</pre></p> |
| |
| Creates a new rule, which can be called from a BUILD file or a macro to create targets.<p>Rules must be assigned to global variables in a .bzl file; the name of the global variable is the rule's name.<p>Test rules are required to have a name ending in <code>_test</code>, while all other rules must not have this suffix. (This restriction applies only to rules, not to their targets.) |
| |
| <!-- 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="rule.implementation"> |
| <code>implementation</code> |
| </td> |
| <td> |
| required<br/> |
| the Starlark function implementing this rule, must have exactly one parameter: <a href="ctx.html">ctx</a>. The function is called during the analysis phase for each instance of the rule. It can access the attributes provided by the user. It must create actions to generate all the declared outputs. |
| </td> |
| </tr> |
| <tr> |
| <td id="rule.test"> |
| <code>test</code> |
| </td> |
| <td> |
| default = False<br/> |
| Whether this rule is a test rule, that is, whether it may be the subject of a <code>blaze test</code> command. All test rules are automatically considered <a href='#rule.executable'>executable</a>; it is unnecessary (and discouraged) to explicitly set <code>executable = True</code> for a test rule. See the <a href='https://bazel.build/versions/6.0.0/extending/rules#executable_rules_and_test_rules'> Rules page</a> for more information. |
| </td> |
| </tr> |
| <tr> |
| <td id="rule.attrs"> |
| <code>attrs</code> |
| </td> |
| <td> |
| <code><a class="anchor" href="dict.html">dict</a>; or <a class="anchor" href="globals.html#None">None</a></code>; |
| default = None<br/> |
| dictionary to declare all the attributes of the rule. It maps from an attribute name to an attribute object (see <a href="attr.html">attr</a> module). Attributes starting with <code>_</code> are private, and can be used to add an implicit dependency on a label. The attribute <code>name</code> is implicitly added and must not be specified. Attributes <code>visibility</code>, <code>deprecation</code>, <code>tags</code>, <code>testonly</code>, and <code>features</code> are implicitly added and cannot be overridden. Most rules need only a handful of attributes. To limit memory usage, the rule function imposes a cap on the size of attrs. |
| </td> |
| </tr> |
| <tr> |
| <td id="rule.outputs"> |
| <code>outputs</code> |
| </td> |
| <td> |
| <code><a class="anchor" href="dict.html">dict</a>; or <a class="anchor" href="globals.html#None">None</a>; or <a class="anchor" href="function.html">function</a></code>; |
| default = None<br/> |
| <b>Deprecated</b>. This parameter is deprecated and will be removed soon. Please do not depend on it. It is <i>disabled</i> with <code>---incompatible_no_rule_outputs_param</code>. Use this flag to verify your code is compatible with its imminent removal. <br>This parameter has been deprecated. Migrate rules to use <code>OutputGroupInfo</code> or <code>attr.output</code> instead. <p>A schema for defining predeclared outputs. Unlike <a href='attr.html#output'><code>output</code></a> and <a href='attr.html#output_list'><code>output_list</code></a> attributes, the user does not specify the labels for these files. See the <a href='https://bazel.build/versions/6.0.0/extending/rules#files'>Rules page</a> for more on predeclared outputs.<p>The value of this argument is either a dictionary or a callback function that produces a dictionary. The callback works similar to computed dependency attributes: The function's parameter names are matched against the rule's attributes, so for example if you pass <code>outputs = _my_func</code> with the definition <code>def _my_func(srcs, deps): ...</code>, the function has access to the attributes <code>srcs</code> and <code>deps</code>. Whether the dictionary is specified directly or via a function, it is interpreted as follows.<p>Each entry in the dictionary creates a predeclared output where the key is an identifier and the value is a string template that determines the output's label. In the rule's implementation function, the identifier becomes the field name used to access the output's <a href='File.html'><code>File</code></a> in <a href='ctx.html#outputs'><code>ctx.outputs</code></a>. The output's label has the same package as the rule, and the part after the package is produced by substituting each placeholder of the form <code>"%{ATTR}"</code> with a string formed from the value of the attribute <code>ATTR</code>:<ul><li>String-typed attributes are substituted verbatim.<li>Label-typed attributes become the part of the label after the package, minus the file extension. For example, the label <code>"//pkg:a/b.c"</code> becomes <code>"a/b"</code>.<li>Output-typed attributes become the part of the label after the package, including the file extension (for the above example, <code>"a/b.c"</code>).<li>All list-typed attributes (for example, <code>attr.label_list</code>) used in placeholders are required to have <i>exactly one element</i>. Their conversion is the same as their non-list version (<code>attr.label</code>).<li>Other attribute types may not appear in placeholders.<li>The special non-attribute placeholders <code>%{dirname}</code> and <code>%{basename}</code> expand to those parts of the rule's label, excluding its package. For example, in <code>"//pkg:a/b.c"</code>, the dirname is <code>a</code> and the basename is <code>b.c</code>.</ul><p>In practice, the most common substitution placeholder is <code>"%{name}"</code>. For example, for a target named "foo", the outputs dict <code>{"bin": "%{name}.exe"}</code> predeclares an output named <code>foo.exe</code> that is accessible in the implementation function as <code>ctx.outputs.bin</code>. |
| </td> |
| </tr> |
| <tr> |
| <td id="rule.executable"> |
| <code>executable</code> |
| </td> |
| <td> |
| default = False<br/> |
| Whether this rule is considered executable, that is, whether it may be the subject of a <code>blaze run</code> command. See the <a href='https://bazel.build/versions/6.0.0/extending/rules#executable_rules_and_test_rules'> Rules page</a> for more information. |
| </td> |
| </tr> |
| <tr> |
| <td id="rule.output_to_genfiles"> |
| <code>output_to_genfiles</code> |
| </td> |
| <td> |
| default = False<br/> |
| If true, the files will be generated in the genfiles directory instead of the bin directory. Unless you need it for compatibility with existing rules (e.g. when generating header files for C++), do not set this flag. |
| </td> |
| </tr> |
| <tr> |
| <td id="rule.fragments"> |
| <code>fragments</code> |
| </td> |
| <td> |
| <code><a class="anchor" href="list.html">sequence</a> of <a class="anchor" href="string.html">string</a>s</code>; |
| default = []<br/> |
| List of names of configuration fragments that the rule requires in target configuration. |
| </td> |
| </tr> |
| <tr> |
| <td id="rule.host_fragments"> |
| <code>host_fragments</code> |
| </td> |
| <td> |
| <code><a class="anchor" href="list.html">sequence</a> of <a class="anchor" href="string.html">string</a>s</code>; |
| default = []<br/> |
| List of names of configuration fragments that the rule requires in host configuration. |
| </td> |
| </tr> |
| <tr> |
| <td id="rule._skylark_testable"> |
| <code>_skylark_testable</code> |
| </td> |
| <td> |
| default = False<br/> |
| <i>(Experimental)</i><br/><br/>If true, this rule will expose its actions for inspection by rules that depend on it via an <a href="globals.html#Actions">Actions</a> provider. The provider is also available to the rule itself by calling <a href="ctx.html#created_actions">ctx.created_actions()</a>.<br/><br/>This should only be used for testing the analysis-time behavior of Starlark rules. This flag may be removed in the future. |
| </td> |
| </tr> |
| <tr> |
| <td id="rule.toolchains"> |
| <code>toolchains</code> |
| </td> |
| <td> |
| <code><a class="anchor" href="list.html">sequence</a></code>; |
| default = []<br/> |
| If set, the set of toolchains this rule requires. The list can contain String, Label, or StarlarkToolchainTypeApi objects, in any combination. Toolchains will be found by checking the current platform, and provided to the rule implementation via <code>ctx.toolchain</code>. |
| </td> |
| </tr> |
| <tr> |
| <td id="rule.incompatible_use_toolchain_transition"> |
| <code>incompatible_use_toolchain_transition</code> |
| </td> |
| <td> |
| default = False<br/> |
| Deprecated, this is no longer in use and should be removed. |
| </td> |
| </tr> |
| <tr> |
| <td id="rule.doc"> |
| <code>doc</code> |
| </td> |
| <td> |
| default = ''<br/> |
| A description of the rule that can be extracted by documentation generating tools. |
| </td> |
| </tr> |
| <tr> |
| <td id="rule.provides"> |
| <code>provides</code> |
| </td> |
| <td> |
| default = []<br/> |
| A list of providers that the implementation function must return.<p>It is an error if the implementation function omits any of the types of providers listed here from its return value. However, the implementation function may return additional providers not listed here.<p>Each element of the list is an <code>*Info</code> object returned by <a href='globals.html#provider'><code>provider()</code></a>, except that a legacy provider is represented by its string name instead. |
| </td> |
| </tr> |
| <tr> |
| <td id="rule.exec_compatible_with"> |
| <code>exec_compatible_with</code> |
| </td> |
| <td> |
| <code><a class="anchor" href="list.html">sequence</a> of <a class="anchor" href="string.html">string</a>s</code>; |
| default = []<br/> |
| A list of constraints on the execution platform that apply to all targets of this rule type. |
| </td> |
| </tr> |
| <tr> |
| <td id="rule.analysis_test"> |
| <code>analysis_test</code> |
| </td> |
| <td> |
| default = False<br/> |
| If true, then this rule is treated as an analysis test. <p>Note: Analysis test rules are primarily defined using infrastructure provided in core Starlark libraries. See <a href="https://bazel.build/versions/6.0.0/rules/testing#testing-rules">Testing</a> for guidance. <p>If a rule is defined as an analysis test rule, it becomes allowed to use configuration transitions defined using <a href="#analysis_test_transition">analysis_test_transition</a> on its attributes, but opts into some restrictions: <ul><li>Targets of this rule are limited in the number of transitive dependencies they may have. <li>The rule is considered a test rule (as if <code>test=True</code> were set). This supersedes the value of <code>test</code></li> <li>The rule implementation function may not register actions. Instead, it must register a pass/fail result via providing <a href='AnalysisTestResultInfo.html'>AnalysisTestResultInfo</a>.</li></ul> |
| </td> |
| </tr> |
| <tr> |
| <td id="rule.build_setting"> |
| <code>build_setting</code> |
| </td> |
| <td> |
| <code><a class="anchor" href="BuildSetting.html">BuildSetting</a>; or <a class="anchor" href="globals.html#None">None</a></code>; |
| default = None<br/> |
| If set, describes what kind of <a href = '/versions/6.0.0/extending/config#user-defined-build-settings'><code>build setting</code></a> this rule is. See the <a href='config.html'><code>config</code></a> module. If this is set, a mandatory attribute named "build_setting_default" is automatically added to this rule, with a type corresponding to the value passed in here. |
| </td> |
| </tr> |
| <tr> |
| <td id="rule.cfg"> |
| <code>cfg</code> |
| </td> |
| <td> |
| default = None<br/> |
| If set, points to the configuration transition the rule will apply to its own configuration before analysis. |
| </td> |
| </tr> |
| <tr> |
| <td id="rule.exec_groups"> |
| <code>exec_groups</code> |
| </td> |
| <td> |
| <code><a class="anchor" href="dict.html">dict</a>; or <a class="anchor" href="globals.html#None">None</a></code>; |
| default = None<br/> |
| Dict of execution group name (string) to <a href='globals.html#exec_group'><code>exec_group</code>s</a>. If set, allows rules to run actions on multiple execution platforms within a single target. See <a href='/versions/6.0.0/extending/exec-groups'>execution groups documentation</a> for more info. |
| </td> |
| </tr> |
| <tr> |
| <td id="rule.compile_one_filetype"> |
| <code>compile_one_filetype</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<br/> |
| Used by --compile_one_dependency: if multiple rules consume the specified file, should we choose this rule over others. |
| </td> |
| </tr> |
| <tr> |
| <td id="rule.name"> |
| <code>name</code> |
| </td> |
| <td> |
| <code><a class="anchor" href="string.html">string</a>; or <a class="anchor" href="globals.html#None">None</a></code>; |
| default = None<br/> |
| <b>Deprecated</b>. This parameter is deprecated and will be removed soon. Please do not depend on it. It is <i>disabled</i> with <code>--+incompatible_remove_rule_name_parameter</code>. Use this flag to verify your code is compatible with its imminent removal. <br>Deprecated: do not use.<p>The name of this rule, as understood by Bazel and reported in contexts such as logging, <code>native.existing_rule(...)[kind]</code>, and <code>bazel query</code>. Usually this is the same as the Starlark identifier that gets bound to this rule; for instance a rule called <code>foo_library</code> would typically be declared as <code>foo_library = rule(...)</code> and instantiated in a BUILD file as <code>foo_library(...)</code>.<p>If this parameter is omitted, the rule's name is set to the name of the first Starlark global variable to be bound to this rule within its declaring .bzl module. Thus, <code>foo_library = rule(...)</code> need not specify this parameter if the name is <code>foo_library</code>.<p>Specifying an explicit name for a rule does not change where you are allowed to instantiate the rule. |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="select">select</h2> |
| <p><pre class="rule-signature">unknown select(x, no_match_error='')</pre></p> |
| |
| <code>select()</code> is the helper function that makes a rule attribute <a href="/versions/6.0.0/reference/be/common-definitions#configurable-attributes">configurable</a>. See <a href="/versions/6.0.0/reference/be/functions#select">build encyclopedia</a> for details. |
| |
| <!-- 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="select.x"> |
| <code>x</code> |
| </td> |
| <td> |
| required<br/> |
| A dict that maps configuration conditions to values. Each key is a <a href="Label.html">Label</a> or a label string that identifies a config_setting or constraint_value instance. See the <a href="https://bazel.build/versions/6.0.0/extending/macros#label-resolution">documentation on macros</a> for when to use a Label instead of a string. |
| </td> |
| </tr> |
| <tr> |
| <td id="select.no_match_error"> |
| <code>no_match_error</code> |
| </td> |
| <td> |
| default = ''<br/> |
| Optional custom error to report if no condition matches. |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="single_version_override">single_version_override</h2> |
| <p><pre class="rule-signature"><a class="anchor" href="globals.html#None">None</a> single_version_override(module_name, version='', registry='', patches=[], patch_cmds=[], patch_strip=0)</pre></p> |
| |
| Specifies that a dependency should still come from a registry, but its version should be pinned, or its registry overridden, or a list of patches applied. This directive can only be used by the root module; in other words, if a module specifies any overrides, it cannot be used as a dependency by others. |
| |
| <!-- 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="single_version_override.module_name"> |
| <code>module_name</code> |
| </td> |
| <td> |
| required<br/> |
| The name of the Bazel module dependency to apply this override to. |
| </td> |
| </tr> |
| <tr> |
| <td id="single_version_override.version"> |
| <code>version</code> |
| </td> |
| <td> |
| default = ''<br/> |
| Overrides the declared version of this module in the dependency graph. In other words, this module will be "pinned" to this override version. This attribute can be omitted if all one wants to override is the registry or the patches. |
| </td> |
| </tr> |
| <tr> |
| <td id="single_version_override.registry"> |
| <code>registry</code> |
| </td> |
| <td> |
| default = ''<br/> |
| Overrides the registry for this module; instead of finding this module from the default list of registries, the given registry should be used. |
| </td> |
| </tr> |
| <tr> |
| <td id="single_version_override.patches"> |
| <code>patches</code> |
| </td> |
| <td> |
| <code>Iterable of <a class="anchor" href="string.html">string</a>s</code>; |
| default = []<br/> |
| A list of labels pointing to patch files to apply for this module. The patch files must exist in the source tree of the top level project. They are applied in the list order. |
| </td> |
| </tr> |
| <tr> |
| <td id="single_version_override.patch_cmds"> |
| <code>patch_cmds</code> |
| </td> |
| <td> |
| <code>Iterable of <a class="anchor" href="string.html">string</a>s</code>; |
| default = []<br/> |
| Sequence of Bash commands to be applied on Linux/Macos after patches are applied. |
| </td> |
| </tr> |
| <tr> |
| <td id="single_version_override.patch_strip"> |
| <code>patch_strip</code> |
| </td> |
| <td> |
| default = 0<br/> |
| Same as the --strip argument of Unix patch. |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="sorted">sorted</h2> |
| <p><pre class="rule-signature"><a class="anchor" href="list.html">list</a> sorted(iterable, *, key=None, reverse=False)</pre></p> |
| |
| Returns a new sorted list containing all the elements of the supplied iterable sequence. An error may occur if any pair of elements x, y may not be compared using x < y. The elements are sorted into ascending order, unless the reverse argument is True, in which case the order is descending. |
| Sorting is stable: elements that compare equal retain their original relative order. |
| <pre class="language-python">sorted([3, 5, 4]) == [3, 4, 5]</pre> |
| |
| <!-- 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="sorted.iterable"> |
| <code>iterable</code> |
| </td> |
| <td> |
| required<br/> |
| The iterable sequence to sort. |
| </td> |
| </tr> |
| <tr> |
| <td id="sorted.key"> |
| <code>key</code> |
| </td> |
| <td> |
| default = None<br/> |
| An optional function applied to each element before comparison. |
| </td> |
| </tr> |
| <tr> |
| <td id="sorted.reverse"> |
| <code>reverse</code> |
| </td> |
| <td> |
| default = False<br/> |
| Return results in descending order. |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="str">str</h2> |
| <p><pre class="rule-signature"><a class="anchor" href="string.html">string</a> str(x)</pre></p> |
| |
| Converts any object to string. This is useful for debugging.<pre class="language-python">str("ab") == "ab" |
| str(8) == "8"</pre> |
| |
| <!-- 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="str.x"> |
| <code>x</code> |
| </td> |
| <td> |
| required<br/> |
| The object to convert. |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="tag_class">tag_class</h2> |
| <p><pre class="rule-signature"><a class="anchor" href="tag_class.html">tag_class</a> tag_class(attrs={}, *, doc='')</pre></p> |
| |
| Creates a new tag_class object, which defines an attribute schema for a class of tags, which are data objects usable by a module extension. |
| |
| <!-- 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="tag_class.attrs"> |
| <code>attrs</code> |
| </td> |
| <td> |
| default = {}<br/> |
| A dictionary to declare all the attributes of this tag class. It maps from an attribute name to an attribute object (see <a href="attr.html">attr</a> module). |
| </td> |
| </tr> |
| <tr> |
| <td id="tag_class.doc"> |
| <code>doc</code> |
| </td> |
| <td> |
| default = ''<br/> |
| A description of the tag class that can be extracted by documentation generating tools. |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="tuple">tuple</h2> |
| <p><pre class="rule-signature"><a class="anchor" href="tuple.html">tuple</a> tuple(x=())</pre></p> |
| |
| Returns a tuple with the same elements as the given iterable value.<pre class="language-python">tuple([1, 2]) == (1, 2) |
| tuple((2, 3, 2)) == (2, 3, 2) |
| tuple({5: "a", 2: "b", 4: "c"}) == (5, 2, 4)</pre> |
| |
| <!-- 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="tuple.x"> |
| <code>x</code> |
| </td> |
| <td> |
| default = ()<br/> |
| The object to convert. |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="type">type</h2> |
| <p><pre class="rule-signature"><a class="anchor" href="string.html">string</a> type(x)</pre></p> |
| |
| Returns the type name of its argument. This is useful for debugging and type-checking. Examples:<pre class="language-python">type(2) == "int" |
| type([1]) == "list" |
| type(struct(a = 2)) == "struct"</pre>This function might change in the future. To write Python-compatible code and be future-proof, use it only to compare return values: <pre class="language-python">if type(x) == type([]): # if x is a list</pre> |
| |
| <!-- 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="type.x"> |
| <code>x</code> |
| </td> |
| <td> |
| required<br/> |
| The object to check type of. |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="use_extension">use_extension</h2> |
| <p><pre class="rule-signature">module_extension_proxy use_extension(extension_bzl_file, extension_name, *, dev_dependency=False)</pre></p> |
| |
| Returns a proxy object representing a module extension; its methods can be invoked to create module extension tags. |
| |
| <!-- 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="use_extension.extension_bzl_file"> |
| <code>extension_bzl_file</code> |
| </td> |
| <td> |
| required<br/> |
| A label to the Starlark file defining the module extension. |
| </td> |
| </tr> |
| <tr> |
| <td id="use_extension.extension_name"> |
| <code>extension_name</code> |
| </td> |
| <td> |
| required<br/> |
| The name of the module extension to use. A symbol with this name must be exported by the Starlark file. |
| </td> |
| </tr> |
| <tr> |
| <td id="use_extension.dev_dependency"> |
| <code>dev_dependency</code> |
| </td> |
| <td> |
| default = False<br/> |
| If true, this usage of the module extension will be ignored if the current module is not the root module or `--ignore_dev_dependency` is enabled. |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="use_repo">use_repo</h2> |
| <p><pre class="rule-signature"><a class="anchor" href="globals.html#None">None</a> use_repo(extension_proxy, *args, **kwargs)</pre></p> |
| |
| Imports one or more repos generated by the given module extension into the scope of the current module. |
| |
| <!-- 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="use_repo.extension_proxy"> |
| <code>extension_proxy</code> |
| </td> |
| <td> |
| required<br/> |
| A module extension proxy object returned by a <code>use_extension</code> call. |
| </td> |
| </tr> |
| <tr> |
| <td id="use_repo.args"> |
| <code>args</code> |
| </td> |
| <td> |
| required<br/> |
| The names of the repos to import. |
| </td> |
| </tr> |
| <tr> |
| <td id="use_repo.kwargs"> |
| <code>kwargs</code> |
| </td> |
| <td> |
| required<br/> |
| Specifies certain repos to import into the scope of the current module with different names. The keys should be the name to use in the current scope, whereas the values should be the original names exported by the module extension. |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="visibility">visibility</h2> |
| <p><pre class="rule-signature"><a class="anchor" href="globals.html#None">None</a> visibility(value)</pre></p> |
| |
| <p>Sets the load visibility of the .bzl module currently being initialized.<p>The load visibility of a module governs whether or not other BUILD and .bzl files may load it. (This is distinct from the target visibility of the underlying .bzl source file, which governs whether the file may appear as a dependency of other targets.) Load visibility works at the level of packages: To load a module the file doing the loading must live in a package that has been granted visibility to the module. A module can always be loaded within its own package, regardless of its visibility.<p><code>visibility()</code> may only be called once per .bzl file, and only at the top level, not inside a function. The preferred style is to put this call immediately below the <code>load()</code> statements and any brief logic needed to determine the argument.<p>If the flag <code>--check_bzl_visibility</code> is set to false, load visibility violations will emit warnings but not fail the build. |
| |
| <!-- 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="visibility.value"> |
| <code>value</code> |
| </td> |
| <td> |
| required<br/> |
| A list of package specification strings, or a single package specification string.<p>Package specifications follow the same format as for <code><a href='/versions/6.0.0/reference/be/functions#package_group'>package_group</a></code>, except that negative package specifications are not permitted. That is, a specification may have the forms:<ul><li><code>"//foo"</code>: the package <code>//foo</code><li><code>"//foo/..."</code>: the package <code>//foo</code> and all of its subpackages.<li><code>"public"</code> or <code>"private"</code>: all packages or no packages, respectively</ul><p>The "@" syntax is not allowed; all specifications are interpreted relative to the current module's repository.<p>If <code>value</code> is a list of strings, the set of packages granted visibility to this module is the union of the packages represented by each specification. (An empty list has the same effect as <code>private</code>.) If <code>value</code> is a single string, it is treated as if it were the singleton list <code>[value]</code>.<p>Note that the flags <code>--incompatible_package_group_has_public_syntax</code> and <code>--incompatible_fix_package_group_reporoot_syntax</code> have no effect on this argument. The <code>"public"</code> and <code>"private"</code> values are always available, and <code>"//..."</code> is always interpreted as "all packages in the current repository". |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="workspace">workspace</h2> |
| <p><pre class="rule-signature"><a class="anchor" href="globals.html#None">None</a> workspace(name)</pre></p> |
| |
| <p>This function can only be used in a <code>WORKSPACE</code> file and must be declared before all other functions in the <code>WORKSPACE</code> file. Each <code>WORKSPACE</code> file should have a <code>workspace</code> function.</p><p>Sets the name for this workspace. Workspace names should be a Java-package-style description of the project, using underscores as separators, e.g., github.com/bazelbuild/bazel should use com_github_bazelbuild_bazel. <p>This name is used for the directory that the repository's runfiles are stored in. For example, if there is a runfile <code>foo/bar</code> in the local repository and the WORKSPACE file contains <code>workspace(name = 'baz')</code>, then the runfile will be available under <code>mytarget.runfiles/baz/foo/bar</code>. If no workspace name is specified, then the runfile will be symlinked to <code>bar.runfiles/foo/bar</code>.</p> <p><a href="/versions/6.0.0/docs/external">Remote repository</a> rule names must be valid workspace names. For example, you could have <code>maven_jar(name = 'foo')</code>, but not <code>maven_jar(name = 'foo%bar')</code>, as Bazel would attempt to write a WORKSPACE file for the <code>maven_jar</code> containing <code>workspace(name = 'foo%bar')</code>.</p> |
| |
| <!-- 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="workspace.name"> |
| <code>name</code> |
| </td> |
| <td> |
| required<br/> |
| the name of the workspace. Names must start with a letter and can only contain letters, numbers, underscores, dashes, and dots. |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="zip">zip</h2> |
| <p><pre class="rule-signature"><a class="anchor" href="list.html">list</a> zip(*args)</pre></p> |
| |
| Returns a <code>list</code> of <code>tuple</code>s, where the i-th tuple contains the i-th element from each of the argument sequences or iterables. The list has the size of the shortest input. With a single iterable argument, it returns a list of 1-tuples. With no arguments, it returns an empty list. Examples:<pre class="language-python">zip() # == [] |
| zip([1, 2]) # == [(1,), (2,)] |
| zip([1, 2], [3, 4]) # == [(1, 3), (2, 4)] |
| zip([1, 2], [3, 4, 5]) # == [(1, 3), (2, 4)]</pre> |
| |
| <!-- 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="zip.args"> |
| <code>args</code> |
| </td> |
| <td> |
| required<br/> |
| lists to zip. |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| |
| </body> |
| </html> |
| |
| <!-- {% endraw %} --> |