cbindgen
cbindgen copied to clipboard
`with_parse_expand(...)` from build.rs seems to hang indefinetly
I have a pretty simple project that uses macros. I try to expand them from inside my build.rs file and it seems to hang forever.
per my build script below... If I remove with_parse_expand(...)
line then my project generates headers fine except I don't get the expansions in my header. If I add back the with_parse_expand(...)
statement then my build never finishes. My repo is pretty minimal and perhaps it can be used to reproduce. : https://github.com/TomzBench/minicbor-c
Below is my build script:
use std::env;
fn main() {
let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
cbindgen::Builder::new()
.with_crate(crate_dir)
.with_parse_expand(&["minicbor-c"])
.generate()
.expect("Unable to generate bindings")
.write_to_file("minicbor.h");
}
Setting
.with_language(cbindgen::Language::C)
may help
my latest attempts had that in there. no help. Also, intermittently after killing the process, some cargo threads where stuck at 100% and i had to kill them.
my latest attempts had that in there. no help. Also, intermittently after killing the process, some cargo threads where stuck at 100% and i had to kill them.
It's working with
cbindgen = "0.21.0"
so it's a regression
yep - can confirm works with "0.21" for me also. Thanks.
Can someone bisect this by any chance? Should be easy to identify the broken commit.
Master version crashes with
Can someone bisect this by any chance? Should be easy to identify the broken commit.
❯ git bisect bad
aeb81934d1c4d3539cc426bbc46612b968adf653 is the first bad commit
commit aeb81934d1c4d3539cc426bbc46612b968adf653
Author: Vadim Petrochenkov <[email protected]>
Date: Thu Mar 31 19:46:41 2022 +0300
Avoid generating and writing bindings when called recursively
from a build script.
src/bindgen/bindings.rs | 17 +++++++++++++++++
src/bindgen/library.rs | 18 ++++++++++++++++++
src/bindgen/parser.rs | 7 -------
3 files changed, 35 insertions(+), 7 deletions(-)
Bisected from HEAD to 0.21 tag