feat: generate C headers from layouts#85
Open
tomrford wants to merge 3 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
mint_core::header::generateand themint header FILE[#BLOCK]... -o FILEcommandValidation
nix develop -c cargo fmt --all -- --checknix develop -c cargo clippy --workspace --all-targets -- -D warningsnix develop -c cargo test --workspace --lockednix develop -c uv run --directory crates/mint-python --group dev maturin develop --manifest-path Cargo.tomlnix develop -c uv run --directory crates/mint-python --group dev pytest testsCloses #70
Note
Medium Risk
New public API and CLI surface with substantial header-generation logic; risk is moderate because failures are validated before write and coverage includes C ABI checks, but firmware could still diverge if target alignment differs from Mint’s contract.
Overview
Adds C header generation from the same TOML layout selectors used for flash builds, so the layout can own struct shape for firmware without a data source.
mint_core::header::generateresolves blocks via sharedresolve_blocks, builds nestedtypedef structtrees from dotted paths, maps scalars/fixed-point to<stdint.h>types, and emits array_LEN/_ROWS/_COLSmacros plus named bitmap_SHIFT/_MASKmacros. It validates C identifiers, keywords, ref targets, field-tree collisions, and upper-snake macro/typedef collisions before returning the full header string;MintError::InHeaderBlockwraps per-block failures.The CLI gains
mint header FILE[#BLOCK]... -o FILE, wired through sharedwrite_textfile output. Docs, README, skill text, anddoc/examples/blocks.hare updated to the generated format (include guard, extent macros). Tests cover deterministic output, validation errors, unchanged output on failure, and a warnings-as-errors C11 compile of the example header against layout offsets/sizes.Reviewed by Cursor Bugbot for commit f2f79f9. Configure here.