Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow build with system-provided libsqlite (dynamically linked) #381

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ codegen-units = 1
incremental = false

[features]
default = ["bundled-sqlite"]
simd-rollsum = []
bundled-sqlite = ["rusqlite/bundled"]

[dependencies]

Expand All @@ -24,7 +26,7 @@ crossbeam-utils = "0.8"
crossbeam-channel = "0.5"
blake3 = "1"
itertools = "0.10"
rusqlite = { version = "0.25", features = ["bundled"] }
rusqlite = { version = "0.25", features = ["modern_sqlite"] }
lz4 = "1.2"
zstd-safe = { version = "6.0", features = ["std", "experimental"] }
anyhow = "1"
Expand Down
16 changes: 10 additions & 6 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@ fn main() {
pkg_config::probe_library("libsodium").unwrap();

println!("cargo:rerun-if-changed=csrc/cksumvfs/sqlite3.h");
cc::Build::new()

let mut build = cc::Build::new();
build
.warnings(false) // Not our code/warnings to fix.
.flag("-DSQLITE_CKSUMVFS_STATIC")
.flag("-Icsrc/cksumvfs")
.file("csrc/cksumvfs/cksumvfs.c")
.file("csrc/cksumvfs/cksumvfs_sqlite_version_number.c")
.compile("cksumvfs");
.flag("-DSQLITE_CKSUMVFS_STATIC");
if cfg!(feature = "bundled-sqlite") {
build
.flag("-Icsrc/cksumvfs")
.file("csrc/cksumvfs/cksumvfs_sqlite_version_number.c");
}
build.file("csrc/cksumvfs/cksumvfs.c").compile("cksumvfs");
}
5 changes: 5 additions & 0 deletions src/cksumvfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@
// For more info see: https://www.sqlite.org/cksumvfs.html

extern "C" {
#[cfg(feature = "bundled-sqlite")]
fn cksumvfs_sqlite_version_number() -> ::std::os::raw::c_int;

fn sqlite3_register_cksumvfs(unused: *const u8) -> ::std::os::raw::c_int;
}

pub fn register_cksumvfs() {
// Because have our own copy of the sqlite3 header file, this
// test ensures we are using the same header rusqlite used.
// This is not needed (nor desirable) when building with a
// system-provided libsqlite.
#[cfg(feature = "bundled-sqlite")]
assert_eq!(
unsafe { cksumvfs_sqlite_version_number() },
rusqlite::version_number()
Expand Down