Skip to content

Commit

Permalink
Add build.rs config to use rust backends.
Browse files Browse the repository at this point in the history
  • Loading branch information
mutexlox-signal committed Jul 31, 2024
1 parent 1c01012 commit 435c369
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion cubeb-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,19 @@ fn main() {
let android = target.contains("android");
let mut cfg = cmake::Config::new("libcubeb");

// Also clone better-supported rust backends.
if darwin {
let _ = Command::new("git")
.args(["clone", "https://github.com/mozilla/cubeb-coreaudio-rs.git"])
.current_dir("libcubeb/src")
.status();
} else if !windows {
let _ = Command::new("git")
.args(["clone", "https://github.com/mozilla/cubeb-pulse-rs"])
.current_dir("libcubeb/src")
.status();
}

if darwin {
let cmake_osx_arch = if target.contains("aarch64") {
// Apple Silicon
Expand All @@ -65,6 +78,9 @@ fn main() {
.define("BUILD_SHARED_LIBS", "OFF")
.define("BUILD_TESTS", "OFF")
.define("BUILD_TOOLS", "OFF")
// This is safe to set always; it's a no-op if the directories don't
// exist
.define("BUILD_RUST_LIBS", "ON")
.build();

println!("cargo:rustc-link-lib=static=cubeb");
Expand All @@ -80,6 +96,11 @@ fn main() {
println!("cargo:rustc-link-lib=framework=CoreAudio");
println!("cargo:rustc-link-lib=framework=CoreServices");
println!("cargo:rustc-link-lib=dylib=c++");
println!("cargo:rustc-link-lib=static=cubeb_coreaudio");
let mut search_path = std::env::current_dir().unwrap();
// TODO: Also allow for debug?
search_path.push("libcubeb/src/cubeb-coreaudio-rs/target/release");
println!("cargo:rustc-link-search=native={}", search_path.display());
println!("cargo:rustc-link-search=native={}/lib", dst.display());
} else {
if freebsd || android {
Expand All @@ -93,7 +114,13 @@ fn main() {
// Ignore the result of find_library. We don't care if the
// libraries are missing.
let _ = pkg_config::find_library("alsa");
let _ = pkg_config::find_library("libpulse");
if pkg_config::find_library("libpulse").is_ok() || true {
println!("cargo:rustc-link-lib=static=cubeb_pulse");
let mut search_path = std::env::current_dir().unwrap();
// TODO: Also allow for debug?
search_path.push("libcubeb/src/cubeb-pulse/target/release");
println!("cargo:rustc-link-search=native={}", search_path.display());
}
let _ = pkg_config::find_library("jack");
let _ = pkg_config::find_library("speexdsp");
if android {
Expand Down

0 comments on commit 435c369

Please sign in to comment.