technocreatives / dbc-codegen

Generate Rust structs for messages from a dbc (CAN bus definition) file.
Apache License 2.0
43 stars 22 forks source link

Put codegen output into `OUT_DIR` rather than `src/` #76

Open liamkinne opened 1 month ago

liamkinne commented 1 month ago

The current guidance of putting code generated by a build.rs script into src/ is generally not a good idea (see here). It leads to it being checked into source control and people trying to make edits to it.

Trying to put the current output of codegen into OUT_DIR causes errors to do with inner attributes not being permitted. This PR implements a config parameter clippy_attributes which turns off generating these attributes by default. They are turned back on for the CLI as it is assumed the user will be placing the output into src/ in that case.

Also see prost_build for a good template for how code generation from an interface format should work.