Session extension (#459)

Session extension bindings
This commit is contained in:
gwenn
2019-01-13 12:46:19 +01:00
committed by GitHub
parent f6a4feecea
commit dbc4eef657
11 changed files with 996 additions and 116 deletions

View File

@@ -22,6 +22,10 @@ min_sqlite_version_3_7_7 = ["pkg-config", "vcpkg"]
min_sqlite_version_3_7_16 = ["pkg-config", "vcpkg"]
# sqlite3_unlock_notify >= 3.6.12
unlock_notify = []
# 3.13.0
preupdate_hook = []
# 3.13.0
session = ["preupdate_hook"]
[build-dependencies]
bindgen = { version = "0.46", optional = true }

View File

@@ -54,6 +54,12 @@ mod build {
if cfg!(feature = "unlock_notify") {
cfg.flag("-DSQLITE_ENABLE_UNLOCK_NOTIFY");
}
if cfg!(feature = "preupdate_hook") {
cfg.flag("-DSQLITE_ENABLE_PREUPDATE_HOOK");
}
if cfg!(feature = "session") {
cfg.flag("-DSQLITE_ENABLE_SESSION");
}
cfg.compile("libsqlite3.a");
println!("cargo:lib_dir={}", out_dir);
@@ -237,10 +243,22 @@ mod bindings {
pub fn write_to_out_dir(header: HeaderLocation, out_path: &Path) {
let header: String = header.into();
let mut output = Vec::new();
bindgen::builder()
let mut bindings = bindgen::builder()
.header(header.clone())
.parse_callbacks(Box::new(SqliteTypeChooser))
.rustfmt_bindings(true)
.rustfmt_bindings(true);
if cfg!(feature = "unlock_notify") {
bindings = bindings.clang_arg("-DSQLITE_ENABLE_UNLOCK_NOTIFY");
}
if cfg!(feature = "preupdate_hook") {
bindings = bindings.clang_arg("-DSQLITE_ENABLE_PREUPDATE_HOOK");
}
if cfg!(feature = "session") {
bindings = bindings.clang_arg("-DSQLITE_ENABLE_SESSION");
}
bindings
.generate()
.expect(&format!("could not run bindgen on header {}", header))
.write(Box::new(&mut output))