1- """starlark_library.bzl is a thin wrapper over bzl_library ."""
1+ """starlark_library.bzl is similar to bzl_library but also provides load statement foreach file ."""
22
33load ("@bazel_skylib//:bzl_library.bzl" , "StarlarkLibraryInfo" )
44
55StarlarkLibraryFileInfo = provider (
66 "Information on contained Starlark rules." ,
77 fields = {
8+ "bazelignore" : "List[str] value of ctx.attr.bazelignore" ,
9+ "bazelversion" : "str: the value of ctx.attr.bazelversion" ,
10+ "deps" : "DepSet[StarlarkLibraryFileInfo]: deps of this file" ,
811 "label" : "The label of the target rule" ,
9- "repo_name" : "The original (non-canonical) repo (workspace!) name" ,
10- "srcs" : "List of .bzl files" ,
1112 "loads" : "load statements per .bzl file" ,
12- "deps " : "DepSet[StarlarkLibraryFileInfo]: deps of this file " ,
13+ "srcs " : "List of .bzl files " ,
1314 "transitive_deps" : "DepSet[StarlarkLibraryFileInfo]: transitive deps of this file" ,
14- "bazelignore" : "List[str] value of ctx.attr.bazelignore" ,
15- "bazelversion" : "str: the value of ctx.attr.bazelversion" ,
1615 },
1716)
1817
1918def _starlark_library_impl (ctx ):
20- deps = [d [StarlarkLibraryFileInfo ] for d in ctx .attr .deps ]
2119 srcs = ctx .files .srcs
20+ deps = [d [StarlarkLibraryFileInfo ] for d in ctx .attr .deps ]
2221 transitive_srcs = depset (srcs , order = "postorder" , transitive = [d .transitive_srcs for d in deps ])
23-
24- # loads = {}
25- # for k, v in ctx.attr.loads.items():
26- # loads[Label(k)] = v
22+ transitive_deps = depset (deps , order = "postorder" , transitive = [d .transitive_deps for d in deps ])
2723
2824 return [
2925 DefaultInfo (
@@ -34,39 +30,36 @@ def _starlark_library_impl(ctx):
3430 transitive_srcs = transitive_srcs ,
3531 ),
3632 StarlarkLibraryFileInfo (
37- label = ctx .label ,
38- repo_name = ctx .attr .repo_name ,
39- srcs = srcs ,
40- loads = ctx .attr .loads ,
4133 bazelignore = ctx .attr .bazelignore ,
4234 bazelversion = ctx .attr .bazelversion ,
43- transitive_deps = depset (deps , transitive = [d .transitive_deps for d in deps ]),
35+ deps = deps ,
36+ label = ctx .label ,
37+ loads = ctx .attr .loads ,
38+ srcs = srcs ,
39+ transitive_deps = transitive_deps ,
4440 ),
4541 ]
4642
4743starlark_library = rule (
4844 implementation = _starlark_library_impl ,
4945 attrs = {
50- "repo_name " : attr .string (
51- mandatory = True ,
46+ "bazelignore " : attr .string_list (
47+ doc = "contents of the .bazelignore file, if present" ,
5248 ),
53- "srcs" : attr .label_list (
54- doc = "label for the .bzl file" ,
55- allow_files = True ,
49+ "bazelversion" : attr .string (
50+ doc = "contents of the .bazelversion file, if present" ,
5651 ),
5752 "loads" : attr .string_list_dict (
5853 doc = "load per file" ,
5954 ),
55+ "srcs" : attr .label_list (
56+ doc = "label for the .bzl file" ,
57+ allow_files = True ,
58+ ),
6059 "deps" : attr .label_list (
6160 doc = "list of starlark_library rule dependencies. These can be " ,
6261 providers = [StarlarkLibraryFileInfo ],
6362 ),
64- "bazelignore" : attr .string_list (
65- doc = "contents of the .bazelignore file, if present" ,
66- ),
67- "bazelversion" : attr .string (
68- doc = "contents of the .bazelversion file, if present" ,
69- ),
7063 },
7164 doc = "" ,
7265 provides = [DefaultInfo , StarlarkLibraryInfo , StarlarkLibraryFileInfo ],
0 commit comments