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
41
42
43
extern crate regex;
#[macro_use]
extern crate serde_derive;
extern crate serde_json;
extern crate serde_xml_rs;
extern crate toml;
pub mod build;
pub mod configuration;
mod configuration_private;
mod cpp;
mod rust;
mod util;
use configuration::Config;
use std::error::Error;
use std::path::Path;
pub fn read_bindings_file<P: AsRef<Path>>(config_file: P) -> Result<Config, Box<dyn Error>> {
configuration::parse(config_file)
}
pub fn generate_bindings(config: &Config) -> Result<(), Box<dyn Error>> {
cpp::write_header(config)?;
cpp::write_cpp(config)?;
rust::write_interface(config)?;
rust::write_implementation(config)?;
Ok(())
}
pub fn generate_bindings_from_config_file<P: AsRef<Path>>(
config_file: P,
overwrite_implementation: bool,
) -> Result<(), Box<dyn Error>> {
let mut config = read_bindings_file(config_file)?;
if overwrite_implementation {
config.overwrite_implementation = true;
}
generate_bindings(&config)
}