I want to do some sophisticated code generation within a Cargo project, but I’m unsure how to do this. I basically want to have a crate which generates code from an XML specification. To generate this code, the generator requires some options.
@bjz’s gl-rs project seems to do something very similar, the build script generates bindings to the OpenGL library depending on some options. This code just seems to be spitted into the crate however. I would like to have the generated code by in a seperate crate, so I can make it a dynamic library, and when other crates depend on it, I don’t have to regenerate and rebuild it for every crate.
The issue I am facing is that when I generate the code inside a seperate package, I cannot pass options anymore regarding how to build it. When I generate the code inside the package using the code, it’ll always be statically linked, and I cannot make it a dynamic library anymore.
Does anyone have any ideas on how to get the best of both worlds, meaning having the generated code rest in a seperate crate and pass options to the code generator.