Skip to content

Commit

Permalink
enable dlopen feature with env var RUST_JACK_DLOPEN
Browse files Browse the repository at this point in the history
  • Loading branch information
Be-ing committed Feb 22, 2022
1 parent d7800ef commit 5f84250
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
7 changes: 7 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
fn main() {
println!("cargo:rerun-if-env-changed=RUST_JACK_DLOPEN");
let dlopen = std::env::var("RUST_JACK_DLOPEN").is_ok();
if dlopen {
println!("cargo:rustc-cfg=feature=\"dlopen\"");
}
}
18 changes: 12 additions & 6 deletions jack-sys/build.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
fn main() {
// pkg-config is required to find PipeWire's implementation of libjack
// Refer to https://github.com/RustAudio/rust-jack/issues/142 for details.
// Do not unwrap this because linking might still work if pkg-config is
// not installed, for example on Windows.
#[cfg(not(feature = "dlopen"))]
let _ = pkg_config::probe_library("jack");
println!("cargo:rerun-if-env-changed=RUST_JACK_DLOPEN");
let dlopen = std::env::var("RUST_JACK_DLOPEN").is_ok();
if dlopen {
println!("cargo:rustc-cfg=feature=\"dlopen\"");
}
if !(dlopen || cfg!(feature = "dlopen")) {
// pkg-config is required to find PipeWire's implementation of libjack
// Refer to https://github.com/RustAudio/rust-jack/issues/142 for details.
// Do not unwrap this because linking might still work if pkg-config is
// not installed, for example on Windows.
pkg_config::find_library("jack").unwrap();
}
}
4 changes: 4 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
//! jack = { version = "0.9", default-features = false }
//! ```
//!
//! You can set the environment variable `RUST_JACK_DLOPEN` to `on` to enable the `dlopen` feature
//! without needing to edit your application's Cargo.toml. This can be useful for cross compiling
//! to Linux with a different CPU architecture.
//!
//! # Server
//!
//! JACK provides a high priority server to manipulate audio and midi across applications. The rust
Expand Down

0 comments on commit 5f84250

Please sign in to comment.