type(x) function), but depsets are not simply hash
sets and do not support fast membership tests. If you need a general set datatype, use the core
Starlark set type (available since Bazel 8.1); if your .bzl file needs to
be compatible with older Bazel releases, you can simulate a set by using a dictionary where all keys
map to True.
When tested for truth (that is, when used in a Boolean context such as if d: where
d is a depset), a depset is True if and only if it is non-empty; this check is an O(1)
operation.
Depsets are immutable. They should be created using their
constructor function and merged or augmented with other
depsets via the transitive argument.
The order parameter determines the kind of traversal that is done to convert the
depset to an iterable. There are four possible values:
-
"default"(formerly"stable"): Order is unspecified (but deterministic). -
"postorder"(formerly"compile"): A left-to-right post-ordering. Precisely, this recursively traverses all children leftmost-first, then the direct elements leftmost-first. -
"preorder"(formerly"naive_link"): A left-to-right pre-ordering. Precisely, this traverses the direct elements leftmost-first, then recursively traverses the children leftmost-first. -
"topological"(formerly"link"): A topological ordering from the root down to the leaves. There is no left-to-right guarantee.
"default" order. In the latter case the resulting depset’s order will be the same as
the other’s order.
Depsets may contain duplicate values but these will be suppressed when iterating (using
to_list()). Duplicates may interfere with the ordering
semantics.
Members
to_list
"default"-ordered depsets, and for elements of child depsets whose order differs from that of the parent depset. The list is a copy; modifying it has no effect on the depset and vice versa.