Use `codegenrs`?
kazk opened this issue · comments
codegenrs
makes it easy to get rid of code-gen inbuild.rs
, reducing build times for your crate and those that depend on itThis is done by:
- Creating a child
[[bin]]
crate that does code-gen usingcodegenrs
- Do one-time code-gen and commit it
- Run the
--check
step in your CI to ensure your code-gen is neither out of
date or been human edited.
Seems to support using rustfmt
to format the generated code. https://github.com/crate-ci/imperative/blob/f7955ed1deda8abc8aeacc3a41aca23b3acc47d0/codegen/src/main.rs#L99
It's a pretty simple library. It's only one file, the rustfmt part is a simple shell hook, and the the generation part doesn't look like it can deal with appending to existing files easily - which we would need.
We could do this with a crate and a [[bin]]
entry anyway though. But I think we can probably generate and run rustfmt
as part of our build script here.