Skip to content

Commit 677b02d

Browse files
authored
Avoid libv4l2 pkg-config dependency added by mistake (#106)
User API header file required to generate bindings in `v4l2-sys` is not part of `libv4l2`. Instead directly check if UAPI header file is present on FreeBSD and extend compiler's include paths. Or guide user towards necessary package if header file is missing.
1 parent 8953d41 commit 677b02d

2 files changed

Lines changed: 13 additions & 11 deletions

File tree

v4l2-sys/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,3 @@ build = "build.rs"
99

1010
[build-dependencies]
1111
bindgen = "0.69.1"
12-
pkg-config = "0.3.30"

v4l2-sys/build.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
11
extern crate bindgen;
22

33
use std::env;
4-
use std::path::PathBuf;
4+
use std::path::{Path, PathBuf};
55

66
fn main() {
7-
let pkg_conf = pkg_config::Config::new()
8-
.probe("libv4l2")
9-
.expect("pkg-config has failed to find `libv4l2`");
7+
let extra_include_paths = if cfg!(target_os = "freebsd") {
8+
assert!(
9+
Path::new("/usr/local/include/linux/videodev2.h").exists(),
10+
"Video4Linux `videodev2.h` UAPI header is required to generate bindings \
11+
against `libv4l2` and the header file is missing.\n\
12+
Consider installing `multimedia/v4l_compat` FreeBSD package."
13+
);
14+
vec!["-I/usr/local/include"]
15+
} else {
16+
vec![]
17+
};
1018

1119
let bindings = bindgen::Builder::default()
1220
.header("wrapper.h")
13-
.clang_args(
14-
pkg_conf
15-
.include_paths
16-
.into_iter()
17-
.map(|path| format!("-I{}", path.to_string_lossy())),
18-
)
21+
.clang_args(extra_include_paths)
1922
.generate()
2023
.expect("Failed to generate bindings");
2124

0 commit comments

Comments
 (0)