attrs
any
def any(
*,
doc: str = "",
default = ...,
) -> attribute
Takes most builtin literals and passes them to the rule as a string. Discouraged, as it provides little type safety and destroys the structure.
arg
def arg(
*,
json: bool = False,
default = ...,
doc: str = "",
anon_target_compatible: bool = False,
) -> attribute
Takes a command line argument from the user and supplies a cmd_args
compatible value to the rule. The argument may contain special macros such as $(location :my_target)
or $(exe :my_target)
which will be replaced with references to those values in the rule. Takes in an optional anon_target_compatible
flag, which indicates whether the args can be passed into anon targets. Note that there is a slight memory hit when using this flag.
bool
def bool(
*,
default = ...,
doc: str = "",
) -> attribute
Takes a boolean and passes it to the rule as a boolean.
configuration_label
def configuration_label(
*,
doc: str = "",
) -> attribute
configured_dep
def configured_dep(
*,
providers: list | tuple = [],
default = ...,
doc: str = "",
) -> attribute
default_only
def default_only(
inner: attribute,
/,
*,
doc: str = "",
) -> attribute
Rejects all values and uses the default for the inner argument. Often used to resolve dependencies, which otherwise can't be resolved inside a rule.
attrs.default_only(attrs.dep(default = "foo//my_package:my_target"))
dep
def dep(
*,
providers: list | tuple = [],
pulls_plugins: list[PluginKind] | tuple[PluginKind, ...] = [],
pulls_and_pushes_plugins: all_plugins | list[PluginKind] | tuple[PluginKind, ...] = ...,
default = ...,
doc: str = "",
) -> attribute
Takes a target from the user, as a string, and supplies a dependency to the rule. A target can be specified as an absolute dependency foo//bar:baz
, omitting the cell (//bar:baz
) or omitting the package name (:baz
).
If supplied the providers
argument ensures that specific providers will be present
on the dependency.
dict
def dict(
key: attribute,
value: attribute,
*,
sorted: bool = False,
default = ...,
doc: str = "",
) -> attribute
Takes a dict from the user, supplies a dict to the rule.
enum
def enum(
variants: list[str] | tuple[str, ...],
/,
*,
default: selector | str = ...,
doc: str = "",
) -> attribute
Takes a string from one of the variants given, and gives that string to the rule. Strings are matched case-insensitively, and always passed to the rule lowercase.
exec_dep
def exec_dep(
*,
providers: list | tuple = [],
default = ...,
doc: str = "",
) -> attribute
Takes a target from the user, as a string, and supplies a dependency to the rule. The dependency will transition to the execution platform. Use exec_dep
if you plan to execute things from this dependency as part of the compilation.
int
def int(
*,
default = ...,
doc: str = "",
) -> attribute
Takes an int from the user, supplies an int to the rule.
label
def label(
*,
default = ...,
doc: str = "",
) -> attribute
Takes a target (as per deps
) and passes a label
to the rule. Validates that the target exists, but does not introduce a dependency on it.
list
def list(
inner: attribute,
/,
*,
default = ...,
doc: str = "",
) -> attribute
Takes a list from the user, supplies a list to the rule.
named_set
def named_set(
value_type: attribute,
/,
*,
sorted: bool = False,
default = ...,
doc: str = "",
) -> attribute
one_of
def one_of(
*args: attribute,
default = ...,
doc: str = "",
) -> attribute
Given a list of alternative attributes, selects the first that matches and gives that to the rule.
option
def option(
inner: attribute,
/,
*,
default = ...,
doc: str = "",
) -> attribute
Takes a value that may be None
or some inner type, and passes either None
or the value corresponding to the inner to the rule. Often used to make a rule optional:
attrs.option(attr.string(), default = None)
plugin_dep
def plugin_dep(
*,
kind: PluginKind,
default = ...,
doc: str = "",
) -> attribute
query
def query(
*,
doc: str = "",
) -> attribute
regex
def regex(
*,
default = ...,
doc: str = "",
) -> attribute
Currently an alias for attrs.string
.
set
def set(
value_type: attribute,
/,
*,
sorted: bool = False,
default = ...,
doc: str = "",
) -> attribute
source
def source(
*,
allow_directory: bool = False,
default = ...,
doc: str = "",
) -> attribute
Takes a source file from the user, supplies an artifact to the rule. The source file may be specified as a literal string (representing the path within this package), or a target (which must have a DefaultInfo
with a default_outputs
value).
split_transition_dep
def split_transition_dep(
*,
providers: list | tuple = [],
cfg,
default = ...,
doc: str = "",
) -> attribute
string
def string(
*,
default = ...,
validate = ...,
doc: str = "",
) -> attribute
Takes a string from the user, supplies a string to the rule.
toolchain_dep
def toolchain_dep(
*,
providers: list | tuple = [],
default = ...,
doc: str = "",
) -> attribute
Takes a target from the user, as a string, and supplies a dependency to the rule. The dependency will be a toolchain dependency, meaning that its execution platform dependencies will be used to select the execution platform for this rule.
transition_dep
def transition_dep(
*,
providers: list | tuple = [],
cfg,
default = ...,
doc: str = "",
) -> attribute
tuple
def tuple(
*args: attribute,
default = ...,
doc: str = "",
) -> attribute
Takes a tuple of values and gives a tuple to the rule.
versioned
def versioned(
value_type: attribute,
*,
doc: str = "",
) -> attribute