Skip to content

Commit 691073b

Browse files
First working buck2 rdl gen. lots of mess here still including no support for deps and hard-coded paths
1 parent febfa15 commit 691073b

File tree

6 files changed

+64
-0
lines changed

6 files changed

+64
-0
lines changed

.buckconfig

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[repositories]
2+
root = .
3+
prelude = prelude
4+
toolchains = toolchains
5+
none = none
6+
7+
[repository_aliases]
8+
config = prelude
9+
fbcode = none
10+
fbsource = none
11+
buck = none
12+
13+
[parser]
14+
target_platform_detector_spec = target:root//...->prelude//platforms:default
15+
16+
[project]
17+
ignore = .git

.buckroot

Whitespace-only changes.

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
[submodule "vnd/cobalt"]
22
path = vnd/cobalt
33
url = git@github.com:oxidecomputer/cobalt.git
4+
[submodule "prelude"]
5+
path = prelude
6+
url = https://github.com/facebook/buck2-prelude.git

BUCK

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
load(":rdl.bzl", "rdl_file", "rdl_gen")
2+
rdl_file(
3+
name = "gimlet_regs_rdl",
4+
src = "gimlet_seq_fpga_regs.rdl"
5+
)
6+
7+
rdl_gen(
8+
name = "rdl_test",
9+
srcs = [":gimlet_regs_rdl"],
10+
outputs = ["test_pkg.vhd", "test.html"]
11+
)

prelude

Submodule prelude added at 7080d9b

rdl.bzl

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
def _rdl_file_impl(ctx):
2+
return [DefaultInfo(default_output=ctx.attrs.src.without_associated_artifacts())]
3+
4+
rdl_file = rule(
5+
impl = _rdl_file_impl,
6+
attrs = {
7+
"src": attrs.source()
8+
}
9+
)
10+
11+
def _rdl_gen_impl(ctx):
12+
outs = [ctx.actions.declare_output(out) for out in ctx.attrs.outputs]
13+
print(ctx.attrs.srcs)
14+
ctx.actions.run([
15+
"python3",
16+
"../cobalt/tools/site_cobble/rdl_pkg/rdl_cli.py",
17+
"--inputs", [x for x in ctx.attrs.srcs],
18+
"--outputs", [x.as_output() for x in outs],
19+
],
20+
category="rdl",
21+
22+
)
23+
24+
return [DefaultInfo(default_outputs=outs)]
25+
26+
rdl_gen = rule(
27+
impl = _rdl_gen_impl,
28+
attrs = {
29+
"srcs": attrs.list(attrs.source()),
30+
"outputs": attrs.list(attrs.string())
31+
}
32+
)

0 commit comments

Comments
 (0)