flatten package to avoid another dependency

master
Niko PLP 7 months ago
parent 13b3c20222
commit 95ec9536b1
  1. 46
      Cargo.toml
  2. 17
      README.md
  3. 36
      librocksdb-sys/build.rs
  4. 2
      src/lib.rs
  5. 33
      src/librocksdb_sys.rs

@ -1,6 +1,6 @@
[package] [package]
name = "rocksdb" name = "ng-rocksdb"
description = "Rust wrapper for Facebook's RocksDB embeddable database" description = "Rust wrapper for Facebook's RocksDB embeddable database, fork for Nextgraph.org"
version = "0.21.0" version = "0.21.0"
edition = "2018" edition = "2018"
rust-version = "1.60" rust-version = "1.60"
@ -16,28 +16,32 @@ exclude = [
"deploy.sh", "deploy.sh",
"test/**/*", "test/**/*",
] ]
links = "rocksdb"
[workspace] build = "librocksdb-sys/build.rs"
members = ["librocksdb-sys"]
[features] [features]
default = [] default = ["static"]
jemalloc = ["librocksdb-sys/jemalloc"] jemalloc = ["tikv-jemalloc-sys"]
io-uring = ["librocksdb-sys/io-uring"] static = ["libz-sys?/static", "bzip2-sys?/static"]
io-uring = []
snappy = []
lz4 = ["lz4-sys"]
zstd = ["zstd-sys"]
zlib = ["libz-sys"]
bzip2 = ["bzip2-sys"]
rtti = []
valgrind = [] valgrind = []
snappy = ["librocksdb-sys/snappy"]
lz4 = ["librocksdb-sys/lz4"]
zstd = ["librocksdb-sys/zstd"]
zlib = ["librocksdb-sys/zlib"]
bzip2 = ["librocksdb-sys/bzip2"]
rtti = ["librocksdb-sys/rtti"]
multi-threaded-cf = [] multi-threaded-cf = []
serde1 = ["serde"] serde1 = ["serde"]
[dependencies] [dependencies]
libc = "0.2" libc = "0.2"
librocksdb-sys = { path = "librocksdb-sys", version = "0.11.0" }
serde = { version = "1", features = [ "derive" ], optional = true } serde = { version = "1", features = [ "derive" ], optional = true }
tikv-jemalloc-sys = { version = "0.5", features = ["unprefixed_malloc_on_supported_platforms"], optional = true }
lz4-sys = { version = "1.9", optional = true }
zstd-sys = { version = "2.0", features = ["zdict_builder"], optional = true }
libz-sys = { version = "1.1", default-features = false, optional = true }
bzip2-sys = { version = "0.1", default-features = false, optional = true }
[dev-dependencies] [dev-dependencies]
trybuild = "1.0" trybuild = "1.0"
@ -45,3 +49,15 @@ tempfile = "3.1"
pretty_assertions = "1.0" pretty_assertions = "1.0"
bincode = "1.3" bincode = "1.3"
serde = { version = "1", features = [ "derive" ] } serde = { version = "1", features = [ "derive" ] }
const-cstr = "0.3"
uuid = { version = "1.0", features = ["v4"] }
[target.'cfg(not(any(target_os = "linux",target_os = "darwin",target_os = "openbsd")))'.dependencies.openssl]
version = "0.10"
features = ["vendored"]
[build-dependencies]
cc = { version = "1.0", features = ["parallel"] }
bindgen = { version = "0.65", default-features = false, features = ["runtime"] }
glob = "0.3"
pkg-config = { version = "0.3" }

