fzyzcjy / flutter_rust_bridge

Flutter/Dart <-> Rust binding generator, feature-rich, but seamless and simple.
https://fzyzcjy.github.io/flutter_rust_bridge/
MIT License
4.29k stars 300 forks source link

Passing feature flags to flutter_rust_bridge_codegen is not possible #2283

Closed fmeef closed 2 months ago

fmeef commented 2 months ago

Is your feature request related to a problem? Please describe. I have a crate that has a "flutter" feature, than when enabled adds the required dependencies and enables some flutter specific apis. This is because my crate is designed to be used both with and without flutter. Since feature flags are suppose to be additive I can't have it enabled by default.

Describe the solution you'd like Have a commandline argument and/or a config option to enable features (pass --features to cargo expand) during codegen

Describe alternatives you've considered Alternatives include making features default (and therefore subtractive) and using a dedicated 2nd crate. Because RUSTFLAGS isn't passed to cargo expand alone in the right place,

 RUSTFLAGS="--features flutter" flutter_rust_bridge_codegen generate

also fails with error: Unrecognized option: 'features'

Additional context I have a branch https://github.com/fmeef/flutter_rust_bridge/tree/cargo_features that adds this, making PR soon

welcome[bot] commented 2 months ago

Hi! Thanks for opening your first issue here! :smile:

fzyzcjy commented 2 months ago

Have a commandline argument and/or a config option to enable features (pass --features to cargo expand) during codegen

That looks reasonable, and https://github.com/fzyzcjy/flutter_rust_bridge/pull/2284 looks great!

github-actions[bot] commented 1 month ago

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new issue.