fc4fb70232
The 17.1.6 Bazel migration dropped maudio's generate-bindings feature, so the darwin addon shipped maudio-sys's Linux-shaped pregenerated miniaudio bindings. Those bindings omit the MA_SUPPORT_COREAUDIO backend-state union members that the macOS build of miniaudio.c actually contains, producing a Rust/C ABI mismatch: capture callbacks saw zero channels and yielded no PCM. Re-enable generate-bindings for apple targets only. Patch maudio-sys's build script to branch on Cargo's TARGET rather than the build-script host, so a macOS-hosted Linux/Windows cross-build keeps target-family pregenerated bindings instead of incorrectly running Darwin bindgen. Repin the Bazel graph to apply the patch and gate bindgen behind the apple target selects. Fixes #6846
39 lines
1.4 KiB
Diff
39 lines
1.4 KiB
Diff
--- a/build.rs
|
|
+++ b/build.rs
|
|
@@ -5,6 +5,12 @@ use cc::Build;
|
|
|
|
#[cfg(feature = "generate-bindings")]
|
|
fn write_bindings(out_bindings: &std::path::Path) {
|
|
+ let target = env::var("TARGET").expect("TARGET must be set by Cargo");
|
|
+ if !target.contains("apple-darwin") {
|
|
+ copy_bindings(&target, out_bindings);
|
|
+ return;
|
|
+ }
|
|
+
|
|
let mut builder = bindgen::Builder::default()
|
|
.header("native/miniaudio/miniaudio.h")
|
|
.clang_arg("-Inative")
|
|
@@ -25,11 +31,17 @@ fn write_bindings(out_bindings: &std::path::Path) {
|
|
|
|
#[cfg(not(feature = "generate-bindings"))]
|
|
fn write_bindings(out_bindings: &std::path::Path) {
|
|
+ let target = env::var("TARGET").expect("TARGET must be set by Cargo");
|
|
+ copy_bindings(&target, out_bindings);
|
|
+}
|
|
+
|
|
+fn copy_bindings(target: &str, out_bindings: &std::path::Path) {
|
|
eprintln!("Copying bindings");
|
|
- #[cfg(unix)]
|
|
- std::fs::copy("src/pregen_bindings/unix.rs", out_bindings)
|
|
- .expect("Failed to copy pre-generated bindings to OUT_DIR");
|
|
- #[cfg(windows)]
|
|
- std::fs::copy("src/pregen_bindings/windows.rs", out_bindings)
|
|
+ let source = if target.contains("windows") {
|
|
+ "src/pregen_bindings/windows.rs"
|
|
+ } else {
|
|
+ "src/pregen_bindings/unix.rs"
|
|
+ };
|
|
+ std::fs::copy(source, out_bindings)
|
|
.expect("Failed to copy pre-generated bindings to OUT_DIR");
|
|
}
|