Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reintroduce the MDB_IDL_LOGN feature flags #229

Merged
merged 5 commits into from
Feb 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions heed/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,26 @@ unbounded_depth = ["heed-types/unbounded_depth"]
# <https://github.com/LMDB/lmdb/blob/3947014aed7ffe39a79991fa7fb5b234da47ad1a/libraries/liblmdb/lmdb.h#L46-L69>
posix-sem = ["lmdb-master-sys/posix-sem"]

# 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 = ["lmdb-master-sys/mdb_idl_logn_8"]
mdb_idl_logn_9 = ["lmdb-master-sys/mdb_idl_logn_9"]
mdb_idl_logn_10 = ["lmdb-master-sys/mdb_idl_logn_10"]
mdb_idl_logn_11 = ["lmdb-master-sys/mdb_idl_logn_11"]
mdb_idl_logn_12 = ["lmdb-master-sys/mdb_idl_logn_12"]
mdb_idl_logn_13 = ["lmdb-master-sys/mdb_idl_logn_13"]
mdb_idl_logn_14 = ["lmdb-master-sys/mdb_idl_logn_14"]
mdb_idl_logn_15 = ["lmdb-master-sys/mdb_idl_logn_15"]
mdb_idl_logn_16 = ["lmdb-master-sys/mdb_idl_logn_16"]

[[example]]
name = "rmp-serde"
required-features = ["serde-rmp"]
20 changes: 20 additions & 0 deletions lmdb-master-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,23 @@ asan = []
fuzzer = []
fuzzer-no-link = []
posix-sem = []

# 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 = []
mdb_idl_logn_16 = []
93 changes: 93 additions & 0 deletions lmdb-master-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,98 @@ mod generate;
use std::env;
use std::path::PathBuf;

#[cfg(all(
feature = "mdb_idl_logn_8",
not(any(
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",
feature = "mdb_idl_logn_16"
))
))]
const MDB_IDL_LOGN: u8 = 8;
#[cfg(all(
feature = "mdb_idl_logn_9",
not(any(
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",
feature = "mdb_idl_logn_16"
))
))]
const MDB_IDL_LOGN: u8 = 9;
#[cfg(all(
feature = "mdb_idl_logn_10",
not(any(
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",
feature = "mdb_idl_logn_16"
))
))]
const MDB_IDL_LOGN: u8 = 10;
#[cfg(all(
feature = "mdb_idl_logn_11",
not(any(
feature = "mdb_idl_logn_12",
feature = "mdb_idl_logn_13",
feature = "mdb_idl_logn_14",
feature = "mdb_idl_logn_15",
feature = "mdb_idl_logn_16"
))
))]
const MDB_IDL_LOGN: u8 = 11;
#[cfg(all(
feature = "mdb_idl_logn_12",
not(any(
feature = "mdb_idl_logn_13",
feature = "mdb_idl_logn_14",
feature = "mdb_idl_logn_15",
feature = "mdb_idl_logn_16"
))
))]
const MDB_IDL_LOGN: u8 = 12;
#[cfg(all(
feature = "mdb_idl_logn_13",
not(any(
feature = "mdb_idl_logn_14",
feature = "mdb_idl_logn_15",
feature = "mdb_idl_logn_16"
))
))]
const MDB_IDL_LOGN: u8 = 13;
#[cfg(all(
feature = "mdb_idl_logn_14",
not(any(feature = "mdb_idl_logn_15", feature = "mdb_idl_logn_16"))
))]
const MDB_IDL_LOGN: u8 = 14;
#[cfg(all(feature = "mdb_idl_logn_15", not(any(feature = "mdb_idl_logn_16"))))]
const MDB_IDL_LOGN: u8 = 15;
#[cfg(any(
feature = "mdb_idl_logn_16",
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",
feature = "mdb_idl_logn_16",
))
))]
const MDB_IDL_LOGN: u8 = 16;

macro_rules! warn {
($message:expr) => {
println!("cargo:warning={}", $message);
Expand All @@ -33,6 +125,7 @@ fn main() {
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
Expand Down
Loading