Commit 606eb048 authored by glorv's avatar glorv Committed by Yi Wu

support pre-generate bindings for aarch64 (#435)

* add pre generated binding for aarch64
Signed-off-by: 's avatarglorv <glorvs@163.com>
parent 16b671d7
......@@ -15,6 +15,9 @@ matrix:
- os: osx
osx_image: xcode11.3
rust: stable
- os: linux
arch: arm64
rust: stable
env:
global:
......@@ -23,12 +26,13 @@ env:
cache: false
before_script:
- rustup default nightly-2019-09-05
- rustup default nightly-2019-12-20
- rustup component add rustfmt-preview
- rustup component add clippy
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 build
- 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) {
fn config_binding_path() {
let file_path: PathBuf;
match env::var("TARGET").unwrap_or("".to_owned()).as_str() {
"x86_64-unknown-linux-gnu" => {
let target = env::var("TARGET").unwrap_or_else(|_| "".to_owned());
match target.as_str() {
"x86_64-unknown-linux-gnu" | "aarch64-unknown-linux-gnu" => {
file_path = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap())
.join("bindings")
.join("x86_64-unknown-linux-gnu-bindings.rs");
.join(format!("{}-bindings.rs", target));
if env::var("UPDATE_BIND")
.map(|s| s == "1".to_owned())
.map(|s| s.as_str() == "1")
.unwrap_or(false)
{
bindgen_rocksdb(&file_path);
......@@ -164,7 +165,7 @@ fn build_rocksdb() -> Build {
let build_dir = format!("{}/build", dst.display());
let mut build = Build::new();
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",
_ => "Debug",
};
......
......@@ -180,6 +180,9 @@ pub fn new_bloom_filter(bits: c_int) -> *mut DBFilterPolicy {
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 {
crocksdb_cache_create_lru(opt)
}
......@@ -379,6 +382,9 @@ pub enum DBBackgroundErrorReason {
MemTable = 4,
}
/// # Safety
///
/// ptr must point to a valid CStr value
pub unsafe fn error_message(ptr: *mut c_char) -> String {
let c_str = CStr::from_ptr(ptr);
let s = format!("{}", c_str.to_string_lossy());
......
......@@ -5,5 +5,8 @@
# The generated bindings will overwrite librocksdb_sys/bindings/*
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/*
......@@ -13,6 +13,10 @@
// 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 libc;
#[macro_use]
......
......@@ -887,7 +887,7 @@ impl DB {
pub fn drop_cf(&mut self, name: &str) -> Result<(), String> {
let cf = self.cfs.remove(name);
if cf.is_none() {
return Err(format!("Invalid column family: {}", name).clone());
return Err(format!("Invalid column family: {}", name));
}
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