Skip to content

Commit 6c68177

Browse files
Be-ingiparaskev
authored andcommitted
use pkg-config to find Linux libraries (#2)
1 parent 15d762a commit 6c68177

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

webrtc-sys/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,8 @@ cxx-build = "1.0"
2222
glob = "0.3"
2323
cc = "1.0"
2424

25+
[target.'cfg(target_os = "linux")'.build-dependencies]
26+
pkg-config = "0.3.22"
27+
2528
[dev-dependencies]
2629
env_logger = "0.10"

webrtc-sys/build.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,21 @@ fn main() {
155155
println!("cargo:rustc-link-lib=dylib=pthread");
156156
println!("cargo:rustc-link-lib=dylib=m");
157157

158-
println!("cargo:rustc-link-lib=dylib=glib-2.0");
159-
println!("cargo:rustc-link-lib=dylib=gobject-2.0");
160-
println!("cargo:rustc-link-lib=dylib=gio-2.0");
161-
println!("cargo:rustc-link-lib=dylib=drm");
162-
println!("cargo:rustc-link-lib=dylib=gbm");
158+
if std::env::var("LK_CUSTOM_WEBRTC").is_ok() {
159+
for lib_name in ["glib-2.0", "gobject-2.0", "gio-2.0"] {
160+
let lib = pkg_config::probe_library(lib_name).unwrap();
161+
builder.includes(lib.include_paths);
162+
}
163+
} else {
164+
println!("cargo:rustc-link-lib=dylib=glib-2.0");
165+
println!("cargo:rustc-link-lib=dylib=gobject-2.0");
166+
println!("cargo:rustc-link-lib=dylib=gio-2.0");
167+
add_gio_headers(&mut builder);
168+
}
163169

164-
add_gio_headers(&mut builder);
170+
for lib_name in ["libdrm", "gbm"] {
171+
pkg_config::probe_library(lib_name).unwrap();
172+
}
165173

166174
match target_arch.as_str() {
167175
"x86_64" => {

0 commit comments

Comments
 (0)