1# This is here to test that built-in names can be shadowed by global names. 2# (Regression test for http://b/35984389). 3# buildifier: disable=module-docstring 4config = "value for global config variable" 5 6def my_rule_impl(ctx): 7 _ignore = [ctx] # @unused 8 return [] 9 10def exercise_the_api(): 11 var1 = config_common.FeatureFlagInfo # @unused 12 var2 = platform_common.TemplateVariableInfo # @unused 13 var3 = repository_rule( 14 implementation = my_rule_impl, 15 doc = "This repository rule has documentation.", 16 ) # @unused 17 var4 = testing.ExecutionInfo({}) # @unused 18 19exercise_the_api() 20 21# buildifier: disable=provider-params 22# buildifier: disable=unsorted-dict-items 23MyInfo = provider( 24 fields = { 25 "foo": "Something foo-related.", 26 "bar": "Something bar-related.", 27 }, 28) 29 30my_info = MyInfo(foo = "x", bar = "y") 31 32# buildifier: disable=unsorted-dict-items 33my_rule = rule( 34 implementation = my_rule_impl, 35 doc = "This rule exercises some of the build API.", 36 attrs = { 37 "src": attr.label( 38 doc = "The source file.", 39 allow_files = [".bzl"], 40 ), 41 "deps": attr.label_list( 42 doc = """ 43A list of dependencies. 44""", 45 providers = [MyInfo], 46 allow_files = False, 47 ), 48 "tool": attr.label( 49 doc = "The location of the tool to use.", 50 allow_files = True, 51 default = Label("//foo/bar/baz:target"), 52 cfg = "exec", 53 executable = True, 54 ), 55 "out": attr.output( 56 doc = "The output file.", 57 mandatory = True, 58 ), 59 "extra_arguments": attr.string_list(default = []), 60 }, 61) 62