-
-
Notifications
You must be signed in to change notification settings - Fork 44
/
rules.bzl
38 lines (35 loc) · 909 Bytes
/
rules.bzl
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
"mypy_stubs rule"
MyPyStubsInfo = provider(
"TODO: docs",
fields = {
"srcs": ".pyi stub files",
},
)
def _mypy_stubs_impl(ctx):
pyi_srcs = []
for target in ctx.attr.srcs:
pyi_srcs.extend(target.files.to_list())
transitive_srcs = depset(direct = pyi_srcs)
return [
MyPyStubsInfo(
srcs = ctx.attr.srcs,
),
PyInfo(
# TODO(Jonathon): Stub files only for Py3 right?
has_py2_only_sources = False,
has_py3_only_sources = True,
uses_shared_libraries = False,
transitive_sources = transitive_srcs,
),
]
mypy_stubs = rule(
implementation = _mypy_stubs_impl,
attrs = {
"srcs": attr.label_list(
allow_empty = False,
mandatory = True,
doc = "TODO(Jonathon)",
allow_files = [".pyi"],
),
},
)