servo: Merge #16880 - provide more information when bindgen fails (from froydnj:bindgen-informative-failure); r=emilio
authorNathan Froyd <froydnj@gmail.com>
Tue, 16 May 2017 07:19:53 -0500
changeset 409086 69d16243839bb2ab1206bc91cfdd9e7d021b90dd
parent 409085 fcb2c384b08b211f31d9c453cbf0ae90fb0e2b86
child 409087 638cd9bc82f45405386e56989af6b783f887c3cd
push id1490
push usermtabara@mozilla.com
push dateMon, 31 Jul 2017 14:08:16 +0000
treeherdermozilla-release@70e32e6bf15e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
servo: Merge #16880 - provide more information when bindgen fails (from froydnj:bindgen-informative-failure); r=emilio Providing the flags we passed into clang can be informative for double-checking that we set everything up correctly. - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [ ] These changes fix #__ (github issue number if applicable). Source-Repo: https://github.com/servo/servo Source-Revision: 0388e11db2532d41a71e184cb2a1f46e5107b8f5
servo/components/style/build_gecko.rs
--- a/servo/components/style/build_gecko.rs
+++ b/servo/components/style/build_gecko.rs
@@ -245,17 +245,24 @@ mod bindings {
         let out_file = OUTDIR_PATH.join(file);
         if let Some(modified) = get_modified_time(&out_file) {
             // Don't generate the file if nothing it depends on was modified.
             let last_modified = LAST_MODIFIED.lock().unwrap();
             if *last_modified <= modified {
                 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();
         }
         let bytes = result.into_bytes();
         File::create(&out_file).unwrap().write_all(&bytes).expect("Unable to write output");
     }