blob: 18042eedd13564506850b8cd76885858eb0ee715 [file] [log] [blame] [view]
<!-- Generated with Stardoc: http://skydoc.bazel.build -->
Skylib module containing utilities for Bazel modules and module extensions.
<a id="modules.as_extension"></a>
## modules.as_extension
<pre>
modules.as_extension(<a href="#modules.as_extension-macro">macro</a>, <a href="#modules.as_extension-doc">doc</a>)
</pre>
Wraps a WORKSPACE dependency macro into a module extension.
Example:
```starlark
def rules_foo_deps(optional_arg = True):
some_repo_rule(name = "foobar")
http_archive(name = "bazqux")
rules_foo_deps_ext = modules.as_extension(rules_foo_deps)
```
**PARAMETERS**
| Name | Description | Default Value |
| :------------- | :------------- | :------------- |
| <a id="modules.as_extension-macro"></a>macro | A [WORKSPACE dependency macro](https://bazel.build/rules/deploying#dependencies), i.e., a function with no required parameters that instantiates one or more repository rules. | none |
| <a id="modules.as_extension-doc"></a>doc | A description of the module extension that can be extracted by documentation generating tools. | `None` |
**RETURNS**
A module extension that generates the repositories instantiated by the given macro and also
uses [`use_all_repos`](#use_all_repos) to indicate that all of those repositories should be
imported via `use_repo`. The extension is marked as reproducible if supported by the current
version of Bazel and thus doesn't result in a lockfile entry.
<a id="modules.use_all_repos"></a>
## modules.use_all_repos
<pre>
modules.use_all_repos(<a href="#modules.use_all_repos-module_ctx">module_ctx</a>, <a href="#modules.use_all_repos-reproducible">reproducible</a>)
</pre>
Return from a module extension that should have all its repositories imported via `use_repo`.
Example:
```starlark
def _ext_impl(module_ctx):
some_repo_rule(name = "foobar")
http_archive(name = "bazqux")
return modules.use_all_repos(module_ctx)
ext = module_extension(_ext_impl)
```
**PARAMETERS**
| Name | Description | Default Value |
| :------------- | :------------- | :------------- |
| <a id="modules.use_all_repos-module_ctx"></a>module_ctx | The [`module_ctx`](https://bazel.build/rules/lib/builtins/module_ctx) object passed to the module extension's implementation function. | none |
| <a id="modules.use_all_repos-reproducible"></a>reproducible | The value of the `reproducible` parameter to pass to the [`extension_metadata`](https://bazel.build/rules/lib/builtins/extension_metadata.html) object returned by this function. This is safe to set with Bazel versions that don't support this parameter and will be ignored in that case. | `False` |
**RETURNS**
An [`extension_metadata`](https://bazel.build/rules/lib/builtins/extension_metadata.html)
object that, when returned from a module extension implementation function, specifies that all
repositories generated by this extension should be imported via `use_repo`. If the current
version of Bazel doesn't support `extension_metadata`, returns `None` instead, which can
safely be returned from a module extension implementation function in all versions of Bazel.