technocreatives / dbc-codegen

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

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

Open liamkinne opened 6 months ago

liamkinne commented 6 months 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.