#codegen #build #schema #serde #macro

build derive-codegen

Highly-configurable code generation tooling based on Rust types

5 releases

0.0.5 Mar 17, 2024
0.0.4 Jul 11, 2023
0.0.3 Jul 11, 2023
0.0.2 Jul 11, 2023
0.0.1 Jul 3, 2023

#184 in Build Utils

Download history 5/week @ 2024-02-16 12/week @ 2024-02-23 20/week @ 2024-03-01 17/week @ 2024-03-08 206/week @ 2024-03-15 15/week @ 2024-03-22 28/week @ 2024-03-29 18/week @ 2024-04-05 3/week @ 2024-04-12

70 downloads per month

Apache-2.0 OR MIT

73KB
1.5K SLoC

derive-codegen

WIP

'derive-codegen' allows you to build your own code generator based on rust enum and struct types.

Design:

  • Generation happens in two passes: 1. collect all the structural information from Rust code, 2. pass a JSON of all that structural information and your custom attributes to your own code generation command, which can be written in your preferred language.
  • You can "tag" your items in order to select which items should get generated for multiple code generators.
  • derive-codegen does minimal parsing and interpretation of serde attributes, and it is up to the codegen command to figure out what to do with aliases, rename, flatten, and others.

Interesting places in the codebase:

Dependencies

~2–2.9MB
~62K SLoC