Unverified Commit 74299c38 authored by glorv's avatar glorv Committed by GitHub

support pre-generate bindings for aarch64 (#435)

* add pre generated binding for aarch64
Signed-off-by: 's avatarglorv <glorvs@163.com>
parent b67becf9
...@@ -15,6 +15,9 @@ matrix: ...@@ -15,6 +15,9 @@ matrix:
- os: osx - os: osx
osx_image: xcode11.3 osx_image: xcode11.3
rust: stable rust: stable
- os: linux
arch: arm64
rust: stable
env: env:
global: global:
...@@ -23,12 +26,13 @@ env: ...@@ -23,12 +26,13 @@ env:
cache: false cache: false
before_script: before_script:
- rustup default nightly-2019-09-05 - rustup default nightly-2019-12-20
- rustup component add rustfmt-preview - rustup component add rustfmt-preview
- rustup component add clippy - rustup component add clippy
script: script:
- make clippy # copile rocksdb may cost more than 10 minutes, see https://docs.travis-ci.com/user/common-build-problems/#build-times-out-because-no-output-was-received
- travis_wait make clippy
- cargo fmt --all -- --check - cargo fmt --all -- --check
- cargo build - cargo build
- cargo test --all - cargo test --all
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -45,13 +45,14 @@ fn bindgen_rocksdb(file_path: &PathBuf) { ...@@ -45,13 +45,14 @@ fn bindgen_rocksdb(file_path: &PathBuf) {
fn config_binding_path() { fn config_binding_path() {
let file_path: PathBuf; let file_path: PathBuf;
match env::var("TARGET").unwrap_or("".to_owned()).as_str() { let target = env::var("TARGET").unwrap_or_else(|_| "".to_owned());
"x86_64-unknown-linux-gnu" => { match target.as_str() {
"x86_64-unknown-linux-gnu" | "aarch64-unknown-linux-gnu" => {
file_path = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()) file_path = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap())
.join("bindings") .join("bindings")
.join("x86_64-unknown-linux-gnu-bindings.rs"); .join(format!("{}-bindings.rs", target));
if env::var("UPDATE_BIND") if env::var("UPDATE_BIND")
.map(|s| s == "1".to_owned()) .map(|s| s.as_str() == "1")
.unwrap_or(false) .unwrap_or(false)
{ {
bindgen_rocksdb(&file_path); bindgen_rocksdb(&file_path);
...@@ -164,7 +165,7 @@ fn build_rocksdb() -> Build { ...@@ -164,7 +165,7 @@ fn build_rocksdb() -> Build {
let build_dir = format!("{}/build", dst.display()); let build_dir = format!("{}/build", dst.display());
let mut build = Build::new(); let mut build = Build::new();
if cfg!(target_os = "windows") { if cfg!(target_os = "windows") {
let profile = match &*env::var("PROFILE").unwrap_or("debug".to_owned()) { let profile = match &*env::var("PROFILE").unwrap_or_else(|_| "debug".to_owned()) {
"bench" | "release" => "Release", "bench" | "release" => "Release",
_ => "Debug", _ => "Debug",
}; };
......
...@@ -180,6 +180,9 @@ pub fn new_bloom_filter(bits: c_int) -> *mut DBFilterPolicy { ...@@ -180,6 +180,9 @@ pub fn new_bloom_filter(bits: c_int) -> *mut DBFilterPolicy {
unsafe { crocksdb_filterpolicy_create_bloom(bits) } unsafe { crocksdb_filterpolicy_create_bloom(bits) }
} }
/// # Safety
///
/// `DBLRUCacheOptions` should pointer to a valid cache options
pub unsafe fn new_lru_cache(opt: *mut DBLRUCacheOptions) -> *mut DBCache { pub unsafe fn new_lru_cache(opt: *mut DBLRUCacheOptions) -> *mut DBCache {
crocksdb_cache_create_lru(opt) crocksdb_cache_create_lru(opt)
} }
...@@ -379,6 +382,9 @@ pub enum DBBackgroundErrorReason { ...@@ -379,6 +382,9 @@ pub enum DBBackgroundErrorReason {
MemTable = 4, MemTable = 4,
} }
/// # Safety
///
/// ptr must point to a valid CStr value
pub unsafe fn error_message(ptr: *mut c_char) -> String { pub unsafe fn error_message(ptr: *mut c_char) -> String {
let c_str = CStr::from_ptr(ptr); let c_str = CStr::from_ptr(ptr);
let s = format!("{}", c_str.to_string_lossy()); let s = format!("{}", c_str.to_string_lossy());
......
...@@ -5,5 +5,8 @@ ...@@ -5,5 +5,8 @@
# The generated bindings will overwrite librocksdb_sys/bindings/* # The generated bindings will overwrite librocksdb_sys/bindings/*
export UPDATE_BIND=1 export UPDATE_BIND=1
cargo build --target x86_64-unknown-linux-gnu if [ "$ARCH" == "" ]; then
ARCH=`uname -p`
fi
cargo build --target ${ARCH}-unknown-linux-gnu
rustfmt librocksdb_sys/bindings/* rustfmt librocksdb_sys/bindings/*
...@@ -13,6 +13,10 @@ ...@@ -13,6 +13,10 @@
// limitations under the License. // limitations under the License.
// //
// FIXME: we should remove this line after we add safe doc to all the unsafe functions
// see: https://rust-lang.github.io/rust-clippy/master/index.html#missing_safety_doc
#![allow(clippy::missing_safety_doc)]
extern crate core; extern crate core;
extern crate libc; extern crate libc;
#[macro_use] #[macro_use]
......
...@@ -887,7 +887,7 @@ impl DB { ...@@ -887,7 +887,7 @@ impl DB {
pub fn drop_cf(&mut self, name: &str) -> Result<(), String> { pub fn drop_cf(&mut self, name: &str) -> Result<(), String> {
let cf = self.cfs.remove(name); let cf = self.cfs.remove(name);
if cf.is_none() { if cf.is_none() {
return Err(format!("Invalid column family: {}", name).clone()); return Err(format!("Invalid column family: {}", name));
} }
unsafe { unsafe {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment