-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.rs
40 lines (32 loc) · 1.31 KB
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
extern crate bindgen;
use cmake::Config;
use std::env;
use std::path::PathBuf;
fn main() {
// Generate bindings for RediSearch
let bindings = bindgen::Builder::default()
.header("src/include/redisearch_api.h")
//.clang_arg("-I src/include") // For redismodule.h
.whitelist_var("(RS|RediSearch|REDISEARCH_|GC_POLICY).*")
.whitelist_function("RediSearch.*")
.blacklist_item("RedisModule.*")
.blacklist_type("__darwin_.*")
.size_t_is_usize(true)
.raw_line("use redis_module::raw::{RedisModuleCtx, RedisModuleString};")
.generate()
.expect("error generating RediSearch bindings");
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
bindings
.write_to_file(out_path.join("bindings.rs"))
.expect("failed to write bindings to file");
// Find and link statically to libredisearch.a
// TODO: Consider splitting the low level libredisearch wrapper off into a separate `-sys` crate.
let mut dst = Config::new("RediSearch")
.define("RS_BUILD_STATIC", "ON")
.define("GIT_DESCRIBE_VERSION", "0.0.0")
.build_target("redisearchS")
.build();
dst.push("build");
println!("cargo:rustc-link-search=native={}", dst.display());
println!("cargo:rustc-link-lib=static=redisearch");
}