mirror of
https://github.com/isar/rusqlite.git
synced 2025-10-06 11:32:20 +08:00
Make libsqlite3-sys's build script slightly more intelligent.
* If SQLITE3_LIB_DIR is present in the environment, we use that. * If SQLITE3_LIB_DIR is not present, we try to use pkg-config. * If SQLITE3_LIB_DIR is not present and pkg-config fails, we fall back to /usr/lib (if it exists).
This commit is contained in:
@@ -1,5 +1,26 @@
|
||||
extern crate pkg_config;
|
||||
|
||||
use std::env;
|
||||
use std::fs;
|
||||
|
||||
fn main() {
|
||||
pkg_config::find_library("sqlite3").unwrap();
|
||||
// Allow users to specify where to find SQLite.
|
||||
let lib_dir = match env::var("SQLITE3_LIB_DIR") {
|
||||
Ok(dir) => dir,
|
||||
Err(_) => {
|
||||
// See if pkg-config can do everything for us.
|
||||
if pkg_config::find_library("sqlite3").is_ok() {
|
||||
return
|
||||
}
|
||||
|
||||
// Try to fall back to /usr/lib if pkg-config failed.
|
||||
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-search={}", lib_dir);
|
||||
}
|
||||
|
Reference in New Issue
Block a user