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