|
|
|
@ -32,21 +32,49 @@ const MDB_IDL_LOGN: u8 = 15; |
|
|
|
|
)))] |
|
|
|
|
const MDB_IDL_LOGN: u8 = 16; |
|
|
|
|
|
|
|
|
|
macro_rules! warn { |
|
|
|
|
($message:expr) => { |
|
|
|
|
println!("cargo:warning={}", $message); |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fn main() { |
|
|
|
|
let mut lmdb = PathBuf::from(&env::var("CARGO_MANIFEST_DIR").unwrap()); |
|
|
|
|
lmdb.push("lmdb"); |
|
|
|
|
lmdb.push("libraries"); |
|
|
|
|
lmdb.push("liblmdb"); |
|
|
|
|
|
|
|
|
|
if cfg!(feature = "with-fuzzer") && cfg!(feature = "with-fuzzer-no-link") { |
|
|
|
|
warn!("Features `with-fuzzer` and `with-fuzzer-no-link` are mutually exclusive."); |
|
|
|
|
warn!("Building with `-fsanitize=fuzzer`."); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if !pkg_config::find_library("liblmdb").is_ok() { |
|
|
|
|
cc::Build::new() |
|
|
|
|
let mut builder = cc::Build::new(); |
|
|
|
|
|
|
|
|
|
builder |
|
|
|
|
.define("MDB_IDL_LOGN", Some(MDB_IDL_LOGN.to_string().as_str())) |
|
|
|
|
.file(lmdb.join("mdb.c")) |
|
|
|
|
.file(lmdb.join("midl.c")) |
|
|
|
|
// https://github.com/mozilla/lmdb/blob/b7df2cac50fb41e8bd16aab4cc5fd167be9e032a/libraries/liblmdb/Makefile#L23
|
|
|
|
|
.flag_if_supported("-Wno-unused-parameter") |
|
|
|
|
.flag_if_supported("-Wbad-function-cast") |
|
|
|
|
.flag_if_supported("-Wuninitialized") |
|
|
|
|
.compile("liblmdb.a") |
|
|
|
|
.flag_if_supported("-Wuninitialized"); |
|
|
|
|
|
|
|
|
|
if env::var("CARGO_FEATURE_WITH_CLANG").is_ok() { |
|
|
|
|
builder.compiler("clang"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if env::var("CARGO_FEATURE_WITH_ASAN").is_ok() { |
|
|
|
|
builder.flag("-fsanitize=address"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if env::var("CARGO_FEATURE_WITH_FUZZER").is_ok() { |
|
|
|
|
builder.flag("-fsanitize=fuzzer"); |
|
|
|
|
} else if env::var("CARGO_FEATURE_WITH_FUZZER_NO_LINK").is_ok() { |
|
|
|
|
builder.flag("-fsanitize=fuzzer-no-link"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
builder.compile("liblmdb.a") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|