cargo-component icon indicating copy to clipboard operation
cargo-component copied to clipboard

build.rs support for cargo-component

Open ryankurte opened this issue 5 months ago • 0 comments

hi folks,

playing with building wasm components and it seems the current approach requires one to run cargo component bindings to generate a src/bindings.rs file, which then has to be committed into the repository for whatever component (and re-committed on any changes).

a more common/rusty way to do this that avoids generated files being included in the source tree would be to invoke the binding generation from build.rs then import the generated bindings (like bindgen does).

have you considered supporting this approach? i see adding build.rs support was discussed in https://github.com/bytecodealliance/cargo-component/issues/362 but not actioned. it seems like generating the bindings from build.rs should be straightforward, then cargo component would need to pick up a flag or something to say that it shouldn't generate bindings itself.

cheers,

ryan

ryankurte avatar Aug 04 '25 22:08 ryankurte