Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate standalone files for Regz by default #353

Merged
merged 9 commits into from
Jan 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
152 changes: 82 additions & 70 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,15 @@ on:
branches: [main, zig-master]
pull_request:
branches: [main, zig-master]
workflow_dispatch:

env:
ZIG_VERSION: ${{ github.ref == 'refs/heads/zig-master' && 'master' || '0.13.0' }}

jobs:
build:
name: Build
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Zig
uses: mlugg/setup-zig@v1
with:
version: ${{ env.ZIG_VERSION }}
- name: Build
run: zig build -Doptimize=ReleaseSmall

unit-test-ports:
name: Unit Test Ports
runs-on: ${{ matrix.os }}
needs: build
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
port_dir: [gigadevice/gd32, raspberrypi/rp2xxx, stmicro/stm32]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Zig
uses: mlugg/setup-zig@v1
with:
version: ${{ env.ZIG_VERSION }}
- name: Unit Test Ports
run: zig build test
working-directory: port/${{ matrix.port_dir }}

unit-test-regz:
name: Unit Test Regz
continue-on-error: true
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
Expand All @@ -60,6 +30,7 @@ jobs:

unit-test-uf2:
name: Unit Test UF2
continue-on-error: true
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
Expand All @@ -75,48 +46,71 @@ jobs:
run: zig build test
working-directory: tools/uf2

build-website:
name: Build Website
stm32-gen-check:
name: Check that stm32 generated code is up to date
continue-on-error: true
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Zig
uses: mlugg/setup-zig@v1
with:
version: ${{ env.ZIG_VERSION }}
- name: Generate Code
run: zig build -Dgenerate
working-directory: port/stmicro/stm32
- name: Check for code diffs
run: |
if [[ $(git status --porcelain | grep -v '^??') ]]; then
echo "Code differences detected:"
git diff
echo "Please commit or fix these changes to proceed."
exit 1
else
echo "No code differences detected."
fi

build:
name: Build
continue-on-error: true
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Zig
uses: mlugg/setup-zig@v1
with:
version: ${{ env.ZIG_VERSION }}
- name: Build Website
run: zig build
working-directory: website
- name: Build
run: zig build -Doptimize=ReleaseSmall

dry-run-packaging:
name: Dry Run Packaging
runs-on: macos-latest
unit-test-ports:
name: Unit Test Ports
continue-on-error: true
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
port_dir: [gigadevice/gd32, raspberrypi/rp2xxx, stmicro/stm32]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Zig
uses: mlugg/setup-zig@v1
with:
version: ${{ env.ZIG_VERSION }}
- name: Dry Run Packaging
run: |
MICROZIG_VERSION=$(zig build package -- get-version)
echo microzig version: $MICROZIG_VERSION
zig build package -- http://localhost:8000
python3 -m http.server 8000 --directory boxzer-out &
sleep 1

cd tools/package-test
zig fetch --save=microzig http://localhost:8000/${MICROZIG_VERSION}/microzig.tar.gz
zig build -Doptimize=ReleaseSmall

jobs -p | xargs kill
- name: Unit Test Ports
run: zig build test
working-directory: port/${{ matrix.port_dir }}

build-examples:
name: Build Examples
continue-on-error: true
runs-on: ubuntu-latest
needs: build
strategy:
matrix:
example_dir:
Expand All @@ -142,26 +136,44 @@ jobs:
run: zig build -Doptimize=ReleaseSmall --summary all
working-directory: examples/${{ matrix.example_dir }}

stm32-gen-check:
name: Check that stm32 generated code is up to date


build-website:
name: Build Website
continue-on-error: true
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v4
- name: Setup Zig
uses: mlugg/setup-zig@v1
with:
version: ${{ env.ZIG_VERSION }}
- name: Generate Code
run: zig build -Dgenerate
working-directory: port/stmicro/stm32
- name: Check for code diffs
- name: Build Website
run: zig build
working-directory: website

dry-run-packaging:
name: Dry Run Packaging
continue-on-error: true
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Zig
uses: mlugg/setup-zig@v1
with:
version: ${{ env.ZIG_VERSION }}
- name: Dry Run Packaging
run: |
if [[ $(git status --porcelain | grep -v '^??') ]]; then
echo "Code differences detected:"
git diff
echo "Please commit or fix these changes to proceed."
exit 1
else
echo "No code differences detected."
fi
MICROZIG_VERSION=$(zig build package -- get-version)
echo microzig version: $MICROZIG_VERSION
zig build package -- http://localhost:8000
python3 -m http.server 8000 --directory boxzer-out &
sleep 1

cd tools/package-test
zig fetch --save=microzig http://localhost:8000/${MICROZIG_VERSION}/microzig.tar.gz
zig build -Doptimize=ReleaseSmall

jobs -p | xargs kill
1 change: 1 addition & 0 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ pub fn MicroBuild(port_select: PortSelect) type {
.atdf, .svd => |file| blk: {
const regz_run = b.addRunArtifact(regz_exe);

regz_run.addArg("--microzig");
regz_run.addArg("--format");
regz_run.addArg(@tagName(target.chip.register_definition));

Expand Down
2 changes: 1 addition & 1 deletion port/stmicro/stm32/src/generate.zig
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ pub fn main() !void {

try db.backup("stm32.regz");

db.to_zig(out_file.writer()) catch |err| {
db.to_zig(out_file.writer(), .{ .for_microzig = true }) catch |err| {
std.log.err("Failed to write", .{});
return err;
};
Expand Down
6 changes: 4 additions & 2 deletions tools/regz/src/Database.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2031,8 +2031,10 @@ pub fn apply_patch(db: *Database, ndjson: []const u8) !void {
}
}

pub fn to_zig(db: *Database, out_writer: anytype) !void {
try gen.to_zig(db, out_writer);
pub const ToZigOptions = gen.ToZigOptions;

pub fn to_zig(db: *Database, out_writer: anytype, opts: ToZigOptions) !void {
try gen.to_zig(db, out_writer, opts);
}

test "all" {
Expand Down
Loading
Loading