-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.rs
31 lines (26 loc) · 974 Bytes
/
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
extern crate bindgen;
extern crate pkg_config;
use std::env;
use std::path::PathBuf;
fn main() {
let lib = "ext2fs";
let library = pkg_config::probe_library(lib).unwrap();
println!("cargo:version={}", library.version);
let includedir = pkg_config::get_variable(lib, "includedir").unwrap();
println!("cargo:includedir={}", includedir);
let (clang_version_major, clang_version_minor) = bindgen::clang_version().parsed.unwrap();
let bindings = bindgen::Builder::default()
.header("wrapper.h")
.clang_arg(format!("-I{}", includedir))
.clang_arg(format!(
"-I/usr/lib/clang/{}.{}/include",
clang_version_major,
clang_version_minor
))
.generate()
.expect("Unable to generate bindings");
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
bindings
.write_to_file(out_path.join("bindings.rs"))
.expect("Couldn't write bindings!");
}