MCPcopy Create free account
hub / github.com/CCExtractor/rusty_ffmpeg / generate_bindings

Function generate_bindings

build.rs:194–243  ·  view source on GitHub ↗
(ffmpeg_include_dir: &Path, headers: &[PathBuf])

Source from the content-addressed store, hash-verified

192}
193
194fn 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
245fn static_linking_with_libs_dir(library_names: &[&str], ffmpeg_libs_dir: &Path) {
246 println!("cargo:rustc-link-search=native={}", ffmpeg_libs_dir);

Callers 4

dynamic_linkingFunction · 0.85
static_linkingFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected