ExPixel / miniaudio-rs

Rust bindings for miniaudio C library.
https://crates.io/crates/miniaudio
MIT License
49 stars 20 forks source link

Perhaps include bindings #40

Closed sagacity closed 3 years ago

sagacity commented 3 years ago

It's a bit tricky to build miniaudio-rs on Windows because the bindings require llvm and clang. Normally this would just be a matter of installing them but llvm-config is not part of the installer and will only be available if llvm is built from source. This seems like a fairly high barrier to entry 😄

Would it be possible to include pre-generated bindings in the crate somehow (e.g. similar to how https://github.com/Gekkio/imgui-rs does this, for instance)? This would remove the need for having llvm and clang installed.

ExPixel commented 3 years ago

That's what I had before actually (I hand wrote the bindings at first, and then later just generated them using bindgen locally), but it caused some issues because of the many ifdefs that change miniaudio's public API — mostly the size and alignment of structs — for each platform. What I'll probably do is set up some GitHub action to generate the bindings per platform. I'll see if I can get that done over the weekend.

sagacity commented 3 years ago

That would be awesome!

ExPixel commented 3 years ago

I found some time and have pushed a change to master that will have pre-generated bindings created, tested, and pushed for linux-x86_64, macos-x86_64, and windows-x86_64 targets. Unfortunately I don't have a Windows machine to test on right now but it all seems to be working in CI at least. Now if you use miniaudio without default features bindgen shouldn't be included by default.

miniaudio = { default-features = false, features = ["ma-log-level-error"] }

for the default features without bindgen.

sagacity commented 3 years ago

I can confirm master works on Windows! I haven't done a rigorous check of all features, but basic playback and seeking of streams works so I guess this is fine.

Thanks for taking the time to fix this :heart: