blob: bced585fe653d09997243d4ee019f8b42ce4f340 [file] [log] [blame]
Matthew Maurer5856e852020-08-10 16:31:06 -07001use bindgen_cmd;
2use bindgen::callbacks::{IntKind, ParseCallbacks};
3
4#[derive(Debug)]
5struct SqliteTypeChooser;
6
7impl ParseCallbacks for SqliteTypeChooser {
8 fn int_macro(&self, _name: &str, value: i64) -> Option<IntKind> {
9 if value >= i32::min_value() as i64 && value <= i32::max_value() as i64 {
10 Some(IntKind::I32)
11 } else {
12 None
13 }
14 }
15}
16
17fn main() {
18 bindgen_cmd::build(|mut builder| {
19 builder = builder
20 .parse_callbacks(Box::new(SqliteTypeChooser))
21 .rustfmt_bindings(true)
22 .blacklist_function("sqlite3_vmprintf")
23 .blacklist_function("sqlite3_vsnprintf")
24 .blacklist_function("sqlite3_str_vappendf")
25 .blacklist_type("va_list")
26 .blacklist_type("__builtin_va_list")
27 .blacklist_type("__gnuc_va_list")
28 .blacklist_type("__va_list_tag")
29 .blacklist_item("__GNUC_VA_LIST");
30
31 if cfg!(feature = "unlock_notify") {
32 builder = builder.clang_arg("-DSQLITE_ENABLE_UNLOCK_NOTIFY");
33 }
34 if cfg!(feature = "preupdate_hook") {
35 builder = builder.clang_arg("-DSQLITE_ENABLE_PREUPDATE_HOOK");
36 }
37 if cfg!(feature = "session") {
38 builder = builder.clang_arg("-DSQLITE_ENABLE_SESSION");
39 }
40
41 builder
42 })
43}