build: Use pkg-config to find vlc
parent
55310d8bd3
commit
12a22eb8a4
|
@ -1,5 +1,6 @@
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
use pkg_config;
|
||||||
|
|
||||||
#[cfg(feature = "bindgen")]
|
#[cfg(feature = "bindgen")]
|
||||||
fn generate_bindings() {
|
fn generate_bindings() {
|
||||||
|
@ -46,6 +47,12 @@ fn copy_pregenerated_bindings()
|
||||||
.expect("Couldn't find pregenerated bindings!");
|
.expect("Couldn't find pregenerated bindings!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn link_vlc_with_pkgconfig() -> Result<pkg_config::Library, pkg_config::Error> {
|
||||||
|
pkg_config::Config::new()
|
||||||
|
.print_system_libs(false)
|
||||||
|
.probe("libvlc")
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
mod windows {
|
mod windows {
|
||||||
#[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
|
#[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
|
||||||
|
@ -164,8 +171,13 @@ fn main() {
|
||||||
copy_pregenerated_bindings();
|
copy_pregenerated_bindings();
|
||||||
|
|
||||||
// Link
|
// Link
|
||||||
#[cfg(target_os = "windows")]
|
if let Err(err) = link_vlc_with_pkgconfig() {
|
||||||
windows::link_vlc();
|
#[cfg(target_os = "windows")]
|
||||||
|
windows::link_vlc();
|
||||||
|
|
||||||
|
#[cfg(not(target_os = "windows"))]
|
||||||
|
panic!("libvlc not found: {:?}", err);
|
||||||
|
}
|
||||||
|
|
||||||
println!("cargo:rustc-link-lib=vlc");
|
println!("cargo:rustc-link-lib=vlc");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue