From 7ac2f1baab16e9dfe5c74d4fa09ba10cc76701ec Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Thu, 19 Sep 2024 11:36:42 +0200 Subject: [PATCH] v4l2-sys: Only use FreeBSD header include if the (cross-compilation) 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`. --- v4l2-sys/build.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/v4l2-sys/build.rs b/v4l2-sys/build.rs index 8f09e8b..54df410 100644 --- a/v4l2-sys/build.rs +++ b/v4l2-sys/build.rs @@ -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_`, 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 \