mirror of
https://github.com/isar/rusqlite.git
synced 2025-10-08 12:32:20 +08:00
Merge pull request #278 from mcgoo/vcpkg
for msvc abi builds, add support for using sqlite from a vcpkg installation if available
This commit is contained in:
@@ -13,15 +13,18 @@ categories = ["database", "external-ffi-bindings"]
|
||||
[features]
|
||||
default = ["min_sqlite_version_3_6_8"]
|
||||
bundled = ["gcc"]
|
||||
buildtime_bindgen = ["bindgen", "pkg-config"]
|
||||
min_sqlite_version_3_6_8 = ["pkg-config"]
|
||||
min_sqlite_version_3_6_11 = ["pkg-config"]
|
||||
min_sqlite_version_3_6_23 = ["pkg-config"]
|
||||
min_sqlite_version_3_7_3 = ["pkg-config"]
|
||||
min_sqlite_version_3_7_4 = ["pkg-config"]
|
||||
min_sqlite_version_3_7_16 = ["pkg-config"]
|
||||
buildtime_bindgen = ["bindgen", "pkg-config", "vcpkg"]
|
||||
min_sqlite_version_3_6_8 = ["pkg-config", "vcpkg"]
|
||||
min_sqlite_version_3_6_11 = ["pkg-config", "vcpkg"]
|
||||
min_sqlite_version_3_6_23 = ["pkg-config", "vcpkg"]
|
||||
min_sqlite_version_3_7_3 = ["pkg-config", "vcpkg"]
|
||||
min_sqlite_version_3_7_4 = ["pkg-config", "vcpkg"]
|
||||
min_sqlite_version_3_7_16 = ["pkg-config", "vcpkg"]
|
||||
|
||||
[build-dependencies]
|
||||
bindgen = { version = "0.23", optional = true }
|
||||
pkg-config = { version = "0.3", optional = true }
|
||||
gcc = { version = "0.3", optional = true }
|
||||
|
||||
[target.'cfg(target_env = "msvc")'.build-dependencies]
|
||||
vcpkg = { version = "0.2", optional = true }
|
||||
|
@@ -43,6 +43,9 @@ mod build {
|
||||
mod build {
|
||||
extern crate pkg_config;
|
||||
|
||||
#[cfg(all(feature = "vcpkg", target_env = "msvc"))]
|
||||
extern crate vcpkg;
|
||||
|
||||
use std::env;
|
||||
|
||||
pub enum HeaderLocation {
|
||||
@@ -80,6 +83,10 @@ mod build {
|
||||
return HeaderLocation::FromEnvironment;
|
||||
}
|
||||
|
||||
if let Some(header) = try_vcpkg() {
|
||||
return header;
|
||||
}
|
||||
|
||||
// See if pkg-config can do everything for us.
|
||||
match pkg_config::Config::new().print_system_libs(false).probe("sqlite3") {
|
||||
Ok(mut lib) => {
|
||||
@@ -101,6 +108,23 @@ mod build {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "vcpkg", target_env = "msvc"))]
|
||||
fn try_vcpkg() -> Option<HeaderLocation> {
|
||||
// See if vcpkg can find it.
|
||||
if let Ok(mut lib) = vcpkg::Config::new().probe("sqlite3") {
|
||||
if let Some(mut header) = lib.include_paths.pop() {
|
||||
header.push("sqlite3.h");
|
||||
return Some(HeaderLocation::FromPath(header.to_string_lossy().into()));
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
#[cfg(not(all(feature = "vcpkg", target_env = "msvc")))]
|
||||
fn try_vcpkg() -> Option<HeaderLocation> {
|
||||
None
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "buildtime_bindgen"))]
|
||||
mod bindings {
|
||||
use super::HeaderLocation;
|
||||
|
Reference in New Issue
Block a user