Debian Codegraph @

build.rs

raw symbols SCIP
1 fn main() {
2 // On NetBSD and OpenBSD, inotify is provided by a userspace library
3 // (libinotify) rather than the kernel. Link against it when building for
4 // those targets.
5 //
6 // FreeBSD ships native inotify support with libc wrappers in libc.so.7, so
7 // the extern declarations resolve against libc directly there.
8 let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap();
9
10 let needs_libinotify = match target_os.as_str() {
11 "netbsd" | "openbsd" => true,
12 _ => false,
13 };
14
15 if needs_libinotify {
16 // Use pkg-config to find the library search path if available,
17 // otherwise fall back to /usr/local/lib (the conventional BSD prefix).
18 let lib_dir = std::process::Command::new("pkg-config")
19 .args(["--variable=libdir", "libinotify"])
20 .output()
21 .ok()
22 .filter(|o| o.status.success())
23 .and_then(|o| String::from_utf8(o.stdout).ok())
24 .map(|s| s.trim().to_owned())
25 .unwrap_or_else(|| "/usr/local/lib".to_owned());
26
27 println!("cargo:rustc-link-search=native={lib_dir}");
28 println!("cargo:rustc-link-lib=inotify");
29 }
30 }