From 97ceb8466fa71160b028e83e6a98898836583319 Mon Sep 17 00:00:00 2001 From: Johnny Graettinger Date: Thu, 18 Nov 2021 01:54:59 -0500 Subject: [PATCH] Add feature flag for runtime type information, and metadata for locating library and sources (#544) --- Cargo.toml | 1 + librocksdb-sys/Cargo.toml | 1 + librocksdb-sys/build.rs | 13 +++++++++++++ 3 files changed, 15 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index d164526..d9a0b82 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,6 +25,7 @@ lz4 = ["librocksdb-sys/lz4"] zstd = ["librocksdb-sys/zstd"] zlib = ["librocksdb-sys/zlib"] bzip2 = ["librocksdb-sys/bzip2"] +rtti = ["librocksdb-sys/rtti"] multi-threaded-cf = [] [dependencies] diff --git a/librocksdb-sys/Cargo.toml b/librocksdb-sys/Cargo.toml index da4eb3d..1d0d7ad 100644 --- a/librocksdb-sys/Cargo.toml +++ b/librocksdb-sys/Cargo.toml @@ -20,6 +20,7 @@ lz4 = [] zstd = [] zlib = [] bzip2 = [] +rtti = [] [dependencies] libc = "0.2" diff --git a/librocksdb-sys/build.rs b/librocksdb-sys/build.rs index 04febf4..a39ee25 100644 --- a/librocksdb-sys/build.rs +++ b/librocksdb-sys/build.rs @@ -83,6 +83,10 @@ fn build_rocksdb() { config.include("bzip2/"); } + if cfg!(feature = "rtti") { + config.define("USE_RTTI", Some("1")); + } + config.include("."); config.define("NDEBUG", Some("1")); @@ -400,4 +404,13 @@ fn main() { fail_on_empty_directory("bzip2"); build_bzip2(); } + + // Allow dependent crates to locate the sources and output directory of + // this crate. Notably, this allows a dependent crate to locate the RocksDB + // sources and built archive artifacts provided by this crate. + println!( + "cargo:cargo_manifest_dir={}", + env::var("CARGO_MANIFEST_DIR").unwrap() + ); + println!("cargo:out_dir={}", env::var("OUT_DIR").unwrap()); }