Remove most of the code using feature=bundled as a version check

This commit is contained in:
Thom Chiovoloni
2020-01-14 08:11:36 -08:00
parent a788d40f10
commit c70d148542
11 changed files with 53 additions and 38 deletions

View File

@@ -13,14 +13,17 @@ categories = ["external-ffi-bindings"]
[features]
default = ["min_sqlite_version_3_6_8"]
bundled = ["cc"]
bundled-windows = ["cc"]
bundled = ["cc", "bundled_bindings"]
bundled-windows = ["cc", "bundled_bindings"]
buildtime_bindgen = ["bindgen", "pkg-config", "vcpkg"]
sqlcipher = []
min_sqlite_version_3_6_8 = ["pkg-config", "vcpkg"]
min_sqlite_version_3_6_23 = ["pkg-config", "vcpkg"]
min_sqlite_version_3_7_7 = ["pkg-config", "vcpkg"]
min_sqlite_version_3_7_16 = ["pkg-config", "vcpkg"]
# Bundle only the bindings file. Note that this does nothing if
# `buildtime_bindgen` is enabled.
bundled_bindings = []
# sqlite3_unlock_notify >= 3.6.12
unlock_notify = []
# 3.13.0

View File

@@ -166,18 +166,17 @@ mod build_linked {
pub fn main(_out_dir: &str, out_path: &Path) {
let header = find_sqlite();
if cfg!(any(
feature = "bundled_bindings",
feature = "bundled",
all(windows, feature = "bundled-windows")
)) && !cfg!(feature = "buildtime_bindgen")
{
// We can only get here if `bundled` and `sqlcipher` were both
// specified (and `builtime_bindgen` was not). In order to keep
// `rusqlite` relatively clean we hide the fact that `bundled` can
// be ignored in some cases, and just use the bundled bindings, even
// though the library we found might not match their version.
// Ideally we'd perform a version check here, but doing so is rather
// tricky, since we might not have access to executables (and
// moreover, we might be cross compiling).
// Generally means the `bundled_bindings` feature is enabled
// (there's also an edge case where we get here involving
// sqlcipher). In either case most users are better off with turning
// on buildtime_bindgen instead, but this is still supported as we
// have runtime version checks and there are good reasons to not
// want to run bindgen.
std::fs::copy("sqlite3/bindgen_bundled_version.rs", out_path)
.expect("Could not copy bindings to output directory");
} else {