commit
a372ea678a
@ -0,0 +1,6 @@ |
||||
[submodule "rocksdb-sys/snappy"] |
||||
path = rocksdb-sys/snappy |
||||
url = https://github.com/google/snappy.git |
||||
[submodule "rocksdb-sys/rocksdb"] |
||||
path = rocksdb-sys/rocksdb |
||||
url = https://github.com/facebook/rocksdb.git |
@ -0,0 +1,2 @@ |
||||
target |
||||
Cargo.lock |
@ -0,0 +1,22 @@ |
||||
[package] |
||||
name = "rocksdb-sys" |
||||
version = "0.4.0" |
||||
authors = ["Karl Hobley <karlhobley10@gmail.com>", "Arkadiy Paronyan <arkadiy@ethcore.io>"] |
||||
license = "MIT/Apache-2.0/BSD" |
||||
description = "Native bindings to librocksdb" |
||||
readme = "README.md" |
||||
repository = "https://github.com/jsgf/rocksdb-sys.git" |
||||
keywords = [ "ffi", "rocksdb" ] |
||||
|
||||
build = "build.rs" |
||||
links = "rocksdb" |
||||
|
||||
[features] |
||||
default = [ "static" ] |
||||
static = [] |
||||
|
||||
[dependencies] |
||||
libc = "0.2" |
||||
|
||||
[build-dependencies] |
||||
gcc = { version = "0.3", features = ["parallel"] } |
@ -0,0 +1,6 @@ |
||||
include rocksdb/src.mk |
||||
|
||||
rocksdb_lib_sources.txt: rocksdb/src.mk |
||||
@echo -n ${LIB_SOURCES} > rocksdb_lib_sources.txt
|
||||
|
||||
gen_lib_sources: rocksdb_lib_sources.txt |
@ -0,0 +1,10 @@ |
||||
RocksDB bindings |
||||
================ |
||||
|
||||
Low-level bindings to RocksDB's C API. |
||||
|
||||
Based on original work by Tyler Neely |
||||
https://github.com/spacejam/rust-rocksdb |
||||
and Jeremy Fitzhardinge |
||||
https://github.com/jsgf/rocksdb-sys |
||||
|
@ -0,0 +1,116 @@ |
||||
extern crate gcc; |
||||
|
||||
fn link(name: &str, bundled: bool) { |
||||
use std::env::var; |
||||
let target = var("TARGET").unwrap(); |
||||
let target: Vec<_> = target.split('-').collect(); |
||||
if target.get(2) == Some(&"windows") { |
||||
println!("cargo:rustc-link-lib=dylib={}", name); |
||||
if bundled && target.get(3) == Some(&"gnu") { |
||||
let dir = var("CARGO_MANIFEST_DIR").unwrap(); |
||||
println!("cargo:rustc-link-search=native={}/{}", dir, target[0]); |
||||
} |
||||
} |
||||
} |
||||
|
||||
fn build_rocksdb() { |
||||
let mut config = gcc::Config::new(); |
||||
config.include("rocksdb/include/"); |
||||
config.include("rocksdb/"); |
||||
config.include("rocksdb/third-party/gtest-1.7.0/fused-src/"); |
||||
config.include("snappy/"); |
||||
config.include("."); |
||||
|
||||
config.define("NDEBUG", Some("1")); |
||||
config.define("SNAPPY", Some("1")); |
||||
|
||||
let mut lib_sources = include_str!("rocksdb_lib_sources.txt").split(" ").collect::<Vec<&'static str>>(); |
||||
|
||||
// We have a pregenerated a version of build_version.cc in the local directory
|
||||
lib_sources = lib_sources.iter().cloned().filter(|file| { |
||||
*file != "util/build_version.cc" |
||||
}) |
||||
.collect::<Vec<&'static str>>(); |
||||
|
||||
if cfg!(target_os = "macos") { |
||||
config.define("OS_MACOSX", Some("1")); |
||||
config.define("ROCKSDB_PLATFORM_POSIX", Some("1")); |
||||
config.define("ROCKSDB_LIB_IO_POSIX", Some("1")); |
||||
|
||||
} |
||||
if cfg!(target_os = "linux") { |
||||
config.define("OS_LINUX", Some("1")); |
||||
config.define("ROCKSDB_PLATFORM_POSIX", Some("1")); |
||||
config.define("ROCKSDB_LIB_IO_POSIX", Some("1")); |
||||
//COMMON_FLAGS="$COMMON_FLAGS -fno-builtin-memcmp"
|
||||
} |
||||
if cfg!(target_os = "freebsd") { |
||||
config.define("OS_FREEBSD", Some("1")); |
||||
config.define("ROCKSDB_PLATFORM_POSIX", Some("1")); |
||||
config.define("ROCKSDB_LIB_IO_POSIX", Some("1")); |
||||
} |
||||
|
||||
if cfg!(windows) { |
||||
link("rpcrt4", false); |
||||
config.define("OS_WIN", Some("1")); |
||||
|
||||
// Remove POSIX-specific sources
|
||||
lib_sources = lib_sources.iter().cloned().filter(|file| { |
||||
match *file { |
||||
"port/port_posix.cc" | |
||||
"util/env_posix.cc" | |
||||
"util/io_posix.cc" => false, |
||||
_ => true |
||||
} |
||||
}) |
||||
.collect::<Vec<&'static str>>(); |
||||
|
||||
// Add Windows-specific sources
|
||||
lib_sources.push("port/win/port_win.cc"); |
||||
lib_sources.push("port/win/env_win.cc"); |
||||
lib_sources.push("port/win/env_default.cc"); |
||||
lib_sources.push("port/win/win_logger.cc"); |
||||
lib_sources.push("port/win/io_win.cc"); |
||||
} |
||||
|
||||
if cfg!(target_env = "msvc") { |
||||
config.flag("-EHsc"); |
||||
} else { |
||||
config.flag("-std=c++11"); |
||||
} |
||||
|
||||
for file in lib_sources { |
||||
let file = "rocksdb/".to_string() + file; |
||||
config.file(&file); |
||||
} |
||||
|
||||
config.file("build_version.cc"); |
||||
|
||||
config.cpp(true); |
||||
config.compile("librocksdb.a"); |
||||
} |
||||
|
||||
fn build_snappy() { |
||||
let mut config = gcc::Config::new(); |
||||
config.include("snappy/"); |
||||
config.include("."); |
||||
|
||||
config.define("NDEBUG", Some("1")); |
||||
|
||||
if cfg!(target_env = "msvc") { |
||||
config.flag("-EHsc"); |
||||
} else { |
||||
config.flag("-std=c++11"); |
||||
} |
||||
|
||||
config.file("snappy/snappy.cc"); |
||||
config.file("snappy/snappy-sinksource.cc"); |
||||
config.file("snappy/snappy-c.cc"); |
||||
config.cpp(true); |
||||
config.compile("libsnappy.a"); |
||||
} |
||||
|
||||
fn main() { |
||||
build_rocksdb(); |
||||
build_snappy(); |
||||
} |
@ -0,0 +1,4 @@ |
||||
#include "build_version.h" |
||||
const char* rocksdb_build_git_sha = "rocksdb_build_git_sha:f201a44b4102308b840b15d9b89122af787476f1"; |
||||
const char* rocksdb_build_git_date = "rocksdb_build_git_date:2016-10-27"; |
||||
const char* rocksdb_build_compile_date = __DATE__; |
@ -0,0 +1,15 @@ |
||||
// Copyright (c) 2013, Facebook, Inc. All rights reserved.
|
||||
// This source code is licensed under the BSD-style license found in the
|
||||
// LICENSE file in the root directory of this source tree. An additional grant
|
||||
// of patent rights can be found in the PATENTS file in the same directory.
|
||||
//
|
||||
#pragma once |
||||
#if !defined(IOS_CROSS_COMPILE) |
||||
// if we compile with Xcode, we don't run build_detect_vesion, so we don't
|
||||
// generate these variables
|
||||
// this variable tells us about the git revision
|
||||
extern const char* rocksdb_build_git_sha; |
||||
|
||||
// Date on which the code was compiled:
|
||||
extern const char* rocksdb_build_compile_date; |
||||
#endif |
@ -0,0 +1 @@ |
||||
Subproject commit f201a44b4102308b840b15d9b89122af787476f1 |
File diff suppressed because one or more lines are too long
@ -0,0 +1 @@ |
||||
Subproject commit efb39e81b8b66b757ec900db33657c47b4750740 |
@ -0,0 +1,97 @@ |
||||
// Copyright 2011 Google Inc. All Rights Reserved.
|
||||
// Author: sesse@google.com (Steinar H. Gunderson)
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Various type stubs for the open-source version of Snappy.
|
||||
//
|
||||
// This file cannot include config.h, as it is included from snappy.h,
|
||||
// which is a public header. Instead, snappy-stubs-public.h is generated by
|
||||
// from snappy-stubs-public.h.in at configure time.
|
||||
|
||||
#ifndef THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_STUBS_PUBLIC_H_ |
||||
#define THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_STUBS_PUBLIC_H_ |
||||
|
||||
#define HAVE_STDINT_H 1 |
||||
|
||||
|
||||
#include <stdint.h> |
||||
|
||||
#include <stddef.h> |
||||
|
||||
//#include <sys/uio.h>
|
||||
|
||||
#if defined(_MSC_VER) |
||||
#define ssize_t intptr_t |
||||
#endif |
||||
|
||||
#define SNAPPY_MAJOR 1 |
||||
#define SNAPPY_MINOR 1 |
||||
#define SNAPPY_PATCHLEVEL 3 |
||||
#define SNAPPY_VERSION \ |
||||
((SNAPPY_MAJOR << 16) | (SNAPPY_MINOR << 8) | SNAPPY_PATCHLEVEL) |
||||
|
||||
#include <string> |
||||
|
||||
namespace snappy { |
||||
|
||||
#if HAVE_STDINT_H |
||||
typedef int8_t int8; |
||||
typedef uint8_t uint8; |
||||
typedef int16_t int16; |
||||
typedef uint16_t uint16; |
||||
typedef int32_t int32; |
||||
typedef uint32_t uint32; |
||||
typedef int64_t int64; |
||||
typedef uint64_t uint64; |
||||
#else |
||||
typedef signed char int8; |
||||
typedef unsigned char uint8; |
||||
typedef short int16; |
||||
typedef unsigned short uint16; |
||||
typedef int int32; |
||||
typedef unsigned int uint32; |
||||
typedef long long int64; |
||||
typedef unsigned long long uint64; |
||||
#endif |
||||
|
||||
typedef std::string string; |
||||
|
||||
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \ |
||||
TypeName(const TypeName&); \
|
||||
void operator=(const TypeName&) |
||||
|
||||
// Windows does not have an iovec type, yet the concept is universally useful.
|
||||
// It is simple to define it ourselves, so we put it inside our own namespace.
|
||||
struct iovec { |
||||
void* iov_base; |
||||
size_t iov_len; |
||||
}; |
||||
|
||||
} // namespace snappy
|
||||
|
||||
#endif // THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_STUBS_PUBLIC_H_
|
@ -0,0 +1,18 @@ |
||||
//
|
||||
// Copyright 2014 Tyler Neely
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
pub use ffi as rocksdb_ffi; |
||||
pub use ffi::{DBCompactionStyle, DBComparator, DBCompressionType, DBRecoveryMode, new_bloom_filter}; |
||||
pub mod ffi; |
Loading…
Reference in new issue