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

Commit e951f46

Browse files
committed
rules_verilog 0.0.1
1 parent 8c84868 commit e951f46

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+2326
-1
lines changed

.bazelrc

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
###############################################################################
2+
## Bazel Configuration Flags
3+
##
4+
## `.bazelrc` is a Bazel configuration file.
5+
## https://bazel.build/docs/best-practices#bazelrc-file
6+
###############################################################################
7+
8+
# https://bazel.build/reference/command-line-reference#flag--enable_platform_specific_config
9+
common --enable_platform_specific_config
10+
11+
# Enable the only currently supported report type
12+
# https://bazel.build/reference/command-line-reference#flag--combined_report
13+
coverage --combined_report=lcov
14+
15+
# Avoid fully cached builds reporting no coverage and failing CI
16+
# https://bazel.build/reference/command-line-reference#flag--experimental_fetch_all_coverage_outputs
17+
coverage --experimental_fetch_all_coverage_outputs
18+
19+
# https://github.com/bazelbuild/bazel/issues/8195
20+
build --incompatible_disallow_empty_glob=true
21+
22+
# https://github.com/bazelbuild/bazel/issues/12821
23+
build --nolegacy_external_runfiles
24+
25+
# Disable legacy __init__.py behavior which is known to conflict with
26+
# modern python versions (3.9+)
27+
build --incompatible_default_to_explicit_init_py
28+
29+
# https://github.com/bazelbuild/bazel/issues/23043.
30+
build --incompatible_autoload_externally=
31+
32+
###############################################################################
33+
## Configuration Flags
34+
###############################################################################
35+
36+
# Enable black for all targets in the workspace
37+
build:verilator_lint --aspects=//verilator:verilator_lint_aspect.bzl%verilator_lint_aspect
38+
build:verilator_lint --output_groups=+verilator_lint_checks
39+
40+
test --config=verilator_lint
41+
42+
###############################################################################
43+
## Custom user flags
44+
##
45+
## This should always be the last thing in the `.bazelrc` file to ensure
46+
## consistent behavior when setting flags in that file as `.bazelrc` files are
47+
## evaluated top to bottom.
48+
###############################################################################
49+
50+
try-import %workspace%/user.bazelrc

.clang-format

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
BasedOnStyle: Google
3+
IndentWidth: 4
4+
...

.github/github.bazelrc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Bazel settings for use in Github CI
2+
3+
# Always display the flags being used
4+
common --announce_rc
5+
6+
# Show errors in CI
7+
test --test_output=errors
8+
9+
# Show more information about failures
10+
build --verbose_failures
11+
12+
# UI for cleaner CI output
13+
common --color=no
14+
common --show_timestamps

.github/release_notes.template

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# {version}
2+
3+
## Setup
4+
```python
5+
bazel_dep(name = "rules_verilog", version = "{version}")
6+
```
7+
8+
Additional documentation can be found at: https://github.com/periareon/rules_verilog

.github/workflows/ci.yaml

