diff --git a/lib/Cargo.toml b/lib/Cargo.toml index f48bb59..2a9b2ab 100644 --- a/lib/Cargo.toml +++ b/lib/Cargo.toml @@ -11,6 +11,12 @@ license = "MIT" readme.workspace = true +[features] +# Generate the bindings for 64-bit even if the host is 32-bit. +arch64 = [] +# Generate the bindings for 32-bit even if the host is 64-bit. +arch32 = [] + [dependencies] nix = { version = "0.28", features = ["ioctl", "mman", "poll", "fs", "event"] } bitflags = "2.4" diff --git a/lib/build.rs b/lib/build.rs index 608ec6d..a3b7f69 100644 --- a/lib/build.rs +++ b/lib/build.rs @@ -30,9 +30,17 @@ fn main() { println!("cargo::rerun-if-changed={}", videodev2_h.display()); println!("cargo::rerun-if-changed={}", WRAPPER_H); + let clang_args = [ + format!("-I{}", videodev2_h_path), + #[cfg(all(feature = "arch64", not(feature = "arch32")))] + "--target=x86_64-linux-gnu".into(), + #[cfg(all(feature = "arch32", not(feature = "arch64")))] + "--target=i686-linux-gnu".into(), + ]; + let bindings = v4l2r_bindgen_builder(bindgen::Builder::default()) .header(WRAPPER_H) - .clang_args([format!("-I{}", videodev2_h_path)]) + .clang_args(clang_args) .generate() .expect("unable to generate bindings");