| --- | |
| title: 'Provider' | |
| --- | |
| A constructor for simple value objects, known as provider instances. | |
| This value has a dual purpose: | |
| * It is a function that can be called to construct 'struct'-like values: | |
| ``` | |
| DataInfo = provider() | |
| d = DataInfo(x = 2, y = 3) | |
| print(d.x + d.y) # prints 5 | |
| ``` | |
| Note: Some providers, defined internally, do not allow instance creation | |
| * It is a *key* to access a provider instance on a [Target](../builtins/Target) | |
| ``` | |
| DataInfo = provider() | |
| def _rule_impl(ctx) | |
| ... ctx.attr.dep[DataInfo] | |
| ``` | |
| Create a new `Provider` using the [provider](../globals/bzl#provider) function. |