fn main() {
if std::env::var_os("DOCS_RS").is_some() {
return;
}
let lib_name = "libpulse";
let fallback_name = {
#[cfg(target_os = "linux")]
{ "pulse::libpulse.so.0" }
#[cfg(target_os = "macos")]
{ "pulse::libpulse.0.dylib" }
#[cfg(windows)]
{ "pulse::libpulse-0.dll" }
#[cfg(not(any(target_os = "linux", target_os = "macos", windows)))]
{ "pulse" }
};
let min_version = {
#[cfg(feature = "pa_v15")]
{ "15.0" }
#[cfg(all(feature = "pa_v14", not(feature = "pa_v15")))]
{ "14.0" }
#[cfg(all(feature = "pa_v13", not(feature = "pa_v14")))]
{ "13.0" }
#[cfg(all(feature = "pa_v12", not(feature = "pa_v13")))]
{ "12.0" }
#[cfg(all(feature = "pa_v8", not(feature = "pa_v12")))]
{ "8.0" }
#[cfg(all(feature = "pa_v6", not(feature = "pa_v8")))]
{ "6.0" }
#[cfg(not(feature = "pa_v6"))]
{ "5.0" }
};
let mut config = pkg_config::Config::new();
config.cargo_metadata(false);
let fallback = match config.probe(lib_name) {
Err(pkg_config::Error::ProbeFailure { .. }) |
Err(pkg_config::Error::Failure { .. }) => {
println!("cargo:warning=Pkg-config seems to not know about PulseAudio (dev package not installed?), \
trying generic fallback...");
true
},
Err(pkg_config::Error::EnvNoPkgConfig(_)) |
Err(pkg_config::Error::Command { .. }) => {
println!("cargo:warning=No pkg-config or disabled, trying generic fallback...");
true
},
_ => false,
};
if fallback {
println!("cargo:rustc-link-lib={}", fallback_name);
return;
}
config.cargo_metadata(true)
.atleast_version(min_version);
match config.probe(lib_name) {
Err(e) => {
println!("cargo:warning={}", e);
std::process::exit(1);
},
Ok(_) => {},
}
}