Skip to content

Commit 435c369

Browse files
Add build.rs config to use rust backends.
1 parent 1c01012 commit 435c369

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

cubeb-sys/build.rs

+28-1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,19 @@ fn main() {
4646
let android = target.contains("android");
4747
let mut cfg = cmake::Config::new("libcubeb");
4848

49+
// Also clone better-supported rust backends.
50+
if darwin {
51+
let _ = Command::new("git")
52+
.args(["clone", "https://github.com/mozilla/cubeb-coreaudio-rs.git"])
53+
.current_dir("libcubeb/src")
54+
.status();
55+
} else if !windows {
56+
let _ = Command::new("git")
57+
.args(["clone", "https://github.com/mozilla/cubeb-pulse-rs"])
58+
.current_dir("libcubeb/src")
59+
.status();
60+
}
61+
4962
if darwin {
5063
let cmake_osx_arch = if target.contains("aarch64") {
5164
// Apple Silicon
@@ -65,6 +78,9 @@ fn main() {
6578
.define("BUILD_SHARED_LIBS", "OFF")
6679
.define("BUILD_TESTS", "OFF")
6780
.define("BUILD_TOOLS", "OFF")
81+
// This is safe to set always; it's a no-op if the directories don't
82+
// exist
83+
.define("BUILD_RUST_LIBS", "ON")
6884
.build();
6985

7086
println!("cargo:rustc-link-lib=static=cubeb");
@@ -80,6 +96,11 @@ fn main() {
8096
println!("cargo:rustc-link-lib=framework=CoreAudio");
8197
println!("cargo:rustc-link-lib=framework=CoreServices");
8298
println!("cargo:rustc-link-lib=dylib=c++");
99+
println!("cargo:rustc-link-lib=static=cubeb_coreaudio");
100+
let mut search_path = std::env::current_dir().unwrap();
101+
// TODO: Also allow for debug?
102+
search_path.push("libcubeb/src/cubeb-coreaudio-rs/target/release");
103+
println!("cargo:rustc-link-search=native={}", search_path.display());
83104
println!("cargo:rustc-link-search=native={}/lib", dst.display());
84105
} else {
85106
if freebsd || android {
@@ -93,7 +114,13 @@ fn main() {
93114
// Ignore the result of find_library. We don't care if the
94115
// libraries are missing.
95116
let _ = pkg_config::find_library("alsa");
96-
let _ = pkg_config::find_library("libpulse");
117+
if pkg_config::find_library("libpulse").is_ok() || true {
118+
println!("cargo:rustc-link-lib=static=cubeb_pulse");
119+
let mut search_path = std::env::current_dir().unwrap();
120+
// TODO: Also allow for debug?
121+
search_path.push("libcubeb/src/cubeb-pulse/target/release");
122+
println!("cargo:rustc-link-search=native={}", search_path.display());
123+
}
97124
let _ = pkg_config::find_library("jack");
98125
let _ = pkg_config::find_library("speexdsp");
99126
if android {

0 commit comments

Comments
 (0)