(ffmpeg_include_dir: &Path, headers: &[PathBuf])
| 192 | } |
| 193 | |
| 194 | fn generate_bindings(ffmpeg_include_dir: &Path, headers: &[PathBuf]) -> Bindings { |
| 195 | if !Path::new(ffmpeg_include_dir).exists() { |
| 196 | panic!( |
| 197 | "FFmpeg include dir: `{:?}` doesn't exits", |
| 198 | ffmpeg_include_dir |
| 199 | ); |
| 200 | } |
| 201 | // Because of the strange `FP_*` in `math.h` https://github.com/rust-lang/rust-bindgen/issues/687 |
| 202 | let filter_callback = FilterCargoCallbacks::new( |
| 203 | [ |
| 204 | "FP_NAN", |
| 205 | "FP_INFINITE", |
| 206 | "FP_ZERO", |
| 207 | "FP_SUBNORMAL", |
| 208 | "FP_NORMAL", |
| 209 | ] |
| 210 | .into_iter() |
| 211 | .collect(), |
| 212 | ); |
| 213 | |
| 214 | // Bindgen on all avaiable headers |
| 215 | headers |
| 216 | .iter() |
| 217 | .map(|header| ffmpeg_include_dir.join(header)) |
| 218 | .filter(|path| { |
| 219 | let exists = Path::new(&path).exists(); |
| 220 | if !exists { |
| 221 | eprintln!("Header path `{:?}` not found.", path); |
| 222 | } |
| 223 | exists |
| 224 | }) |
| 225 | .fold( |
| 226 | { |
| 227 | bindgen::builder() |
| 228 | // Force impl Debug if possible(for `AVCodecParameters`) |
| 229 | .impl_debug(true) |
| 230 | .rust_target(RustTarget::stable(68, 0).ok().unwrap()) |
| 231 | .parse_callbacks(Box::new(filter_callback)) |
| 232 | // Add clang path, for `#include` header finding in bindgen process. |
| 233 | .clang_arg(format!("-I{}", ffmpeg_include_dir)) |
| 234 | // Workaround: https://github.com/rust-lang/rust-bindgen/issues/2159 |
| 235 | .blocklist_type("__mingw_ldbl_type_t") |
| 236 | // Stop bindgen from prefixing enums |
| 237 | .prepend_enum_name(false) |
| 238 | }, |
| 239 | |builder, header| builder.header(header), |
| 240 | ) |
| 241 | .generate() |
| 242 | .expect("Binding generation failed.") |
| 243 | } |
| 244 | |
| 245 | fn static_linking_with_libs_dir(library_names: &[&str], ffmpeg_libs_dir: &Path) { |
| 246 | println!("cargo:rustc-link-search=native={}", ffmpeg_libs_dir); |
no outgoing calls
no test coverage detected