aboutsummaryrefslogtreecommitdiff
path: root/test/testdata/attribute_defaults_test/input.bzl
blob: fe891f6e180dd92c5b1c0a7fd3306922904accb9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
"""A golden test to verify attribute default values."""

def _my_rule_impl(ctx):
    return []

def _my_aspect_impl(target, ctx):
    return []

my_aspect = aspect(
    implementation = _my_aspect_impl,
    doc = "This is my aspect. It does stuff.",
    attr_aspects = ["deps", "attr_aspect"],
    attrs = {
        "_x": attr.label(mandatory = True),
        "y": attr.string(default = "why", doc = "some string"),
        "z": attr.string(mandatory = True),
    },
)

my_rule = rule(
    implementation = _my_rule_impl,
    doc = "This is my rule. It does stuff.",
    attrs = {
        "a": attr.bool(default = False, doc = "Some bool"),
        "b": attr.int(default = 2, doc = "Some int"),
        "c": attr.int_list(default = [0, 1], doc = "Some int_list"),
        "d": attr.label(default = "//foo:bar", doc = "Some label"),
        "e": attr.label_keyed_string_dict(
            default = {"//foo:bar": "hello", "//bar:baz": "goodbye"},
            doc = "Some label_keyed_string_dict",
        ),
        "f": attr.label_list(default = ["//foo:bar", "//bar:baz"], doc = "Some label_list"),
        "g": attr.string(default = "", doc = "Some string"),
        "h": attr.string_dict(
            default = {"animal": "bunny", "color": "orange"},
            doc = "Some string_dict",
        ),
        "i": attr.string_list(default = ["cat", "dog"], doc = "Some string_list"),
        "j": attr.string_list_dict(
            default = {"animal": ["cat", "bunny"], "color": ["blue", "orange"]},
            doc = "Some string_list_dict",
        ),
        "k": attr.bool(mandatory = True, doc = "Some bool"),
        "l": attr.int(mandatory = True, doc = "Some int"),
        "m": attr.int_list(mandatory = True, doc = "Some int_list"),
        "n": attr.label(mandatory = True, doc = "Some label"),
        "o": attr.label_keyed_string_dict(mandatory = True, doc = "Some label_keyed_string_dict"),
        "p": attr.label_list(mandatory = True, doc = "Some label_list"),
        "q": attr.string(mandatory = True, doc = "Some string"),
        "r": attr.string_dict(mandatory = True, doc = "Some string_dict"),
        "s": attr.string_list(mandatory = True, doc = "Some string_list"),
        "t": attr.string_list_dict(mandatory = True, doc = "Some string_list_dict"),
        "u": attr.string(),
        "v": attr.label(),
        "w": attr.int()
    },
)