|
|
@ -1,13 +1,10 @@ |
|
|
|
// Code from https://github.com/rust-rocksdb/rust-rocksdb/blob/eb2d302682418b361a80ad8f4dcf335ade60dcf5/librocksdb-sys/build.rs
|
|
|
|
// Code from https://github.com/rust-rocksdb/rust-rocksdb/blob/eb2d302682418b361a80ad8f4dcf335ade60dcf5/librocksdb-sys/build.rs
|
|
|
|
// License: https://github.com/rust-rocksdb/rust-rocksdb/blob/master/LICENSE
|
|
|
|
// License: https://github.com/rust-rocksdb/rust-rocksdb/blob/master/LICENSE
|
|
|
|
|
|
|
|
|
|
|
|
use std::env; |
|
|
|
use std::env::var; |
|
|
|
use std::fs::File; |
|
|
|
use std::path::PathBuf; |
|
|
|
use std::io::Write; |
|
|
|
|
|
|
|
use std::path::{Path, PathBuf}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn link(name: &str, bundled: bool) { |
|
|
|
fn link(name: &str, bundled: bool) { |
|
|
|
use std::env::var; |
|
|
|
|
|
|
|
let target = var("TARGET").unwrap(); |
|
|
|
let target = var("TARGET").unwrap(); |
|
|
|
let target: Vec<_> = target.split('-').collect(); |
|
|
|
let target: Vec<_> = target.split('-').collect(); |
|
|
|
if target.get(2) == Some(&"windows") { |
|
|
|
if target.get(2) == Some(&"windows") { |
|
|
@ -29,12 +26,12 @@ fn bindgen_rocksdb() { |
|
|
|
.allowlist_var("rocksdb_.*") |
|
|
|
.allowlist_var("rocksdb_.*") |
|
|
|
.generate() |
|
|
|
.generate() |
|
|
|
.expect("unable to generate rocksdb bindings") |
|
|
|
.expect("unable to generate rocksdb bindings") |
|
|
|
.write_to_file(PathBuf::from(env::var("OUT_DIR").unwrap()).join("bindings.rs")) |
|
|
|
.write_to_file(PathBuf::from(var("OUT_DIR").unwrap()).join("bindings.rs")) |
|
|
|
.expect("unable to write rocksdb bindings"); |
|
|
|
.expect("unable to write rocksdb bindings"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fn build_rocksdb() { |
|
|
|
fn build_rocksdb() { |
|
|
|
let target = env::var("TARGET").unwrap(); |
|
|
|
let target = var("TARGET").unwrap(); |
|
|
|
|
|
|
|
|
|
|
|
let mut config = cc::Build::new(); |
|
|
|
let mut config = cc::Build::new(); |
|
|
|
config |
|
|
|
config |
|
|
@ -42,6 +39,7 @@ fn build_rocksdb() { |
|
|
|
.include("rocksdb/include/") |
|
|
|
.include("rocksdb/include/") |
|
|
|
.include("rocksdb/") |
|
|
|
.include("rocksdb/") |
|
|
|
.file("api/c.cc") |
|
|
|
.file("api/c.cc") |
|
|
|
|
|
|
|
.file("api/build_version.cc") |
|
|
|
.define("NDEBUG", Some("1")) |
|
|
|
.define("NDEBUG", Some("1")) |
|
|
|
.define("LZ4", Some("1")) |
|
|
|
.define("LZ4", Some("1")) |
|
|
|
.include("lz4/lib/"); |
|
|
|
.include("lz4/lib/"); |
|
|
@ -62,7 +60,7 @@ fn build_rocksdb() { |
|
|
|
// This is needed to enable hardware CRC32C. Technically, SSE 4.2 is
|
|
|
|
// This is needed to enable hardware CRC32C. Technically, SSE 4.2 is
|
|
|
|
// only available since Intel Nehalem (about 2010) and AMD Bulldozer
|
|
|
|
// only available since Intel Nehalem (about 2010) and AMD Bulldozer
|
|
|
|
// (about 2011).
|
|
|
|
// (about 2011).
|
|
|
|
let target_feature = env::var("CARGO_CFG_TARGET_FEATURE").unwrap(); |
|
|
|
let target_feature = var("CARGO_CFG_TARGET_FEATURE").unwrap(); |
|
|
|
let target_features: Vec<_> = target_feature.split(',').collect(); |
|
|
|
let target_features: Vec<_> = target_feature.split(',').collect(); |
|
|
|
if target_features.contains(&"sse2") { |
|
|
|
if target_features.contains(&"sse2") { |
|
|
|
config.flag_if_supported("-msse2"); |
|
|
|
config.flag_if_supported("-msse2"); |
|
|
@ -148,29 +146,13 @@ fn build_rocksdb() { |
|
|
|
config.flag("-std=c++11"); |
|
|
|
config.flag("-std=c++11"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// version file
|
|
|
|
|
|
|
|
let build_version_cc_path = Path::new("rocksdb/util/build_version.cc"); |
|
|
|
|
|
|
|
if !build_version_cc_path.exists() { |
|
|
|
|
|
|
|
let build_version_cc = include_str!("rocksdb/util/build_version.cc.in") |
|
|
|
|
|
|
|
.replace("@GIT_SHA@", "") |
|
|
|
|
|
|
|
.replace("@GIT_TAG@", "") |
|
|
|
|
|
|
|
.replace("@GIT_MOD@", "0") |
|
|
|
|
|
|
|
.replace("@GIT_DATE@", "") |
|
|
|
|
|
|
|
.replace("@BUILD_DATE@", ""); |
|
|
|
|
|
|
|
File::create(build_version_cc_path) |
|
|
|
|
|
|
|
.unwrap() |
|
|
|
|
|
|
|
.write_all(build_version_cc.as_bytes()) |
|
|
|
|
|
|
|
.unwrap(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for file in lib_sources { |
|
|
|
for file in lib_sources { |
|
|
|
if file == "db/c.cc" { |
|
|
|
if file == "db/c.cc" || file == "util/build_version.cc" { |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
let file = "rocksdb/".to_string() + file; |
|
|
|
let file = "rocksdb/".to_string() + file; |
|
|
|
config.file(&file); |
|
|
|
config.file(&file); |
|
|
|
} |
|
|
|
} |
|
|
|
config.cpp(true); |
|
|
|
|
|
|
|
config.compile("rocksdb"); |
|
|
|
config.compile("rocksdb"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -181,7 +163,7 @@ fn build_lz4() { |
|
|
|
.file("lz4/lib/lz4frame.c") |
|
|
|
.file("lz4/lib/lz4frame.c") |
|
|
|
.file("lz4/lib/lz4hc.c") |
|
|
|
.file("lz4/lib/lz4hc.c") |
|
|
|
.file("lz4/lib/xxhash.c"); |
|
|
|
.file("lz4/lib/xxhash.c"); |
|
|
|
if env::var("TARGET").unwrap() == "i686-pc-windows-gnu" { |
|
|
|
if var("TARGET").unwrap() == "i686-pc-windows-gnu" { |
|
|
|
config.flag("-fno-tree-vectorize"); |
|
|
|
config.flag("-fno-tree-vectorize"); |
|
|
|
} |
|
|
|
} |
|
|
|
config.compile("lz4"); |
|
|
|
config.compile("lz4"); |
|
|
|