extern crate bindgen;
extern crate cmake;
use std::env;
use std::path::PathBuf;
use cmake::Config;
fn main() {
let dst = Config::new("keyvi_core/").build_target("keyvi_c").build();
println!("cargo:rustc-link-lib=dylib=keyvi_c");
println!(
"cargo:rustc-link-search=native={}",
dst.join("build").display()
);
println!("Starting to generate bindings..");
let bindings = bindgen::Builder::default()
.header("keyvi_core/keyvi/include/keyvi/c_api/c_api.h")
.clang_arg("-x")
.clang_arg("c++")
.enable_cxx_namespaces()
.layout_tests(true)
.allowlist_function("keyvi_bytes_destroy")
.allowlist_function("keyvi_string_destroy")
.allowlist_function("keyvi_create_dictionary")
.allowlist_function("keyvi_dictionary_destroy")
.allowlist_function("keyvi_dictionary_get")
.allowlist_function("keyvi_dictionary_get_all_items")
.allowlist_function("keyvi_dictionary_get_fuzzy")
.allowlist_function("keyvi_dictionary_get_multi_word_completions")
.allowlist_function("keyvi_dictionary_get_prefix_completions")
.allowlist_function("keyvi_dictionary_get_size")
.allowlist_function("keyvi_dictionary_get_statistics")
.allowlist_function("keyvi_match_destroy")
.allowlist_function("keyvi_match_get_matched_string")
.allowlist_function("keyvi_match_get_msgpacked_value")
.allowlist_function("keyvi_match_get_score")
.allowlist_function("keyvi_match_get_value_as_string")
.allowlist_function("keyvi_match_is_empty")
.allowlist_function("keyvi_match_iterator_dereference")
.allowlist_function("keyvi_match_iterator_destroy")
.allowlist_function("keyvi_match_iterator_empty")
.allowlist_function("keyvi_match_iterator_increment")
.generate()
.expect("Unable to generate bindings");
println!("Saving to 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!");
}