Skip to content
This repository was archived by the owner on Apr 1, 2026. It is now read-only.

Commit 0a7ae5b

Browse files
authored
Added system_rdl rules (#4)
1 parent 5a200dc commit 0a7ae5b

28 files changed

+1624
-10
lines changed

.github/workflows/compile-requirements.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
inputs:
1010
target:
1111
description: "The py_reqs_compiler target to run"
12-
default: "//python/3rdparty:requirements.update"
12+
default: "//tools/requirements:update"
1313

1414
jobs:
1515
build:
@@ -19,8 +19,6 @@ jobs:
1919
include:
2020
- os: linux_x86_64
2121
runs-on: ubuntu-latest
22-
- os: linux_aarch64
23-
runs-on: ubuntu-24.04-arm
2422
- os: macos_aarch64
2523
runs-on: macos-latest
2624
- os: windows_x86_64
@@ -49,7 +47,7 @@ jobs:
4947
echo "<details>" >> "${GITHUB_STEP_SUMMARY}"
5048
echo "" >> "${GITHUB_STEP_SUMMARY}"
5149
echo '```' >> "${GITHUB_STEP_SUMMARY}"
52-
cat "python/3rdparty/requirements_${{ matrix.os }}.txt" >> "${GITHUB_STEP_SUMMARY}"
50+
cat "tools/requirements/requirements_${{ matrix.os }}.txt" >> "${GITHUB_STEP_SUMMARY}"
5351
echo '```' >> "${GITHUB_STEP_SUMMARY}"
5452
echo "" >> "${GITHUB_STEP_SUMMARY}"
5553
echo "</details>" >> "${GITHUB_STEP_SUMMARY}"

MODULE.bazel

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,53 @@ bazel_dep(name = "bazel_skylib", version = "1.8.2")
99
bazel_dep(name = "platforms", version = "1.0.0")
1010
bazel_dep(name = "rules_cc", version = "0.2.4")
1111
bazel_dep(name = "verilator", version = "5.036.bcr.1")
12+
bazel_dep(name = "rules_venv", version = "0.7.1")
1213

1314
register_toolchains(
1415
"//verilator/toolchain",
16+
"//system_rdl/toolchain",
1517
dev_dependency = True,
1618
)
1719

1820
bazel_dep(name = "stardoc", version = "0.8.0", dev_dependency = True, repo_name = "io_bazel_stardoc")
1921
bazel_dep(name = "rules_rust_mdbook", version = "0.65.0", dev_dependency = True)
20-
bazel_dep(name = "rules_shell", version = "0.5.1", dev_dependency = True)
22+
bazel_dep(name = "rules_shell", version = "0.6.1", dev_dependency = True)
23+
bazel_dep(name = "rules_req_compile", version = "1.0.0rc41", dev_dependency = True)
24+
25+
python = use_extension("@rules_venv//python/extensions:python.bzl", "python", dev_dependency = True)
26+
python.toolchain(
27+
configure_coverage_tool = True,
28+
# Working around a rules_python issue with docker
29+
# https://github.com/bazelbuild/rules_python/pull/713
30+
ignore_root_user_error = True,
31+
is_default = True,
32+
python_version = "3.11",
33+
)
34+
use_repo(
35+
python,
36+
"python_3_11_aarch64-apple-darwin",
37+
"python_3_11_aarch64-unknown-linux-gnu",
38+
"python_3_11_x86_64-apple-darwin",
39+
"python_3_11_x86_64-pc-windows-msvc",
40+
"python_3_11_x86_64-unknown-linux-gnu",
41+
python311 = "python_3_11",
42+
)
43+
44+
requirements = use_extension("@rules_req_compile//extensions:python.bzl", "requirements", dev_dependency = True)
45+
requirements.parse(
46+
name = "pip_deps",
47+
requirements_locks = {
48+
"//tools/requirements:requirements_linux_x86_64.txt": "//tools/requirements:linux_x86_64",
49+
"//tools/requirements:requirements_macos_aarch64.txt": "//tools/requirements:macos_aarch64",
50+
"//tools/requirements:requirements_windows_x86_64.txt": "//tools/requirements:windows_x86_64",
51+
},
52+
)
53+
use_repo(requirements, "pip_deps")
54+
55+
register_toolchains(
56+
"//tools/toolchains:black_toolchain",
57+
"//tools/toolchains:isort_toolchain",
58+
"//tools/toolchains:mypy_toolchain",
59+
"//tools/toolchains:pylint_toolchain",
60+
dev_dependency = True,
61+
)

MODULE.bazel.lock

Lines changed: 244 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/BUILD.bazel

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@ load("@io_bazel_stardoc//stardoc:stardoc.bzl", "stardoc")
22
load("@rules_rust_mdbook//:defs.bzl", "mdbook", "mdbook_server")
33
load("@rules_shell//shell:sh_binary.bzl", "sh_binary")
44

5+
stardoc(
6+
name = "system_rdl",
7+
out = "src/system_rdl.md",
8+
input = "//system_rdl:defs.bzl",
9+
table_of_contents_template = "@io_bazel_stardoc//stardoc:templates/markdown_tables/table_of_contents.vm",
10+
tags = ["manual"],
11+
deps = ["//system_rdl:defs_bzl"],
12+
)
13+
514
stardoc(
615
name = "verilator",
716
out = "src/verilator.md",
@@ -23,6 +32,7 @@ stardoc(
2332
mdbook(
2433
name = "book",
2534
srcs = glob(["src/**/*.md"]) + [
35+
":system_rdl",
2636
":verilator",
2737
":verilog",
2838
],

docs/src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44

55
- [verilog](./verilog.md)
66
- [verilator](./verilator.md)
7+
- [system_rdl](./system_rdl.md)

system_rdl/BUILD.bazel

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
2+
3+
exports_files(
4+
[
5+
"defs.bzl",
6+
"requirements.in",
7+
"system_rdl_info.bzl",
8+
"system_rdl_library.bzl",
9+
"system_rdl_toolchain.bzl",
10+
"verilog_system_rdl_library.bzl",
11+
],
12+
)
13+
14+
toolchain_type(
15+
name = "toolchain_type",
16+
visibility = ["//visibility:public"],
17+
)
18+
19+
bzl_library(
20+
name = "defs_bzl",
21+
srcs = glob(["*.bzl"]),
22+
visibility = ["//visibility:public"],
23+
deps = [
24+
"//system_rdl/private:bzl_lib",
25+
"//verilog:verilog_info_bzl",
26+
],
27+
)

system_rdl/defs.bzl

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
"""# SystemRDL rules.
2+
3+
Bazel rules for [SystemRDL](https://peakrdl.readthedocs.io/en/latest/systemrdl-tutorial.html)
4+
5+
## Setup
6+
7+
```python
8+
bazel_dep(name = "rules_verilog", version = "{version}")
9+
10+
register_toolchain(
11+
# Define a custom toolchain or use the `rules_verilog` provided toolchain.
12+
"@rules_verilog//system_rdl/toolchain",
13+
)
14+
```
15+
"""
16+
17+
load(
18+
":system_rdl_info.bzl",
19+
_SystemRdlInfo = "SystemRdlInfo",
20+
)
21+
load(
22+
":system_rdl_library.bzl",
23+
_system_rdl_library = "system_rdl_library",
24+
)
25+
load(
26+
":system_rdl_toolchain.bzl",
27+
_system_rdl_toolchain = "system_rdl_toolchain",
28+
)
29+
load(
30+
":verilog_system_rdl_library.bzl",
31+
_verilog_system_rdl_library = "verilog_system_rdl_library",
32+
)
33+
34+
SystemRdlInfo = _SystemRdlInfo
35+
system_rdl_library = _system_rdl_library
36+
system_rdl_toolchain = _system_rdl_toolchain
37+
verilog_system_rdl_library = _verilog_system_rdl_library

system_rdl/private/BUILD.bazel

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
2+
load("@rules_venv//python:py_binary.bzl", "py_binary")
3+
load(":system_rdl.bzl", "current_system_rdl_peakrdl_toolchain")
4+
5+
current_system_rdl_peakrdl_toolchain(
6+
name = "current_system_rdl_peakrdl_toolchain",
7+
)
8+
9+
py_binary(
10+
name = "peakrdl",
11+
srcs = [
12+
"peakrdl.py",
13+
],
14+
main = "peakrdl.py",
15+
deps = [
16+
":current_system_rdl_peakrdl_toolchain",
17+
],
18+
)
19+
20+
bzl_library(
21+
name = "bzl_lib",
22+
srcs = glob(["*.bzl"]),
23+
visibility = ["//system_rdl:__pkg__"],
24+
deps = [
25+
"@rules_venv//python:defs_bzl",
26+
],
27+
)

system_rdl/private/peakrdl.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
"""The PeakRDL Bazel entrypoint for use in system_rdl rules."""
2+
3+
from peakrdl.main import main as peakrdl_main
4+
5+
if __name__ == "__main__":
6+
peakrdl_main()

0 commit comments

Comments
 (0)