Skip to content

Commit

Permalink
Workaround for bad errors when cbindgen fails to parse the code.
Browse files Browse the repository at this point in the history
Upstream issue: mozilla/cbindgen#472
  • Loading branch information
tasn committed Mar 26, 2020
1 parent 98a5a77 commit 4c5ad90
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,16 @@ use std::env;

fn main() {
let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
cbindgen::generate(&crate_dir)
.unwrap()
.write_to_file("target/etesync.h");
match cbindgen::generate(&crate_dir) {
Ok(gen) => gen,
Err(e) => match e {
// Ignore syntax errors because those will be handled later on by cargo build.
cbindgen::Error::ParseSyntaxError {
crate_name: _,
src_path: _,
error: _,
} => return,
_ => panic!("{:?}", e),
},
}.write_to_file("target/etesync.h");
}

0 comments on commit 4c5ad90

Please sign in to comment.