Merge pull request #214 from jgallagher/skip-linking-usr-lib-explicitly

Skip linking /usr/lib explicitly
This commit is contained in:
John Gallagher 2017-01-23 20:26:14 -05:00 committed by GitHub
commit d54aeb9c20
3 changed files with 14 additions and 17 deletions

View File

@ -40,7 +40,7 @@ regex = "~0.2"
[dependencies.libsqlite3-sys] [dependencies.libsqlite3-sys]
path = "libsqlite3-sys" path = "libsqlite3-sys"
version = "0.6.0" version = "0.6.1"
[[test]] [[test]]
name = "config_log" name = "config_log"

View File

@ -1,6 +1,6 @@
[package] [package]
name = "libsqlite3-sys" name = "libsqlite3-sys"
version = "0.6.0" version = "0.6.1"
authors = ["John Gallagher <jgallagher@bignerdranch.com>"] authors = ["John Gallagher <jgallagher@bignerdranch.com>"]
repository = "https://github.com/jgallagher/rusqlite" repository = "https://github.com/jgallagher/rusqlite"
description = "Native bindings to the libsqlite3 library" description = "Native bindings to the libsqlite3 library"

View File

@ -4,27 +4,24 @@ extern crate pkg_config;
#[cfg(not(feature = "bundled"))] #[cfg(not(feature = "bundled"))]
fn main() { fn main() {
use std::env; use std::env;
use std::fs;
// Allow users to specify where to find SQLite. // Allow users to specify where to find SQLite.
let lib_dir = match env::var("SQLITE3_LIB_DIR") { match env::var("SQLITE3_LIB_DIR") {
Ok(dir) => dir, Ok(dir) => {
println!("cargo:rustc-link-lib=sqlite3");
println!("cargo:rustc-link-search={}", dir);
}
Err(_) => { Err(_) => {
// See if pkg-config can do everything for us. // See if pkg-config can do everything for us.
if pkg_config::find_library("sqlite3").is_ok() { if !pkg_config::find_library("sqlite3").is_ok() {
return // No env var set and pkg-config couldn't help; just output the link-lib
} // request and hope that the library exists on the system paths. We used to
// output /usr/lib explicitly, but that can introduce other linking problems; see
// Try to fall back to /usr/lib if pkg-config failed. // https://github.com/jgallagher/rusqlite/issues/207.
match fs::metadata("/usr/lib") {
Ok(ref attr) if attr.is_dir() => "/usr/lib".to_owned(),
_ => panic!("Could not find sqlite3. Try setting SQLITE3_LIB_DIR."),
}
},
};
println!("cargo:rustc-link-lib=sqlite3"); println!("cargo:rustc-link-lib=sqlite3");
println!("cargo:rustc-link-search={}", lib_dir); }
}
};
} }
#[cfg(feature = "bundled")] #[cfg(feature = "bundled")]