@@ -187,12 +187,18 @@ impl callbacks::ParseCallbacks for FilterCargoCallbacks {
187187 }
188188}
189189
190- #[ derive( Clone , Copy ) ]
190+ #[ derive( Clone , Copy , PartialEq , Eq ) ]
191191enum FFmpegLinkMode {
192192 Static ,
193193 Dynamic ,
194194}
195195
196+ impl FFmpegLinkMode {
197+ fn is_static ( & self ) -> bool {
198+ self == & Self :: Static
199+ }
200+ }
201+
196202impl From < String > for FFmpegLinkMode {
197203 fn from ( value : String ) -> Self {
198204 match & * value {
@@ -333,10 +339,12 @@ mod pkg_config_linking {
333339 /// Note: no side effect if this function errors.
334340 pub fn linking_with_pkg_config (
335341 library_names : & [ & str ] ,
342+ statik : bool ,
336343 ) -> Result < Vec < PathBuf > , pkg_config:: Error > {
337344 // dry run for library linking
338345 for libname in library_names {
339346 pkg_config:: Config :: new ( )
347+ . statik ( statik)
340348 . cargo_metadata ( false )
341349 . env_metadata ( false )
342350 . print_system_libs ( false )
@@ -348,6 +356,7 @@ mod pkg_config_linking {
348356 let mut paths = HashSet :: new ( ) ;
349357 for libname in library_names {
350358 let new_paths = pkg_config:: Config :: new ( )
359+ . statik ( statik)
351360 . probe ( & format ! ( "lib{}" , libname) )
352361 . unwrap_or_else ( |_| panic ! ( "{} not found!" , libname) )
353362 . include_paths ;
@@ -437,7 +446,13 @@ fn linking(env_vars: EnvVars) {
437446 output_binding_path : & Path ,
438447 ) -> Result < ( ) , pkg_config:: Error > {
439448 // Probe libraries(enable emitting cargo metadata)
440- let include_paths = pkg_config_linking:: linking_with_pkg_config ( & * LIBS ) ?;
449+ let include_paths = pkg_config_linking:: linking_with_pkg_config (
450+ & * LIBS ,
451+ env_vars
452+ . ffmpeg_link_mode
453+ . map ( |x| x. is_static ( ) )
454+ . unwrap_or_default ( ) ,
455+ ) ?;
441456 if let Some ( ffmpeg_binding_path) = env_vars. ffmpeg_binding_path . as_ref ( ) {
442457 use_prebuilt_binding ( ffmpeg_binding_path, output_binding_path) ;
443458 } else if let Some ( ffmpeg_include_dir) = env_vars. ffmpeg_include_dir . as_ref ( ) {
0 commit comments