Lines changed: 238 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,238 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
merge_group:
8+
pull_request:
9+
types:
10+
- opened
11+
- synchronize
12+
13+
env:
14+
BAZEL_STARTUP_FLAGS: --bazelrc=${{ github.workspace }}/.github/github.bazelrc
15+
16+
jobs:
17+
ci:
18+
runs-on: ${{ matrix.os }}
19+
strategy:
20+
matrix:
21+
include:
22+
- os: macos-latest
23+
- os: ubuntu-24.04
24+
- os: ubuntu-24.04-arm
25+
- os: windows-2022
26+
steps:
27+
# Checkout the code
28+
- uses: actions/checkout@v4
29+
30+
- uses: bazel-contrib/setup-bazel@0.14.0
31+
with:
32+
bazelisk-cache: true
33+
disk-cache: ${{ github.workflow }}
34+
repository-cache: true
35+
36+
- name: Setup Bazelrc (Windows)
37+
run: |
38+
echo "TEMP=$env:RUNNER_TEMP" >> "$env:GITHUB_ENV"
39+
echo "TMP=$env:RUNNER_TEMP" >> "$env:GITHUB_ENV"
40+
echo "startup --output_user_root=D:/bzl" > ./user.bazelrc
41+
if: startswith(runner.os, 'Windows')
42+
- name: Setup Bazelrc
43+
run: |
44+
echo "common --keep_going" >> ./user.bazelrc
45+
46+
# Build and Test the code
47+
- name: Test (Unix)
48+
run: bazel ${BAZEL_STARTUP_FLAGS[@]} test //...
49+
if: startswith(runner.os, 'Windows') != true
50+
- name: Test (Windows)
51+
run: bazel $env:BAZEL_STARTUP_FLAGS test //...
52+
if: startswith(runner.os, 'Windows')
53+
54+
ci-aspects:
55+
runs-on: ${{ matrix.os }}
56+
strategy:
57+
matrix:
58+
include:
59+
- os: macos-latest
60+
- os: ubuntu-24.04
61+
- os: ubuntu-24.04-arm
62+
- os: windows-2022
63+
steps:
64+
# Checkout the code
65+
- uses: actions/checkout@v4
66+
67+
- uses: bazel-contrib/setup-bazel@0.14.0
68+
with:
69+
bazelisk-cache: true
70+
disk-cache: ${{ github.workflow }}
71+
repository-cache: true
72+
73+
- name: Setup Bazelrc (Windows)
74+
run: |
75+
echo "TEMP=$env:RUNNER_TEMP" >> "$env:GITHUB_ENV"
76+
echo "TMP=$env:RUNNER_TEMP" >> "$env:GITHUB_ENV"
77+
echo "startup --output_user_root=D:/bzl" > ./user.bazelrc
78+
if: startswith(runner.os, 'Windows')
79+
- name: Setup Bazelrc
80+
run: |
81+
echo "common --keep_going" >> ./user.bazelrc
82+
echo "common --config=strict" >> ./user.bazelrc
83+
84+
# Build and Test the code
85+
- name: Test (Unix)
86+
run: bazel ${BAZEL_STARTUP_FLAGS[@]} test //...
87+
if: startswith(runner.os, 'Windows') != true
88+
- name: Test (Windows)
89+
run: bazel $env:BAZEL_STARTUP_FLAGS test //...
90+
if: startswith(runner.os, 'Windows')
91+
92+
ci-coverage:
93+
runs-on: ${{ matrix.os }}
94+
strategy:
95+
matrix:
96+
include:
97+
- os: macos-latest
98+
- os: ubuntu-24.04
99+
- os: ubuntu-24.04-arm
100+
# TODO: https://github.com/bazelbuild/bazel/issues/26649
101+
# - os: windows-2022
102+
steps:
103+
# Checkout the code
104+
- uses: actions/checkout@v4
105+
106+
- uses: bazel-contrib/setup-bazel@0.14.0
107+
with:
108+
bazelisk-cache: true
109+
disk-cache: ${{ github.workflow }}
110+
repository-cache: true
111+
112+
- name: Setup Bazelrc (Windows)
113+
run: |
114+
echo "TEMP=$env:RUNNER_TEMP" >> "$env:GITHUB_ENV"
115+
echo "TMP=$env:RUNNER_TEMP" >> "$env:GITHUB_ENV"
116+
echo "startup --output_user_root=D:/bzl" > ./user.bazelrc
117+
if: startswith(runner.os, 'Windows')
118+
- name: Setup Bazelrc
119+
run: |
120+
echo "common --keep_going" >> ./user.bazelrc
121+
122+
# Build and Test the code
123+
- name: Coverage (Unix)
124+
run: bazel ${BAZEL_STARTUP_FLAGS[@]} coverage //...
125+
if: startswith(runner.os, 'Windows') != true
126+
- name: Coverage (Windows)
127+
run: bazel $env:BAZEL_STARTUP_FLAGS coverage //...
128+
if: startswith(runner.os, 'Windows')
129+
130+
- name: Check Coverage
131+
run: python3 tools/coverage/coverage_checker.py
132+
133+
ci-bazel-run:
134+
runs-on: ${{ matrix.os }}
135+
strategy:
136+
matrix:
137+
include:
138+
- os: macos-latest
139+
- os: ubuntu-24.04
140+
- os: ubuntu-24.04-arm
141+
- os: windows-2022
142+
steps:
143+
- uses: actions/checkout@v4
144+
- uses: bazel-contrib/setup-bazel@0.14.0
145+
with:
146+
bazelisk-cache: true
147+
disk-cache: ${{ github.workflow }}
148+
repository-cache: true
149+
150+
- name: Test (Unix)
151+
if: startswith(runner.os, 'Windows') != true
152+
run: |
153+
bazel ${BAZEL_STARTUP_FLAGS} run //python/verilog/private/tests/bazel_free:greeter -- world --output=$(pwd)/data.txt
154+
155+
if [[ "$(cat data.txt)" != "Hello, world"* ]]; then
156+
cat data.txt
157+
exit 1
158+
fi
159+
- name: Test (Windows)
160+
if: startswith(runner.os, 'Windows')
161+
run: |
162+
# Run the command and redirect output to data.txt
163+
& bazel $BAZEL_STARTUP_FLAGS run //python/verilog/private/tests/bazel_free:greeter "--" world --output=$(pwd)/data.txt
164+
165+
# Check if the contents of data.txt start with "Hello, world."
166+
if ((Get-Content data.txt) -notmatch "^Hello, world.*") {
167+
Get-Content data.txt
168+
exit 1
169+
}
170+
171+
ci-fixers:
172+
runs-on: ${{ matrix.os }}
173+
strategy:
174+
matrix:
175+
include:
176+
- os: macos-latest
177+
- os: ubuntu-24.04
178+
- os: ubuntu-24.04-arm
179+
- os: windows-2022
180+
steps:
181+
# Checkout the code
182+
- uses: actions/checkout@v4
183+
- uses: bazel-contrib/setup-bazel@0.14.0
184+
with:
185+
bazelisk-cache: true
186+
disk-cache: ${{ github.workflow }}
187+
repository-cache: true
188+
189+
- name: Format (unix)
190+
run: |
191+
bazel ${BAZEL_STARTUP_FLAGS[@]} run //python/black
192+
bazel ${BAZEL_STARTUP_FLAGS[@]} run //python/isort
193+
bazel ${BAZEL_STARTUP_FLAGS[@]} run //python/global_verilog
194+
if: startswith(runner.os, 'Windows') != true
195+
- name: Format (Windows)
196+
run: |
197+
bazel $env:BAZEL_STARTUP_FLAGS run //python/black
198+
bazel $env:BAZEL_STARTUP_FLAGS run //python/isort
199+
# TODO: https://github.com/periareon/rules_verilog/issues/57
200+
# bazel $env:BAZEL_STARTUP_FLAGS run //python/global_verilog
201+
if: startswith(runner.os, 'Windows')
202+
203+
- name: Git diff
204+
shell: bash
205+
run: |
206+
git diff
207+
if [[ -n "$(git status --porcelain)" ]]; then
208+
exit 1
209+
fi
210+
211+
ci-format:
212+
runs-on: ubuntu-24.04
213+
steps:
214+
# Checkout the code
215+
- uses: actions/checkout@v4
216+
- uses: bazel-contrib/setup-bazel@0.14.0
217+
with:
218+
bazelisk-cache: true
219+
disk-cache: ${{ github.workflow }}
220+
repository-cache: true
221+
222+
- uses: DoozyX/clang-format-lint-action@v0.14
223+
with:
224+
source: "."
225+
extensions: "h,c,cc"
226+
clangFormatVersion: 14
227+
228+
- name: Format (unix)
229+
run: |
230+
bazel ${BAZEL_STARTUP_FLAGS[@]} run //:buildifier_check
231+
232+
- name: Git diff
233+
shell: bash
234+
run: |
235+
git diff
236+
if [[ -n "$(git status --porcelain)" ]]; then
237+
exit 1
238+
fi
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
# This workflow will install Python dependencies, run tests and lint with a single version of Python
3+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
4+
5+
name: compile_requirements
6+
7+
on:
8+
workflow_dispatch:
9+
inputs:
10+
target:
11+
description: "The py_reqs_compiler target to run"
12+
default: "//python/3rdparty:requirements.update"
13+
14+
jobs:
15+
build:
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
include:
20+
- os: linux_x86_64
21+
runs-on: ubuntu-latest
22+
- os: linux_aarch64
23+
runs-on: ubuntu-24.04-arm
24+
- os: macos_aarch64
25+
runs-on: macos-latest
26+
- os: windows_x86_64
27+
runs-on: windows-latest
28+
29+
runs-on: ${{ matrix.runs-on }}
30+
name: ${{ matrix.os }}
31+
steps:
32+
- uses: actions/checkout@v4
33+
- name: Compile requirements
34+
if: runner.os == 'Windows'
35+
run: |
36+
bazel run "$env:TARGET" "--" "--upgrade" "--verbose"
37+
env:
38+
TARGET: ${{ github.event.inputs.target }}
39+
- name: Compile requirements
40+
if: runner.os != 'Windows'
41+
run: |
42+
bazel run "${TARGET}" "--" "--upgrade" "--verbose"
43+
env:
44+
TARGET: ${{ github.event.inputs.target }}
45+
- name: Display results
46+
shell: bash
47+
run: |
48+
set -e
49+
echo "<details>" >> "${GITHUB_STEP_SUMMARY}"
50+
echo "" >> "${GITHUB_STEP_SUMMARY}"
51+
echo '```' >> "${GITHUB_STEP_SUMMARY}"
52+
cat "python/3rdparty/requirements_${{ matrix.os }}.txt" >> "${GITHUB_STEP_SUMMARY}"
53+
echo '```' >> "${GITHUB_STEP_SUMMARY}"
54+
echo "" >> "${GITHUB_STEP_SUMMARY}"
55+
echo "</details>" >> "${GITHUB_STEP_SUMMARY}"

.github/workflows/docs.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Docs
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
docs:
10+
name: Docs
11+
permissions:
12+
contents: write
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@master
16+
- name: Run tests
17+
run: bazel run --compilation_mode=opt --stamp //docs:publish_book
18+
- name: Deploy to GitHub Pages
19+
uses: JamesIves/github-pages-deploy-action@4.1.7
20+
with:
21+
branch: gh-pages # The branch the action should deploy to.
22+
folder: docs/book # The folder the action should deploy.

0 commit comments

Comments
 (0)