provide more information when bindgen fails

Providing the flags we passed into clang can be informative for
double-checking that we set everything up correctly.
This commit is contained in:
Nathan Froyd 2017-05-15 16:45:01 -04:00
parent dfb9396296
commit 22db4b4823

View file

@ -250,7 +250,14 @@ mod bindings {
return;
}
}
let mut result = builder.generate().expect("Unable to generate bindings").to_string();
let command_line_opts = builder.command_line_flags();
let result = builder.generate();
let mut result = match result {
Ok(bindings) => bindings.to_string(),
Err(_) => {
panic!("Failed to generate bindings, flags: {:?}", command_line_opts);
},
};
for fixup in fixups.iter() {
result = Regex::new(&format!(r"\b{}\b", fixup.pat)).unwrap().replace_all(&result, fixup.rep.as_str())
.into_owned().into();