Skip to content

Commit

Permalink
v4l2-sys: Only use FreeBSD header include if the (cross-compilation) …
Browse files Browse the repository at this point in the history
…target OS is FreeBSD

With `cfg!()` on `target_os` this include path is unconditionally used
if the _host_ OS is FreeBSD, even if the target OS is different (and its
cross-compilation headers are installed elsewhere on the system).  The
accurate target OS, regardless of what the build script is _running on_
is stored in `CARGO_CFG_TARGET_OS`.
  • Loading branch information
MarijnS95 committed Sep 19, 2024
1 parent 677b02d commit 7ac2f1b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion v4l2-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ use std::env;
use std::path::{Path, PathBuf};

fn main() {
let extra_include_paths = if cfg!(target_os = "freebsd") {
let extra_include_paths = if std::env::var("CARGO_CFG_TARGET_OS").unwrap() == "freebsd" {
// XXX: This path is wrong if the host OS != cross-compilation OS. If anything the host
// should simply set up the right path using `BINDGEN_EXTRA_CLANG_ARGS_<triple>`, allowing
// us to remove this workaround instead.
assert!(
Path::new("/usr/local/include/linux/videodev2.h").exists(),
"Video4Linux `videodev2.h` UAPI header is required to generate bindings \
Expand Down

0 comments on commit 7ac2f1b

Please sign in to comment.