xref: /aosp_15_r20/external/stardoc/test/testdata/attribute_defaults_test/input.bzl (revision b2fa42943c124aa9c7163734493fc7a7559681cf)
1"""A golden test to verify attribute default values."""
2
3def _my_rule_impl(ctx):
4    _ignore = [ctx]  # @unused
5    return []
6
7def _my_aspect_impl(target, ctx):
8    _ignore = [target, ctx]  # @unused
9    return []
10
11# buildifier: disable=unsorted-dict-items
12my_aspect = aspect(
13    implementation = _my_aspect_impl,
14    doc = "This is my aspect. It does stuff.",
15    attr_aspects = ["deps", "attr_aspect"],
16    attrs = {
17        "_x": attr.label(mandatory = True),
18        "y": attr.string(default = "why", doc = "some string"),
19        "z": attr.string(mandatory = True),
20    },
21)
22
23# buildifier: disable=unsorted-dict-items
24my_rule = rule(
25    implementation = _my_rule_impl,
26    doc = "This is my rule. It does stuff.",
27    attrs = {
28        "a": attr.bool(default = False, doc = "Some bool"),
29        "b": attr.int(default = 2, doc = "Some int"),
30        "c": attr.int_list(default = [0, 1], doc = "Some int_list"),
31        "d": attr.label(default = "//foo:bar", doc = "Some label"),
32        "e": attr.label_keyed_string_dict(
33            default = {"//foo:bar": "hello", "//bar:baz": "goodbye"},
34            doc = "Some label_keyed_string_dict",
35        ),
36        "f": attr.label_list(default = ["//foo:bar", "//bar:baz"], doc = "Some label_list"),
37        "g": attr.string(default = "", doc = "Some string"),
38        "h": attr.string_dict(
39            default = {"animal": "bunny", "color": "orange"},
40            doc = "Some string_dict",
41        ),
42        "i": attr.string_list(default = ["cat", "dog"], doc = "Some string_list"),
43        "j": attr.string_list_dict(
44            default = {"animal": ["cat", "bunny"], "color": ["blue", "orange"]},
45            doc = "Some string_list_dict",
46        ),
47        "k": attr.bool(mandatory = True, doc = "Some bool"),
48        "l": attr.int(mandatory = True, doc = "Some int"),
49        "m": attr.int_list(mandatory = True, doc = "Some int_list"),
50        "n": attr.label(mandatory = True, doc = "Some label"),
51        "o": attr.label_keyed_string_dict(mandatory = True, doc = "Some label_keyed_string_dict"),
52        "p": attr.label_list(mandatory = True, doc = "Some label_list"),
53        "q": attr.string(mandatory = True, doc = "Some string"),
54        "r": attr.string_dict(mandatory = True, doc = "Some string_dict"),
55        "s": attr.string_list(mandatory = True, doc = "Some string_list"),
56        "t": attr.string_list_dict(mandatory = True, doc = "Some string_list_dict"),
57        "u": attr.string(),
58        "v": attr.label(),
59        "w": attr.int(),
60    },
61)
62