bytecodealliance / wasi-rs

Experimental WASI API bindings for Rust
Apache License 2.0
273 stars 48 forks source link

Procedurally generate `raw.rs` #16

Closed alexcrichton closed 5 years ago

alexcrichton commented 5 years ago

This commit adds a script that uses the witx crate to parse the official WASI specification definitions and generate Rust bindings for the upstream APIs. The intention is that this isn't actually a breaking change in general (but it is in a few places that switch from *mut c_void to *mut u8).

A CI check is also added to ensure that the in-repository raw.rs is the same as what should be generated, which allows shipping this to crates.io without actually parsing *.witx at build time.

alexcrichton commented 5 years ago

After this @sunfishcode told me about https://github.com/CraneStation/wasi-common/pull/152 which is the same spirit. I'm not sure if we want to share more infrastructure than we're already sharing (the witx crate), though? There's some parts that are for sure reusable across the two but they're largely not too too complicated so it may not be the worst thing to have some duplication for now

alexcrichton commented 5 years ago

That all sounds good to me, should be updated and green now!

sunfishcode commented 5 years ago

Looking at this more, I agree that this PR makes sense. This crate is a dependency of libc, which is a dependency of a lot of things, so having a checked-in raw.rs instead of parsing the witx at build time sounds desirable. And there's not all that much duplication in the end. So let's do it!