Skip to content

Commit f049878

Browse files
committed
Build libredisearch.a dependency
1 parent e5bfb24 commit f049878

File tree

4 files changed

+15
-29
lines changed

4 files changed

+15
-29
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313

1414
- run:
1515
name: Install prerequisite
16-
command: sudo apt-get install -y clang llvm
16+
command: sudo apt-get install -y clang llvm cmake
1717

1818
- restore_cache:
1919
keys:

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ redismodule = { git = "https://github.com/RedisLabsModules/redismodule-rs.git",
2121

2222
[build-dependencies]
2323
bindgen = "0.51"
24-
cc = "1.0"
24+
cmake = "0.1"

README.md

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,12 @@ TODO:
1212

1313
## Building
1414

15-
```
16-
git clone https://github.com/RedisLabsModules/redismodule-rs.git
17-
git clone https://github.com/RediSearch/redisearch-api-rs.git
18-
cd redisearch-api-rs
19-
cargo build
20-
```
15+
cargo build
2116

2217
On macOS:
23-
- `brew install llvm`
2418

25-
* Make sure you have `libredisearch.a` built. This will be done automatically in the future.
26-
For more details see: https://github.com/RediSearch/RediSearch
19+
brew install llvm
2720

2821
### Build example
2922

30-
`cargo build --example hello_redisearch`
23+
cargo build --example hello_redisearch

build.rs

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
extern crate bindgen;
2-
extern crate cc;
32

4-
use std::env;
3+
use cmake::Config;
54

65
fn main() {
76
// Generate bindings for RediSearch
@@ -21,21 +20,15 @@ fn main() {
2120
.expect("failed to write RediSearch bindings to file");
2221

2322
// Find and link statically to libredisearch.a
23+
// TODO: Consider splitting the low level libredisearch wrapper off into a separate `-sys` crate.
2424

25-
// TODO: Instead of relying on a pre-built library,
26-
// we should build RediSearch as a static lib, like this:
27-
//
28-
// mkdir -p build
29-
// cd build
30-
// cmake -DRS_BUILD_STATIC=ON ..
31-
// make
32-
//
33-
// Take a look at some `-sys` crates for system library wrappers, and build using the
34-
// same methods that they use.
35-
// In fact, consider splitting this crate into a `-sys` crate for the low level wrappers
36-
// and another one for the high-level bindings.
37-
38-
let lib_search_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
39-
println!("cargo:rustc-link-search=native={}", lib_search_dir);
25+
let mut dst = Config::new("RediSearch")
26+
.define("RS_BUILD_STATIC", "ON")
27+
.build_target("redisearchS")
28+
.build();
29+
30+
dst.push("build");
31+
32+
println!("cargo:rustc-link-search=native={}", dst.display());
4033
println!("cargo:rustc-link-lib=static=redisearch");
4134
}

0 commit comments

Comments
 (0)