Skip to content

Commit c341c9d

Browse files
committed
Add missing build.rs
1 parent e282414 commit c341c9d

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

build.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
use std::path::PathBuf;
2+
3+
fn main() {
4+
// Tell cargo to look for shared libraries in the specified directory
5+
println!("cargo:rustc-link-search=./");
6+
7+
// Tell cargo to tell rustc to link the system bzip2
8+
// shared library.
9+
println!("cargo:rustc-link-lib=chdb");
10+
11+
// Tell cargo to invalidate the built crate whenever the wrapper changes
12+
println!("cargo:rerun-if-changed=chdb.h");
13+
14+
// The bindgen::Builder is the main entry point
15+
// to bindgen, and lets you build up options for
16+
// the resulting bindings.
17+
let bindings = bindgen::Builder::default()
18+
// The input header we would like to generate
19+
// bindings for.
20+
.header("chdb.h")
21+
// Tell cargo to invalidate the built crate whenever any of the
22+
// included header files changed.
23+
.parse_callbacks(Box::new(bindgen::CargoCallbacks))
24+
// Finish the builder and generate the bindings.
25+
.generate()
26+
// Unwrap the Result and panic on failure.
27+
.expect("Unable to generate bindings");
28+
29+
// Write the bindings to the $OUT_DIR/bindings.rs file.
30+
let out_path = PathBuf::from("./src/");
31+
bindings
32+
.write_to_file(out_path.join("bindings.rs"))
33+
.expect("Couldn't write bindings!");
34+
}

0 commit comments

Comments
 (0)