From 8a8df27e168d4db6c21e333c4415cbeb2001c0d8 Mon Sep 17 00:00:00 2001 From: Miriam Zimmerman Date: Fri, 1 Nov 2024 15:19:13 -0400 Subject: [PATCH] Enable cross-compilation of rust libraries. cubeb's CMakeLists.txt just does `cargo build`, which lets callers cross-compile if they desire, by setting CARGO_BUILD_TARGET. However, that will place the output in a different directory. So, always specify *a* CARGO_BUILD_TARGET to force cargo to place the built rust backends in a known location. --- cubeb-sys/build.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cubeb-sys/build.rs b/cubeb-sys/build.rs index 299221c..2346ffe 100644 --- a/cubeb-sys/build.rs +++ b/cubeb-sys/build.rs @@ -98,6 +98,9 @@ fn main() { .define("BUILD_TESTS", "OFF") .define("BUILD_TOOLS", "OFF") .define("BUILD_RUST_LIBS", build_rust_libs) + // Force rust libs to include target triple when outputting, + // for easier linking when cross-compiling. + .env("CARGO_BUILD_TARGET", &target) .build(); let debug = env::var("DEBUG").unwrap().parse::().unwrap(); @@ -127,6 +130,7 @@ fn main() { println!("cargo:rustc-link-lib=static=cubeb_coreaudio"); let mut search_path = std::env::current_dir().unwrap(); search_path.push(&(libcubeb_path + "/src/cubeb-coreaudio-rs/target")); + search_path.push(&target); if debug { search_path.push("debug"); } else { @@ -157,6 +161,7 @@ fn main() { println!("cargo:rustc-link-lib=static=cubeb_pulse"); let mut search_path = std::env::current_dir().unwrap(); search_path.push(&(libcubeb_path + "/src/cubeb-pulse-rs/target")); + search_path.push(&target); if debug { search_path.push("debug"); } else {