@@ -187,12 +187,19 @@ 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+ #[ cfg( not( target_os = "windows" ) ) ]
197+ impl FFmpegLinkMode {
198+ fn is_static ( & self ) -> bool {
199+ self == & Self :: Static
200+ }
201+ }
202+
196203impl From < String > for FFmpegLinkMode {
197204 fn from ( value : String ) -> Self {
198205 match & * value {
@@ -333,10 +340,12 @@ mod pkg_config_linking {
333340 /// Note: no side effect if this function errors.
334341 pub fn linking_with_pkg_config (
335342 library_names : & [ & str ] ,
343+ statik : bool ,
336344 ) -> Result < Vec < PathBuf > , pkg_config:: Error > {
337345 // dry run for library linking
338346 for libname in library_names {
339347 pkg_config:: Config :: new ( )
348+ . statik ( statik)
340349 . cargo_metadata ( false )
341350 . env_metadata ( false )
342351 . print_system_libs ( false )
@@ -348,6 +357,7 @@ mod pkg_config_linking {
348357 let mut paths = HashSet :: new ( ) ;
349358 for libname in library_names {
350359 let new_paths = pkg_config:: Config :: new ( )
360+ . statik ( statik)
351361 . probe ( & format ! ( "lib{}" , libname) )
352362 . unwrap_or_else ( |_| panic ! ( "{} not found!" , libname) )
353363 . include_paths ;
@@ -437,7 +447,13 @@ fn linking(env_vars: EnvVars) {
437447 output_binding_path : & Path ,
438448 ) -> Result < ( ) , pkg_config:: Error > {
439449 // Probe libraries(enable emitting cargo metadata)
440- let include_paths = pkg_config_linking:: linking_with_pkg_config ( & * LIBS ) ?;
450+ let include_paths = pkg_config_linking:: linking_with_pkg_config (
451+ & * LIBS ,
452+ env_vars
453+ . ffmpeg_link_mode
454+ . map ( |x| x. is_static ( ) )
455+ . unwrap_or_default ( ) ,
456+ ) ?;
441457 if let Some ( ffmpeg_binding_path) = env_vars. ffmpeg_binding_path . as_ref ( ) {
442458 use_prebuilt_binding ( ffmpeg_binding_path, output_binding_path) ;
443459 } else if let Some ( ffmpeg_include_dir) = env_vars. ffmpeg_include_dir . as_ref ( ) {
0 commit comments