Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse errors in capi cause an unhelpful panic in the build script #24093

Open
jdm opened this issue Aug 29, 2019 · 1 comment
Open

Parse errors in capi cause an unhelpful panic in the build script #24093

jdm opened this issue Aug 29, 2019 · 1 comment

Comments

@jdm
Copy link
Member

@jdm jdm commented Aug 29, 2019

If there's a syntax error in any of the code in the capi crate, all you get to learn is this:

error: failed to run custom build command for `simpleservo_capi v0.0.1 (C:\Users\image\servo-g-streamer\ports\libsimpleservo\capi)`

Caused by:
  process didn't exit successfully: `C:\Users\image\servo-g-streamer\target\debug\build\simpleservo_capi-f9dd5c31aa552a3a\build-script-build` (exit code: 101)
--- stderr
thread 'main' panicked at 'Unable to generate bindings: ParseSyntaxError { crate_name: "simpleservo_capi", src_path: "C:\\Users\\image\\servo-g-streamer\\ports\\libsimpleservo\\capi\\src\\lib.rs", error: Error("LexError") }', src\libcore\result.rs:1084:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

It would be much easier to not panic during the build script and find out the actual error during the normal build instead.

@jdm
Copy link
Member Author

@jdm jdm commented Sep 4, 2019

diff --git a/ports/libsimpleservo/capi/build.rs b/ports/libsimpleservo/capi/build.rs
index ad1bfa9e79..e0bb8e3458 100644
--- a/ports/libsimpleservo/capi/build.rs
+++ b/ports/libsimpleservo/capi/build.rs
@@ -17,11 +17,12 @@ fn main() {
     let profile_dir = env::var("PROFILE").unwrap();
     path.push(profile_dir);
     path.push("simpleservo.h");
-    cbindgen::Builder::new()
+    if let Ok(b) = cbindgen::Builder::new()
         .with_crate(crate_dir)
         .with_language(cbindgen::Language::C)
         .exclude_item("OutputDebugStringA")
         .generate()
-        .expect("Unable to generate bindings")
-        .write_to_file(path);
+    {
+        b.write_to_file(path);
+    }
 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.