-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.rs
More file actions
49 lines (43 loc) · 1.66 KB
/
build.rs
File metadata and controls
49 lines (43 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
extern crate cc;
use std::env;
use std::path::PathBuf;
fn main() {
let mut sqlite: PathBuf = PathBuf::from(&env::var("CARGO_MANIFEST_DIR").unwrap());
sqlite.push("sqlite");
cc::Build::new()
.file(sqlite.join("sqlite3.c"))
.define("SQLITE_ENABLE_FTS5", None)
.define("SQLITE_ENABLE_SESSION", None)
.define("SQLITE_ENABLE_JSON1", None)
.define("SQLITE_ENABLE_RTREE", None)
.define("SQLITE_ENABLE_UNLOCK_NOTIFY", None)
.define("SQLITE_THREADSAFE", Some("1"))
.define("SQLITE_DEFAULT_MEMSTATUS", Some("0"))
.define("SQLITE_MAX_EXPR_DEPTH", Some("0"))
.define("SQLITE_OMIT_DEPRECATED", None)
.define("SQLITE_DIRECT_OVERFLOW_READ", None)
.define("SQLITE_LIKE_DOESNT_MATCH_BLOBS", None)
.define("SQLITE_OMIT_DECLTYPE", None)
.define("SQLITE_OMIT_PROGRESS_CALLBACK", None)
.define("SQLITE_USE_ALLOCA", None)
.opt_level(2)
.static_crt(true)
.compile("libsqlite3.a");
let bindings = bindgen::Builder::default()
.header("wrapper.h")
.generate_comments(true)
.use_core()
.ctypes_prefix("libc")
.whitelist_function("sqlite3_.*")
.whitelist_type("sqlite3_.*")
.prepend_enum_name(false)
.generate()
.expect("Unable to generate bindings");
// Write the bindings to src folder to make rls autocomplete work.
let out_path = PathBuf::from("src");
bindings
.write_to_file(out_path.join("bindings.rs"))
.expect("Couldn't write bindings!");
// Tell cargo to tell rustc to link the lmdb library.
println!("cargo:rustc-link-lib=static=sqlite3");
}