Support conditional derives / custom attributes
As far as I can tell, #1089 was resolved by the ability to add custom derives. The support for more custom attributes beyond just listing derives wasn't part of the resolution.
I have a case where the derive needs to be conditional (cfg_attr(feature = "feat1", derive(MyDerive))) and the bindings are not being generated from the build script (in this case: to reduce build system dependencies). I have a workaround generating a set of bindings for each combination of conditions but this
- is unwieldy / awkward
- only works for derives and I have at least one case where I need to manually add an attribute currently
It would be appreciated if ParseCallbacks::add_derives could be extended to a more general ParseCallbacks::add_attributes
This would also fix https://github.com/rust-lang/rust-bindgen/discussions/2513
I have just opened https://github.com/rust-lang/rust-bindgen/pull/2866. :)