@@ -296,11 +296,18 @@ mod build_linked {
296296 // Try to use pkg-config to determine link commands
297297 let pkgconfig_path = Path :: new ( & dir) . join ( "pkgconfig" ) ;
298298 env:: set_var ( "PKG_CONFIG_PATH" , pkgconfig_path) ;
299- if pkg_config:: Config :: new ( ) . probe ( link_lib) . is_err ( ) {
299+
300+ #[ cfg( feature = "pkg-config" ) ]
301+ let lib_found = pkg_config:: Config :: new ( ) . probe ( link_lib) . is_ok ( ) ;
302+ #[ cfg( not( feature = "pkg-config" ) ) ]
303+ let lib_found = false ;
304+
305+ if !lib_found {
300306 // Otherwise just emit the bare minimum link commands.
301307 println ! ( "cargo:rustc-link-lib={}={}" , find_link_mode( ) , link_lib) ;
302308 println ! ( "cargo:rustc-link-search={dir}" ) ;
303309 }
310+
304311 return HeaderLocation :: FromEnvironment ;
305312 }
306313
@@ -309,39 +316,50 @@ mod build_linked {
309316 }
310317
311318 // See if pkg-config can do everything for us.
312- match pkg_config:: Config :: new ( ) . print_system_libs ( false ) . probe ( link_lib) {
313- Ok ( mut lib) => {
314- if let Some ( header) = lib. include_paths . pop ( ) {
315- HeaderLocation :: FromPath ( header. to_string_lossy ( ) . into ( ) )
316- } else {
319+ #[ cfg( feature = "pkg-config" ) ]
320+ {
321+ match pkg_config:: Config :: new ( ) . print_system_libs ( false ) . probe ( link_lib) {
322+ Ok ( mut lib) => {
323+ if let Some ( header) = lib. include_paths . pop ( ) {
324+ HeaderLocation :: FromPath ( header. to_string_lossy ( ) . into ( ) )
325+ } else {
326+ HeaderLocation :: Wrapper
327+ }
328+ }
329+ Err ( _) => {
330+ // No env var set and pkg-config couldn't help; just output the link-lib
331+ // request and hope that the library exists on the system paths. We used to
332+ // output /usr/lib explicitly, but that can introduce other linking problems;
333+ // see https://github.com/rusqlite/rusqlite/issues/207.
334+ if !cfg ! ( feature = "loadable-extension" ) {
335+ println ! ( "cargo:rustc-link-lib={}={}" , find_link_mode( ) , link_lib) ;
336+ }
317337 HeaderLocation :: Wrapper
318338 }
319339 }
320- Err ( _) => {
321- // No env var set and pkg-config couldn't help; just output the link-lib
322- // request and hope that the library exists on the system paths. We used to
323- // output /usr/lib explicitly, but that can introduce other linking problems;
324- // see https://github.com/rusqlite/rusqlite/issues/207.
325- if !cfg ! ( feature = "loadable-extension" ) {
326- println ! ( "cargo:rustc-link-lib={}={}" , find_link_mode( ) , link_lib) ;
327- }
328- HeaderLocation :: Wrapper
340+ }
341+ #[ cfg( not( feature = "pkg-config" ) ) ]
342+ {
343+ // No pkg-config available; just output the link-lib request and hope
344+ // that the library exists on the system paths.
345+ if !cfg ! ( feature = "loadable-extension" ) {
346+ println ! ( "cargo:rustc-link-lib={}={}" , find_link_mode( ) , link_lib) ;
329347 }
348+ HeaderLocation :: Wrapper
330349 }
331350 }
332351
333352 fn try_vcpkg ( ) -> Option < HeaderLocation > {
334- if cfg ! ( feature = "vcpkg" ) && is_compiler ( "msvc" ) {
353+ #[ cfg( feature = "vcpkg" ) ]
354+ if is_compiler ( "msvc" ) {
335355 // See if vcpkg can find it.
336356 if let Ok ( mut lib) = vcpkg:: Config :: new ( ) . probe ( lib_name ( ) ) {
337357 if let Some ( header) = lib. include_paths . pop ( ) {
338358 return Some ( HeaderLocation :: FromPath ( header. to_string_lossy ( ) . into ( ) ) ) ;
339359 }
340360 }
341- None
342- } else {
343- None
344361 }
362+ None
345363 }
346364}
347365
@@ -485,12 +503,11 @@ mod bindings {
485503 . write ( Box :: new ( & mut output) )
486504 . expect ( "could not write output of bindgen" ) ;
487505
506+ #[ allow( unused_mut) ]
488507 let mut output = String :: from_utf8 ( output) . expect ( "bindgen output was not UTF-8?!" ) ;
489508
490509 #[ cfg( feature = "loadable-extension" ) ]
491- {
492- generate_functions ( & mut output) ;
493- }
510+ generate_functions ( & mut output) ;
494511
495512 let mut file = OpenOptions :: new ( )
496513 . write ( true )
0 commit comments