forked from mozilla/lmdb-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.rs
40 lines (36 loc) · 1.49 KB
/
build.rs
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
extern crate pkg_config;
extern crate cc;
use std::env;
use std::path::PathBuf;
fn main() {
let mut lmdb: PathBuf = PathBuf::from(&env::var("CARGO_MANIFEST_DIR").unwrap());
lmdb.push("lmdb");
lmdb.push("libraries");
lmdb.push("liblmdb");
if !pkg_config::find_library("liblmdb").is_ok() {
let target = env::var("TARGET").expect("No TARGET found");
let mut build = cc::Build::new();
if target.contains("android") {
build.define("ANDROID", "1");
}
if target.contains("windows") {
// LMDB on Windows has an issue with ´off_t´ being defined as ´long´ 32-bit signed
// which caused a max size of the database of 2 GB which we work
// around by redefining ´off_t´ to 64-bit
//
// was discussed here and allgedly fixed in January 2016 but fix doesn't work as
// Windows doesn't support _FILE_OFFSET_BITS
// https://www.openldap.org/lists/openldap-bugs/201605/msg00015.htm
// https://github.com/LMDB/lmdb/commit/20dec1f69bf4860202c764ce92b1fbbe3d11a065
build.define("_OFF_T_DEFINED", "1");
build.define("off_t", "__int64");
build.define("_off_t", "__int64");
}
build
.file(lmdb.join("mdb.c"))
.file(lmdb.join("midl.c"))
// https://github.com/LMDB/lmdb/blob/LMDB_0.9.21/libraries/liblmdb/Makefile#L25
.opt_level(2)
.compile("liblmdb.a")
}
}