@ -1,13 +1,6 @@
# rust-rocksdb # ng-rocksdb
![RocksDB build](https://github.com/rust-rocksdb/rust-rocksdb/workflows/RocksDB%20build/badge.svg?branch=master) This is a fork of https://github.com/rust-rocksdb/rust-rocksdb that also includes a subtree of a fork of https://github.com/facebook/rocksdb for the needs of NextGraph.org project.
[![crates.io](https://img.shields.io/crates/v/rocksdb.svg)](https://crates.io/crates/rocksdb)
[![documentation](https://docs.rs/rocksdb/badge.svg)](https://docs.rs/rocksdb)
[![license](https://img.shields.io/crates/l/rocksdb.svg)](https://github.com/rust-rocksdb/rust-rocksdb/blob/master/LICENSE)
[![Gitter chat](https://badges.gitter.im/rust-rocksdb/gitter.png)](https://gitter.im/rust-rocksdb/lobby)
![rust 1.60.0 required](https://img.shields.io/badge/rust-1.60.0-blue.svg?label=MSRV)
![GitHub commits (since latest release)](https://img.shields.io/github/commits-since/rust-rocksdb/rust-rocksdb/latest.svg)
## Requirements ## Requirements
@ -45,12 +38,6 @@ algorithms is not needed, default features can be disabled and specific
compression algorithms can be enabled. For example, to enable only LZ4 compression algorithms can be enabled. For example, to enable only LZ4
compression support, make these changes to your Cargo.toml: compression support, make these changes to your Cargo.toml:
```
[dependencies.rocksdb]
default-features = false
features = ["lz4"]
```
## Multithreaded ColumnFamily alternation ## Multithreaded ColumnFamily alternation
The underlying RocksDB does allow column families to be created and dropped The underlying RocksDB does allow column families to be created and dropped

@ -27,14 +27,14 @@ fn fail_on_empty_directory(name: &str) {
fn rocksdb_include_dir() -> String { fn rocksdb_include_dir() -> String {
match env::var("ROCKSDB_INCLUDE_DIR") { match env::var("ROCKSDB_INCLUDE_DIR") {
Ok(val) => val, Ok(val) => val,
Err(_) => "rocksdb/include".to_string(), Err(_) => "librocksdb-sys/rocksdb/include".to_string(),
} }
} }
fn bindgen_rocksdb() { fn bindgen_rocksdb() {
let bindings = bindgen::Builder::default() let bindings = bindgen::Builder::default()
.header(rocksdb_include_dir() + "/rocksdb/c.h") .header(rocksdb_include_dir() + "/rocksdb/c.h")
.header("api/c.h") .header("librocksdb-sys/api/c.h")
.derive_debug(false) .derive_debug(false)
.blocklist_type("max_align_t") // https://github.com/rust-lang-nursery/rust-bindgen/issues/550 .blocklist_type("max_align_t") // https://github.com/rust-lang-nursery/rust-bindgen/issues/550
.ctypes_prefix("libc") .ctypes_prefix("libc")
@ -55,9 +55,9 @@ fn build_rocksdb() {
let target = env::var("TARGET").unwrap(); let target = env::var("TARGET").unwrap();
let mut config = cc::Build::new(); let mut config = cc::Build::new();
config.include("rocksdb/include/"); config.include("librocksdb-sys/rocksdb/include/");
config.include("rocksdb/"); config.include("librocksdb-sys/rocksdb/");
config.include("rocksdb/third-party/gtest-1.8.1/fused-src/"); config.include("librocksdb-sys/rocksdb/third-party/gtest-1.8.1/fused-src/");
if cfg!(feature = "snappy") { if cfg!(feature = "snappy") {
config.define("SNAPPY", Some("1")); config.define("SNAPPY", Some("1"));
@ -68,7 +68,7 @@ fn build_rocksdb() {
if cfg!(feature = "lz4") { if cfg!(feature = "lz4") {
config.define("LZ4", Some("1")); config.define("LZ4", Some("1"));
config.include("lz4/"); config.include("librocksdb-sys/lz4/");
} }
if cfg!(feature = "zstd") { if cfg!(feature = "zstd") {
@ -96,7 +96,7 @@ fn build_rocksdb() {
config.define("USE_RTTI", Some("1")); config.define("USE_RTTI", Some("1"));
} }
config.include("."); config.include("librocksdb-sys");
config.define("NDEBUG", Some("1")); config.define("NDEBUG", Some("1"));
let mut lib_sources = include_str!("rocksdb_lib_sources.txt") let mut lib_sources = include_str!("rocksdb_lib_sources.txt")
@ -152,7 +152,7 @@ fn build_rocksdb() {
if target.contains("darwin") || (target.contains("linux") && !target.contains("android")) { if target.contains("darwin") || (target.contains("linux") && !target.contains("android")) {
// on macos and linux we use the IPPCP plugin of rocksdb for the crypto (the lib is precompiled) // on macos and linux we use the IPPCP plugin of rocksdb for the crypto (the lib is precompiled)
config.include("rocksdb/plugin/ippcp/library/include"); config.include("librocksdb-sys/rocksdb/plugin/ippcp/library/include");
lib_sources.push("plugin/ippcp/ippcp_provider.cc"); lib_sources.push("plugin/ippcp/ippcp_provider.cc");
let dir = env::var("CARGO_MANIFEST_DIR").unwrap(); let dir = env::var("CARGO_MANIFEST_DIR").unwrap();
let prebuild_lib = if target.contains("darwin") { let prebuild_lib = if target.contains("darwin") {
@ -163,7 +163,9 @@ fn build_rocksdb() {
println!( println!(
"cargo:rustc-link-search=native={}", "cargo:rustc-link-search=native={}",
Path::new(&dir) Path::new(&dir)
.join(format!("rocksdb/plugin/ippcp/library/{prebuild_lib}/lib")) .join(format!(
"librocksdb-sys/rocksdb/plugin/ippcp/library/{prebuild_lib}/lib"
))
.display() .display()
); );
println!("cargo:rustc-link-lib=static=ippcp"); println!("cargo:rustc-link-lib=static=ippcp");
@ -171,7 +173,7 @@ fn build_rocksdb() {
if let Some(include) = std::env::var_os("DEP_OPENSSL_INCLUDE") { if let Some(include) = std::env::var_os("DEP_OPENSSL_INCLUDE") {
config.include(include); config.include(include);
} else { } else {
config.include("rocksdb/plugin/openssl/include"); config.include("librocksdb-sys/rocksdb/plugin/openssl/include");
} }
lib_sources.push("plugin/openssl/openssl_provider.cc"); lib_sources.push("plugin/openssl/openssl_provider.cc");
// let dir = env::var("CARGO_MANIFEST_DIR").unwrap(); // let dir = env::var("CARGO_MANIFEST_DIR").unwrap();
@ -255,7 +257,7 @@ fn build_rocksdb() {
config.define("HAVE_UINT128_EXTENSION", None); config.define("HAVE_UINT128_EXTENSION", None);
config.define("DHAVE_ALIGNED_NEW", None); config.define("DHAVE_ALIGNED_NEW", None);
config.define("_REENTRANT", None); config.define("_REENTRANT", None);
config.include("rocksdb/plugin/openssl/include"); config.include("librocksdb-sys/rocksdb/plugin/openssl/include");
lib_sources.push("plugin/openssl/openssl_provider.cc"); lib_sources.push("plugin/openssl/openssl_provider.cc");
} else if target.contains("windows") { } else if target.contains("windows") {
link("rpcrt4", false); link("rpcrt4", false);
@ -362,11 +364,11 @@ fn build_rocksdb() {
} }
for file in lib_sources { for file in lib_sources {
config.file(format!("rocksdb/{file}")); config.file(format!("librocksdb-sys/rocksdb/{file}"));
} }
config.file("build_version.cc"); config.file("librocksdb-sys/build_version.cc");
config.file("api/c.cc"); config.file("librocksdb-sys/api/c.cc");
config.cpp(true); config.cpp(true);
config.flag_if_supported("-std=c++17"); config.flag_if_supported("-std=c++17");
@ -457,7 +459,7 @@ fn update_submodules() {
} }
fn main() { fn main() {
if !Path::new("rocksdb/AUTHORS").exists() { if !Path::new("librocksdb-sys/rocksdb/AUTHORS").exists() {
update_submodules(); update_submodules();
} }
let target = env::var("TARGET").unwrap(); let target = env::var("TARGET").unwrap();
@ -470,8 +472,8 @@ fn main() {
bindgen_rocksdb(); bindgen_rocksdb();
if !try_to_find_and_link_lib("ROCKSDB") { if !try_to_find_and_link_lib("ROCKSDB") {
println!("cargo:rerun-if-changed=rocksdb/"); println!("cargo:rerun-if-changed=librocksdb-sys/rocksdb/");
fail_on_empty_directory("rocksdb"); fail_on_empty_directory("librocksdb-sys/rocksdb");
build_rocksdb(); build_rocksdb();
} else { } else {
let target = env::var("TARGET").unwrap(); let target = env::var("TARGET").unwrap();

@ -133,6 +133,8 @@ pub use crate::{
write_batch::{WriteBatch, WriteBatchIterator, WriteBatchWithTransaction}, write_batch::{WriteBatch, WriteBatchIterator, WriteBatchWithTransaction},
}; };
pub mod librocksdb_sys;
pub use librocksdb_sys as ffi; pub use librocksdb_sys as ffi;
use std::error; use std::error;

@ -0,0 +1,33 @@
// Copyright 2020 Tyler Neely, Alex Regueiro
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#![allow(clippy::all)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(non_upper_case_globals)]
#![allow(deref_nullptr)]
// Ensure the libraries are linked in, despite it not being used directly
#[cfg(feature = "bzip2")]
extern crate bzip2_sys;
#[cfg(feature = "zlib")]
extern crate libz_sys;
#[cfg(feature = "lz4")]
extern crate lz4_sys;
#[cfg(not(any(target_os = "linux", target_os = "macos", target_os = "openbsd")))]
extern crate openssl;
#[cfg(feature = "zstd")]
extern crate zstd_sys;
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
Loading…
Cancel
Save