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

Function static_linking

build.rs:399–517  ·  view source on GitHub ↗
(env_vars: &EnvVars)

Source from the content-addressed store, hash-verified

397}
398
399fn static_linking(env_vars: &EnvVars) {
400 let output_binding_path = &env_vars.out_dir.as_ref().unwrap().join("binding.rs");
401
402 #[cfg(not(target_os = "windows"))]
403 {
404 fn static_linking_with_pkg_config_and_bindgen(
405 env_vars: &EnvVars,
406 output_binding_path: &Path,
407 ) -> Result<(), pkg_config::Error> {
408 // Probe libraries(enable emitting cargo metadata)
409 let include_paths = pkg_config_linking::linking_with_pkg_config(&*LIBS)?;
410 if let Some(ffmpeg_binding_path) = env_vars.ffmpeg_binding_path.as_ref() {
411 use_prebuilt_binding(ffmpeg_binding_path, output_binding_path);
412 } else if let Some(ffmpeg_include_dir) = env_vars.ffmpeg_include_dir.as_ref() {
413 // If use ffmpeg_pkg_config_path with ffmpeg_include_dir, prefer using the user given dir rather than pkg_config_path.
414 generate_bindings(ffmpeg_include_dir, &HEADERS)
415 .write_to_file(output_binding_path)
416 .expect("Cannot write binding to file.");
417 } else {
418 generate_bindings(&include_paths[0], &HEADERS)
419 .write_to_file(output_binding_path)
420 .expect("Cannot write binding to file.");
421 }
422 Ok(())
423 }
424 // Hint: set PKG_CONFIG_PATH to some placeholder value will let pkg_config probing system library.
425 if let Some(ffmpeg_pkg_config_path) = env_vars.ffmpeg_pkg_config_path.as_ref() {
426 if !Path::new(ffmpeg_pkg_config_path).exists() {
427 panic!(
428 "error: FFMPEG_PKG_CONFIG_PATH is set to `{}`, which does not exist.",
429 ffmpeg_pkg_config_path
430 );
431 }
432 env::set_var("PKG_CONFIG_PATH", ffmpeg_pkg_config_path);
433 static_linking_with_pkg_config_and_bindgen(env_vars, output_binding_path)
434 .expect("Static linking with pkg-config failed.");
435 } else if let Some(ffmpeg_libs_dir) = env_vars.ffmpeg_libs_dir.as_ref() {
436 static_linking_with_libs_dir(&*LIBS, ffmpeg_libs_dir);
437 if let Some(ffmpeg_binding_path) = env_vars.ffmpeg_binding_path.as_ref() {
438 use_prebuilt_binding(ffmpeg_binding_path, output_binding_path);
439 } else if let Some(ffmpeg_include_dir) = env_vars.ffmpeg_include_dir.as_ref() {
440 generate_bindings(ffmpeg_include_dir, &HEADERS)
441 .write_to_file(output_binding_path)
442 .expect("Cannot write binding to file.");
443 } else {
444 panic!("No binding generation method is set!");
445 }
446 } else {
447 #[cfg(not(any(feature = "link_system_ffmpeg", feature = "link_vcpkg_ffmpeg")))]
448 panic!(
449 "
450!!!!!!! rusty_ffmpeg: No linking method set!
451Use `FFMPEG_PKG_CONFIG_PATH` or `FFMPEG_LIBS_DIR` if you have prebuilt FFmpeg libraries.
452Enable `link_system_ffmpeg` feature if you want to link ffmpeg libraries installed in system path(which can be probed by pkg-config).
453Enable `link_vcpkg_ffmpeg` feature if you want to link ffmpeg libraries installed by vcpkg.
454"
455 );
456 #[cfg(any(feature = "link_system_ffmpeg", feature = "link_vcpkg_ffmpeg"))]

Callers 1

mainFunction · 0.85

Tested by

no test coverage detected