use std::path::PathBuf; use bindgen::MacroTypeVariation; #[cfg(debug_assertions)] pub fn adjust(build: &mut cc::Build) -> &mut cc::Build { build.define("SQLITE_ENABLE_API_ARMOR", None).define("SQLITE_ENABLE_EXPLAIN_COMMENTS", None) } #[cfg(not(debug_assertions))] pub fn adjust(build: &mut Build) -> &mut Build { build } pub fn main() -> Result<(), Box>{ println!("cargo:rerun-if-changed=sqlite"); let mut build = cc::Build::new(); let build = build .files(["sqlite/sqlite3.c"]) // there are a few, but we can't change those .warnings(false) .static_flag(true) .cpp(false); let build = build .define("SQLITE_ENABLE_FTS5", None) .define("SQLITE_ENABLE_JSON", None) .define("SQLITE_ENABLE_MATH_FUNCTIONS", None) .define("SQLITE_THREADSAFE", "2") .define("SQLITE_MAX_EXPR_DEPTH", "0") .define("SQLITE_DQS", "0") .define("SQLITE_DEFAULT_MEMSTATUS", "0") .define("SQLITE_DEFAULT_SYNCHRONOUS", "2") .define("SQLITE_LIKE_DOESNT_MATCH_BLOBS", None) .define("SQLITE_OMIT_DECLTYPE", None) .define("SQLITE_OMIT_DEPRECATED", None) .define("SQLITE_OMIT_PROGRESS_CALLBACK", None) .define("SQLITE_OMIT_SHARED_CACHE", None) .define("SQLITE_USE_ALLOCA", None) .define("SQLITE_OMIT_AUTOINIT", None); let build = adjust(build); build.compile("sqlite3"); let cargo_out = PathBuf::from(std::env::var("OUT_DIR").unwrap()); let bindings = bindgen::Builder::default() .header("sqlite/sqlite3.h") .disable_header_comment() .default_macro_constant_type(MacroTypeVariation::Signed) .generate()?; bindings.write_to_file(cargo_out.join("sqlite3.rs"))?; Ok(()) }