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

corrosion_experimental_cbindgen always triggers rebuilds of files that include the generated header #503

Closed
flaviojs opened this issue Apr 11, 2024 · 3 comments

Comments

@flaviojs
Copy link

During development I run make to ensure new code can compile.
With cmake I expect only the files with changes to be rebuilt.

Since I started using corrosion_experimental_cbindgen (v0.4), whatever includes the generated header gets rebuilt every time.
The contents of the header did not change, only the timestamp changed.

Suggestion: generate to a temporary directory and use configure_file(COPYONLY) to update the wanted header.
This should provide the cmake-like experience of only rebuilding when there are changes.

@jschwe
Copy link
Collaborator

jschwe commented Apr 11, 2024

Did you try the latest version on master?

@jschwe
Copy link
Collaborator

jschwe commented Apr 11, 2024

To add some background:

configure_file is only available at CMake configure time, it's not a build command. It's not suitable because the bindings will not be regenerated if the rust code changes.

You need to use the most recent version of Corrosion, and use cbindgen 0.26 (or newer). If you don't have cbindgen installed at all, thats also fine - corrosion will build it for you.
The newest version of cbindgen generates a so called depfile (see mozilla/cbindgen#820), which lists which rust files the generated bindings depend on. Corrosion, then uses this depfile to tell CMake when the cbindgen command needs to be rerun.
The depfile feature requires a more recent CMake version then Corrosion v0.4 requires, so it is only used on the latest master (future v0.5 version) which already requires a sufficienlty new CMake version.

I'll be closing this issue for now, but if you still encounter this on the latest master version, the please reopen the issue and provide some more information so I can reproduce.

@jschwe jschwe closed this as completed Apr 11, 2024
@flaviojs
Copy link
Author

It works as expected after updating cbindgen to 0.26 and using master, thanks. :)

As a side note, since configure_file is only available at configure time, then cmake -E copy_if_different probably works at build time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants