lerouxrgd / rsgen-avro

Command line and library for generating Rust types from Avro schemas
MIT License
37 stars 29 forks source link

Split CLI binary from the library crate #58

Closed oshevtsov closed 1 year ago

oshevtsov commented 1 year ago

I am using rsgen-avro at work for Rust code generation based on Avro schema files. The application we are building is for an IoT system that is run on a custom Yocto linux build. We are using rsgen-avro as a library (we do not use the generated CLI binary). The issue with the rsgen-avro>=0.12.0 is the dependency on clap@4. Since the latter installs the most recent version, which is clap@4.4.1 as of today, it requires at least Rust 1.70 to compile. Unfortunately, the latest supported Rust version on Yocto today is 1.68 (see [1] and [2]).

With the current structure of the package, we are stuck on rsgen-avro@0.11.1 until Yocto project supports at least Rust 1.70. We would greatly benefit from using the latest version, rsgen-avro>=0.12.2, but this requires modifying slightly the package structure.

With this change I propose to split the binary generation from the library crate using a feature flag. One can still generate the binary, if needed (and it will be done by the CI/CD pipeline), but the benefit is that the library crate does not depend on clap@4 and therefore any other package that uses rsgen-avro as a library skips installing clap as dependency.

[1] https://docs.yoctoproject.org/dev/migration-guides/release-notes-4.2.html [2] https://wiki.yoctoproject.org/wiki/Releases

lerouxrgd commented 1 year ago

That's a good point, thanks for the careful fix !

oshevtsov commented 1 year ago

Thank you for looking at this and the great library :slightly_smiling_face: