-
Notifications
You must be signed in to change notification settings - Fork 307
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 specify expand
for the current crate?
#72
Comments
While I don't have my own code as an example, this publicly available code displays the same issue: https://github.com/getsentry/symbolic/tree/master/cabi. To reproduce:
If you add a |
No I don't think you're doing anything wrong. Specifying
Interesting, there might be a bug here with recursive calls to Maybe if this is done in the It seems like this works for you when you use the The long compile times with the CLI are unfortunately normal, as |
This seems likely! Perhaps cbindgen is compiling each crate independently when in expand mode?
It seems like cbindgen is doing more work than it needs to. Does it use a separate target/build dir for each crate that Is there a way to force cbindgen to reuse the same build artifacts as |
https://github.com/eqrion/cbindgen/blob/master/src/bindgen/cargo/cargo_expand.rs#L22 It seems like using You can simulate this by running:
a few times in your project. The first invocation will be slow as it compiles all the necessary artifacts, but the subsequent calls will be fast. Then run,
and you'll see it's like running it for the first time again (notice the target directory is |
I initially added use of I think this can be revisited and either be controlled by a flag or figure out how to use the correct target dir in Firefox/Gecko. |
@kirbysayshi Is this still an issue or has this been resolved? |
I haven't retested with a build.rs yet, but setting |
Okay I will close this for now, feel free to file a new issue if this problem reoccurs. |
I'm using cbindgen via a
build.rs
script within a root project. Let's call itffi_playground
. I have many macros withinffi_playground
that help with making the ffi, including generating structs and functions.My
cbindgen.toml
looks like this:With this configuration, my macros within
ffi_playground
(aka my root lib) are not expanded and my header is missing symbols.If I attempt to force
ffi_playground
to be expanded:Now my build never finishes! I get very little output, and watching activity monitor implies an infinite loop somewhere (lots of rustc processes). I have to CTRL+C cargo.
Curiously, if I remove
build.rs
, and instead use thecbindgen
CLI (still using cbindgen.toml), then with the first config I get the same result (incomplete header + warnings about missing symbols), and with the second config I get a complete header but the process takes ~30 seconds (which is a loooong time!).Am I doing something wrong? My assumption was that macros within the root crate would be expanded automatically, but that seems incorrect with the behavior I'm seeing.
The text was updated successfully, but these errors were encountered: