implementation | function; required A Starlark function that implements this aspect, with exactly two parameters: Target (the target to which the aspect is applied) and ctx (the rule context which the target is created from). Attributes of the target are available via the ctx.rule field. This function is evaluated during the analysis phase for each application of an aspect to a target. |
attr_aspects | sequence of strings; or function; default is [] Accepts a list of attribute names or [Experimental] a function that returns the list of attribute names. The aspect propagates along dependencies specified in the attributes of a target with these names. Common values here include deps and exports. The list can also contain a single string "*" to propagate along all dependencies of a target. |
toolchains_aspects | sequence; or function; default is [] Accepts a list of toolchain types or [Experimental] a function that returns the list of toolchain types. The aspect propagates to target toolchains which match these toolchain types. |
attrs | dict; default is {} 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 attr module). Aspect attributes are available to implementation function as fields of ctx parameter. Implicit attributes starting with _ must have default values, and have type label or label_list. Explicit attributes must have type string, and must use the values 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. Declared attributes will convert None to the default value. |
required_providers | sequence; default is [] 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, [[FooInfo], [BarInfo], [BazInfo, QuxInfo]] is a valid value while [FooInfo, BarInfo, [BazInfo, QuxInfo]] is not valid. An unnested list of providers will automatically be converted to a list containing one list of providers. That is, [FooInfo, BarInfo] will automatically be converted to [[FooInfo, BarInfo]]. To make some rule (e.g. some_rule) targets visible to an aspect, some_rule must advertise all providers from at least one of the required providers lists. For example, if the required_providers of an aspect are [[FooInfo], [BarInfo], [BazInfo, QuxInfo]], this aspect can see some_rule targets if and only if some_rule provides FooInfo, or BarInfo, or both BazInfo and QuxInfo. |
required_aspect_providers | sequence; default is [] 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, [[FooInfo], [BarInfo], [BazInfo, QuxInfo]] is a valid value while [FooInfo, BarInfo, [BazInfo, QuxInfo]] is not valid. An unnested list of providers will automatically be converted to a list containing one list of providers. That is, [FooInfo, BarInfo] will automatically be converted to [[FooInfo, BarInfo]]. To make another aspect (e.g. other_aspect) visible to this aspect, other_aspect must provide all providers from at least one of the lists. In the example of [[FooInfo], [BarInfo], [BazInfo, QuxInfo]], this aspect can see other_aspect if and only if other_aspect provides FooInfo, or BarInfo, or both BazInfo and QuxInfo. |
required_aspect_hints_providers | sequence; default is [] This attribute is used to match aspects to targets that appear in the aspect_hints attribute. With the --incompatible_require_matching_aspect_hints_providers flag enabled, the aspect_hints attribute is evaluated differently from other attributes: A target T in the aspect_hints attribute of a target P is added as a dependency of P only if the rule class of T declares providers that satisfy the required_aspect_hints_providers of one or more aspects being applied to P. This avoids analysis time, memory usage, configuration mismatches, conformance test failures, etc. for targets that are not actually needed by any aspect. The target’s providers to be matched against an aspect’s required_aspect_hints_providers must be declared in the rule class (via the provides argument of rule()) so that targets and aspects can be matched without actually evaluating the target. That is, it is not sufficient to just return the provider from the rule implementation function. The value of required_aspect_hints_providers must be a list containing either individual providers or lists of providers but not both. For example, [[FooInfo], [BarInfo], [BazInfo, QuxInfo]] is a valid value while [FooInfo, BarInfo, [BazInfo, QuxInfo]] is not valid. An unnested list of providers will automatically be converted to a list containing one list of providers. That is, [FooInfo, BarInfo] will automatically be converted to [[FooInfo, BarInfo]]. |
provides | sequence; default is [] A list of providers that the implementation function must return. 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. Each element of the list is an *Info object returned by provider(). When a target of the rule is used as a dependency for a target that declares a required provider, it is not necessary to specify that provider here. It is enough that the implementation function returns it. However, it is considered best practice to specify it, even though this is not required. The required_providers field of an aspect does, however, require that providers are specified here. |
requires | sequence of Aspects; default is [] List of aspects required to be propagated before this aspect. |
propagation_predicate | function; or None; default is None Experimental: a function that returns a boolean value indicating whether the aspect should be propagated to a target. |
fragments | sequence of strings; default is [] List of names of configuration fragments that the aspect requires in target configuration. |
host_fragments | sequence of strings; default is [] List of names of configuration fragments that the aspect requires in host configuration. |
toolchains | sequence; default is [] If set, the set of toolchains this aspect 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 aspect implementation via ctx.toolchain. |
doc | string; or None; default is None A description of the aspect that can be extracted by documentation generating tools. |
apply_to_generating_rules | bool; default is False If true, the aspect will, when applied to an output file, instead apply to the output file’s generating rule. 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. False by default. |
exec_compatible_with | sequence of strings; default is [] A list of constraints on the execution platform that apply to all instances of this aspect. |
exec_groups | dict; or None; default is None Dict of execution group name (string) to exec_groups. If set, allows aspects to run actions on multiple execution platforms within a single instance. See execution groups documentation for more info. |
subrules | sequence of Subrules; default is [] Experimental: list of subrules used by this aspect. |