add feature flags to define MDB_IDL_LOGN macro

without.crypto
Myk Melez 6 years ago
parent 99359f4cab
commit babc0594df
  1. 22
      lmdb-sys/Cargo.toml
  2. 29
      lmdb-sys/build.rs

@ -21,3 +21,25 @@ libc = "0.2"
[build-dependencies] [build-dependencies]
pkg-config = "0.3.2" pkg-config = "0.3.2"
cc = "1" cc = "1"
[features]
default = []
# These features configure the MDB_IDL_LOGN macro, which determines
# the size of the free and dirty page lists (and thus the amount of memory
# allocated when opening an LMDB environment in read-write mode).
#
# Each feature defines MDB_IDL_LOGN as the value in the name of the feature.
# That means these features are mutually exclusive, and you must not specify
# more than one at the same time (or the crate will fail to compile).
#
# For more information on the motivation for these features (and their effect),
# see https://github.com/mozilla/lmdb/pull/2.
mdb_idl_logn_8 = []
mdb_idl_logn_9 = []
mdb_idl_logn_10 = []
mdb_idl_logn_11 = []
mdb_idl_logn_12 = []
mdb_idl_logn_13 = []
mdb_idl_logn_14 = []
mdb_idl_logn_15 = []

@ -4,6 +4,34 @@ extern crate cc;
use std::env; use std::env;
use std::path::PathBuf; use std::path::PathBuf;
#[cfg(feature = "mdb_idl_logn_8")]
const MDB_IDL_LOGN: u8 = 8;
#[cfg(feature = "mdb_idl_logn_9")]
const MDB_IDL_LOGN: u8 = 9;
#[cfg(feature = "mdb_idl_logn_10")]
const MDB_IDL_LOGN: u8 = 10;
#[cfg(feature = "mdb_idl_logn_11")]
const MDB_IDL_LOGN: u8 = 11;
#[cfg(feature = "mdb_idl_logn_12")]
const MDB_IDL_LOGN: u8 = 12;
#[cfg(feature = "mdb_idl_logn_13")]
const MDB_IDL_LOGN: u8 = 13;
#[cfg(feature = "mdb_idl_logn_14")]
const MDB_IDL_LOGN: u8 = 14;
#[cfg(feature = "mdb_idl_logn_15")]
const MDB_IDL_LOGN: u8 = 15;
#[cfg(not(any(
feature = "mdb_idl_logn_8",
feature = "mdb_idl_logn_9",
feature = "mdb_idl_logn_10",
feature = "mdb_idl_logn_11",
feature = "mdb_idl_logn_12",
feature = "mdb_idl_logn_13",
feature = "mdb_idl_logn_14",
feature = "mdb_idl_logn_15",
)))]
const MDB_IDL_LOGN: u8 = 16;
fn main() { fn main() {
let mut lmdb: PathBuf = PathBuf::from(&env::var("CARGO_MANIFEST_DIR").unwrap()); let mut lmdb: PathBuf = PathBuf::from(&env::var("CARGO_MANIFEST_DIR").unwrap());
lmdb.push("lmdb"); lmdb.push("lmdb");
@ -12,6 +40,7 @@ fn main() {
if !pkg_config::find_library("liblmdb").is_ok() { if !pkg_config::find_library("liblmdb").is_ok() {
cc::Build::new() cc::Build::new()
.define("MDB_IDL_LOGN", Some(MDB_IDL_LOGN.to_string().as_str()))
.file(lmdb.join("mdb.c")) .file(lmdb.join("mdb.c"))
.file(lmdb.join("midl.c")) .file(lmdb.join("midl.c"))
// https://github.com/LMDB/lmdb/blob/LMDB_0.9.21/libraries/liblmdb/Makefile#L25 // https://github.com/LMDB/lmdb/blob/LMDB_0.9.21/libraries/liblmdb/Makefile#L25

Loading…
Cancel
Save