summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs
index a7bd9618..c5d2b063 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -8,6 +8,7 @@ extern crate rustc_serialize;
use bindgen::clang_version;
use std::env;
+use std::panic;
mod options;
use options::builder_from_flags;
@@ -44,8 +45,24 @@ pub fn main() {
match builder_from_flags(bind_args.into_iter()) {
Ok((builder, output)) => {
- let mut bindings = builder.generate()
- .expect("Unable to generate bindings");
+
+ let builder_result =
+ panic::catch_unwind(||
+ builder.generate().expect("Unable to generate bindings")
+ );
+
+ if builder_result.is_err() {
+ println!("Bindgen unexpectedly panicked");
+ println!("This may be caused by one of the known-unsupported \
+ things (https://github.com/servo/rust-bindgen#c), \
+ please modify the bindgen flags to work around it as \
+ described in https://github.com/servo/rust-bindgen#c");
+ println!("Otherwise, please file an issue at \
+ https://github.com/servo/rust-bindgen/issues/new");
+ std::process::exit(1);
+ }
+
+ let mut bindings = builder_result.unwrap();
bindings.write(output)
.expect("Unable to write output");
bindings.write_dummy_uses()