forked from skade/leveldb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove dependency: leveldb-sys. Use deps (git-modules) instead.
Google Snappy, version: 1.2.1 Google Leveldb, commit ID: 23e35d7
- Loading branch information
Showing
22 changed files
with
359 additions
and
49 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,77 @@ | ||
on: [push, pull_request] | ||
on: | ||
push: | ||
branches: [ "master" ] | ||
pull_request: | ||
branches: [ "master" ] | ||
|
||
name: Continuous integration | ||
name: Continuous Integration | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
|
||
jobs: | ||
test-x86_64-unknown-linux-gnu: | ||
name: Test Suite (x86_64-unknown-linux-gnu) | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: minimal | ||
toolchain: stable | ||
override: true | ||
components: rustfmt, clippy | ||
- uses: actions-rs/cargo@v1 | ||
with: | ||
command: build | ||
args: --verbose | ||
- uses: actions-rs/cargo@v1 | ||
with: | ||
command: test | ||
args: --verbose | ||
|
||
test-x86_64-unknown-windows-msvc: | ||
name: Test Suite (x86_64-unknown-windows-msvc) | ||
runs-on: windows-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: minimal | ||
toolchain: stable | ||
override: true | ||
components: rustfmt, clippy | ||
- uses: actions-rs/cargo@v1 | ||
with: | ||
command: build | ||
args: --verbose | ||
- uses: actions-rs/cargo@v1 | ||
with: | ||
command: test | ||
args: --verbose | ||
|
||
test-x86_64-unknown-darwin: | ||
name: Test Suite (x86_64-unknown-darwin) | ||
runs-on: macos-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: minimal | ||
toolchain: stable | ||
override: true | ||
components: rustfmt, clippy | ||
- uses: actions-rs/cargo@v1 | ||
with: | ||
command: build | ||
args: --verbose | ||
- uses: actions-rs/cargo@v1 | ||
with: | ||
command: test | ||
args: --verbose |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
[submodule "deps/google-leveldb"] | ||
path = deps/google-leveldb | ||
url = https://github.com/google/leveldb.git | ||
[submodule "deps/google-snappy"] | ||
path = deps/google-snappy | ||
url = https://github.com/google/snappy.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
[package] | ||
name = "leveldb" | ||
version = "0.8.6" | ||
name = "leveldb-rs-binding" | ||
version = "0.8.7" | ||
edition = "2021" | ||
authors = [ | ||
"Florian Gilcher <[email protected]>", | ||
"Zhang Xin <zx3306@126.com>" | ||
"Zhang Xin <zxin3306@126.com>", | ||
] | ||
|
||
description = "An interface for leveldb" | ||
|
@@ -16,19 +16,24 @@ readme = "README.md" | |
homepage = "https://github.com/rim99/leveldb-rs-binding" | ||
repository = "https://github.com/rim99/leveldb-rs-binding" | ||
|
||
build = "src/sys/build.rs" | ||
links = "leveldb" | ||
autotests = false | ||
|
||
[features] | ||
default = ["leveldb-sys/snappy"] | ||
default = ["snappy"] | ||
snappy = [] | ||
|
||
[lib] | ||
name = "leveldb" | ||
|
||
[dependencies] | ||
libc = "0.2.158" | ||
libc = "0.2.*" | ||
ffi-opaque = "2" | ||
|
||
[dependencies.leveldb-sys] | ||
version = "2.0.0" | ||
[build-dependencies] | ||
cmake = "0.1" | ||
num_cpus = "1.10" | ||
|
||
[dev-dependencies] | ||
tempdir = "0.3.4" | ||
|
Submodule google-leveldb
added at
23e35d
Submodule google-snappy
added at
2c94e1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pub mod database; | ||
pub mod sys; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
use std::{ | ||
env, | ||
path::{Path, PathBuf}, | ||
}; | ||
|
||
/// Directory name within `$OUT_DIR` where the static libraries should be built. | ||
const LIBDIR: &'static str = "lib"; | ||
|
||
#[cfg(feature = "snappy")] | ||
fn build_snappy() -> PathBuf { | ||
println!("[snappy] Building"); | ||
|
||
let outdir = env::var("OUT_DIR").unwrap(); | ||
let libdir = Path::new(&outdir).join(LIBDIR); | ||
|
||
env::set_var("NUM_JOBS", num_cpus::get().to_string()); | ||
let dest_prefix = | ||
cmake::Config::new(Path::new("deps").join("google-snappy")) | ||
.define("BUILD_SHARED_LIBS", "OFF") | ||
.define("SNAPPY_BUILD_TESTS", "OFF") | ||
.define("SNAPPY_BUILD_BENCHMARKS", "OFF") | ||
.define("HAVE_LIBZ", "OFF") | ||
.define("CMAKE_INSTALL_LIBDIR", &libdir) | ||
.build(); | ||
|
||
assert_eq!( | ||
dest_prefix.join(LIBDIR), | ||
libdir, | ||
"CMake should build Snappy in provided LIBDIR" | ||
); | ||
println!("cargo:rustc-link-search=native={}", libdir.display()); | ||
println!("cargo:rustc-link-lib=static=snappy"); | ||
|
||
dest_prefix | ||
} | ||
|
||
fn build_leveldb(snappy_prefix: Option<PathBuf>) { | ||
println!("[leveldb] Building"); | ||
|
||
let outdir = env::var("OUT_DIR").unwrap(); | ||
let libdir = Path::new(&outdir).join(LIBDIR); | ||
|
||
env::set_var("NUM_JOBS", num_cpus::get().to_string()); | ||
let mut config = | ||
cmake::Config::new(Path::new("deps").join("google-leveldb")); | ||
config | ||
.define("LEVELDB_BUILD_TESTS", "OFF") | ||
.define("LEVELDB_BUILD_BENCHMARKS", "OFF") | ||
.define("CMAKE_INSTALL_LIBDIR", &libdir); | ||
if let Some(snappy_prefix) = snappy_prefix { | ||
#[cfg(target_env = "msvc")] | ||
let ldflags = format!("/LIBPATH:{}", snappy_prefix.join(LIBDIR).display()); | ||
#[cfg(not(target_env = "msvc"))] | ||
let ldflags = format!("-L{}", snappy_prefix.join(LIBDIR).display()); | ||
|
||
env::set_var( | ||
"LDFLAGS", | ||
ldflags | ||
); | ||
|
||
config | ||
.define("HAVE_SNAPPY", "ON") | ||
.cflag(format!("-I{}", snappy_prefix.join("include").display())) | ||
.cxxflag(format!("-I{}", snappy_prefix.join("include").display())); | ||
} else { | ||
config.define("HAVE_SNAPPY", "OFF"); | ||
} | ||
let dest_prefix = config.build(); | ||
|
||
assert_eq!( | ||
dest_prefix.join(LIBDIR), | ||
libdir, | ||
"CMake should build LevelDB in provided LIBDIR" | ||
); | ||
println!("cargo:rustc-link-search=native={}", libdir.display()); | ||
println!("cargo:rustc-link-lib=static=leveldb"); | ||
} | ||
|
||
fn main() { | ||
println!("[build] Started"); | ||
|
||
// If we have the appropriate feature, then we build snappy. | ||
#[cfg(feature = "snappy")] | ||
let snappy_prefix = Some(build_snappy()); | ||
#[cfg(not(feature = "snappy"))] | ||
let snappy_prefix: Option<PathBuf> = None; | ||
|
||
// Build LevelDB | ||
build_leveldb(snappy_prefix); | ||
|
||
// Link to the standard C++ library | ||
let target = env::var("TARGET").unwrap(); | ||
if target.contains("apple") || target.contains("freebsd") { | ||
println!("cargo:rustc-link-lib=c++"); | ||
} else if target.contains("gnu") || target.contains("netbsd") || target.contains("openbsd") { | ||
println!("cargo:rustc-link-lib=stdc++"); | ||
} else if target.contains("musl") { | ||
// We want to link to libstdc++ *statically*. This requires that the user passes the right | ||
// search path to rustc via `-Lstatic=/path/to/libstdc++`. | ||
println!("cargo:rustc-link-lib=static=stdc++"); | ||
} | ||
|
||
println!("[build] Finished"); | ||
} |
Oops, something went wrong.