-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathyosys.bzl
51 lines (47 loc) · 1.26 KB
/
yosys.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
39
40
41
42
43
44
45
46
47
48
49
50
51
"""Yosys rules"""
def _yosys_impl(ctx):
outs = []
for k in dir(ctx.outputs):
outs.extend(getattr(ctx.outputs, k))
ctx.actions.run(
arguments = [ctx.expand_location(arg, ctx.attr.srcs) for arg in ctx.attr.arguments],
executable = ctx.executable._yosys,
inputs = depset(
ctx.files.srcs + [
ctx.executable._yosys,
],
transitive = [
ctx.attr._yosys[DefaultInfo].default_runfiles.files,
ctx.attr._yosys[DefaultInfo].default_runfiles.symlinks,
],
),
outputs = outs,
)
return [
DefaultInfo(
files = depset(outs),
),
]
yosys = rule(
implementation = _yosys_impl,
attrs = {
"_yosys": attr.label(
doc = "Yosys binary.",
executable = True,
allow_files = True,
cfg = "exec",
default = Label("@docker_orfs//:yosys"),
),
"arguments": attr.string_list(
mandatory = True,
),
"srcs": attr.label_list(
mandatory = True,
allow_files = True,
),
"outs": attr.output_list(
mandatory = True,
),
},
provides = [DefaultInfo],
)