-
Notifications
You must be signed in to change notification settings - Fork 320
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
how to run cbindgen *after* rust compile? #472
Comments
Yes, I also gave up on the
You can have the |
|
I expect the simplest solution if you want to do it from |
I too was hit by this. I have a workaround that I use locally that solves it:
It just ignores parse errors because those would be handled by the rest of the build process anyway... I have no idea if it breaks other things, but it works for me and makes development a bit less annoying. :) Also, I have no idea why, but I wasn't able to use Maybe it should be added to the README? |
Adjusted @tasn's answer to read a bit cleaner: match cbindgen::generate(&crate_dir) {
Ok(bindings) => bindings.write_to_file("target/header.h"),
Err(cbindgen::Error::ParseSyntaxError { .. }) => return, // ignore in favor of cargo's syntax check
Err(err) => panic!("{:?}", err)
}; |
It's much cleaner, thanks for sharing! |
This is so much better. It should really be added to the README! |
This is a trap "for young players" an loosing feedback from rustc or your favorite code analysis tools won't make things better. Let's point out the issue and the solution given in issue mozilla#472 upfront.
This is a trap "for young players" and loosing feedback from rustc or your favorite code analysis tools won't make things better. Let's point out the issue and the solution given in issue mozilla#472 upfront.
This is a trap "for young players" and loosing feedback from rustc or your favorite code analysis tools won't make things better. Let's point out the issue and the solution given in issue #472 upfront.
Does anyone have recommendations for running cbindgen as post-build step? by using
build.rs
as recommended by the docs it makes it so when I have basic typos in my Rust code, I sometimes run into parse errors like this:instead of pretty rust compiler errors like this:
there's some discussion of a postbuild.rs in cargo: rust-lang/cargo#545 but also quite a bit of pushback on making cargo build more complex. It would be good to know if other folks have run into this and what solutions might be better than just temporarily renaming
build.rs
to disable cbindgen, then adding it back in once the Rust code works well.The text was updated successfully, but these errors were encountered: