| 1 |
extern crate bindgen; |
| 2 |
extern crate pkg_config; |
| 3 |
|
| 4 |
pub fn main() { |
| 5 |
let conf = pkg_config::probe_library("libpjproject").expect("libpjproject not found!"); |
| 6 |
|
| 7 |
let mut clang_args = Vec::new(); |
| 8 |
|
| 9 |
|
| 10 |
for path in conf.include_paths { |
| 11 |
clang_args.push("-I".to_string()); |
| 12 |
clang_args.push( |
| 13 |
path.to_str() |
| 14 |
.expect(&format!("Couldn't convert PathBuf: {:?} to str!", path)) |
| 15 |
.to_string(), |
| 16 |
); |
| 17 |
} |
| 18 |
|
| 19 |
|
| 20 |
for define in conf.defines { |
| 21 |
if let Some(value) = define.1 { |
| 22 |
clang_args.push(format!("-D{}={}", define.0, value)); |
| 23 |
} |
| 24 |
} |
| 25 |
|
| 26 |
let bindings = bindgen::Builder::default() |
| 27 |
.header("../../../../pjsip/include/pjsua.h") |
| 28 |
.clang_args(clang_args) |
| 29 |
.generate_comments(false) |
| 30 |
.allowlist_type(r"pj.*") |
| 31 |
.allowlist_type(r"PJ.*") |
| 32 |
.allowlist_var(r"pj.*") |
| 33 |
.allowlist_var(r"PJ.*") |
| 34 |
.allowlist_function(r"pj.*") |
| 35 |
.allowlist_function(r"PJ.*") |
| 36 |
.generate() |
| 37 |
.expect("Couldn't generate bindings!"); |
| 38 |
|
| 39 |
let out_path = std::path::PathBuf::from(std::env::var("OUT_DIR").expect("OUT_DIR not set!")); |
| 40 |
|
| 41 |
bindings |
| 42 |
.write_to_file(out_path.join("bindings.rs")) |
| 43 |
.expect("Couldn't write bindings!"); |
| 44 |
} |