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
#[macro_use]
extern crate log;
extern crate serde;
#[macro_use]
extern crate serde_derive;
extern crate serde_json;
extern crate syn;
extern crate toml;
mod bindgen;
pub use bindgen::*;
use std::path::Path;
pub fn generate<P: AsRef<Path>>(crate_dir: P) -> Result<Bindings, String> {
let config = Config::from_root_or_default(crate_dir.as_ref());
generate_with_config(crate_dir, config)
}
pub fn generate_with_config<P: AsRef<Path>>(crate_dir: P, config: Config) -> Result<Bindings, String> {
let cargo = Cargo::load(crate_dir.as_ref(),
None,
config.parse.parse_deps)?;
LibraryBuilder::new().with_config(config)
.with_std_types()
.with_crate(cargo)
.build()?.generate()
}