Skip to content

Commit

Permalink
Enable cross-compilation of rust libraries.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mutexlox-signal committed Nov 1, 2024
1 parent 4bdfda6 commit a3f441e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cubeb-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<bool>().unwrap();
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit a3f441e

Please sign in to comment.