-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Add a mechanism to inform cargo not to rebuild the crate after running build script #3404
Comments
I guess a new special key from build script's output should work? |
Does this happen often? I'd be curious about what percentage of builds rerun a build script but don't want to rebuild the crate... |
I think with binding generated from C++ headers, that could happen more frequently than normal, especially when you use whitelist to include only specific types, functions, etc. in the result. |
Hm I'm not sure I quite follow. Could you elaborate more on the example? Is the library being bound not being compiled into the crate? How is bindgen detecting that no changes are made? etc. |
For example, if I have a C++ header: class A { /* ... */ };
class B { /* ... */ }; For some reason, we only want to have struct A { /* ... */ } Now, whatever you do to In larger projects, like Gecko, there are complicated dependencies between headers, and thus tons of headers, which may or may not affect the result, are indirectly included. But we only whitelist a small fraction of the types / functions declared in those files, and thus majority of changes to those files wouldn't really change the generated Rust code. Bindgen library itself is not able to detect whether there is any change, but the build script can check whether the generated code is different from what's currently inside the FWIW, Gecko's build system has a mechanism to avoid updating generated file if its content is not changed, so that all its dependants would not be triggered to rebuild. (Gecko's build system requires a manifest to specify which file is generated by which script or function, so it can apply a generic mechanism for all generated files. This is different than the design of Cargo's build script, though.) |
Oh, and, when you are debugging the build script, you may not really want the other part to build repeatedly as well. |
@upsuper thanks for the explanation! That definitely makes sense to me! |
#5663 includes some other use cases for this. |
I have this issue with a project where Specifically, it generates So any change to any test input causes a full 10 second re-link of the program, despite it being completely unnecessary. The only alternative is to manually maintain the As for why I do all this in |
If I'm understanding this issue correctly, In that case, users can workaround it by having a Longer term, it seems like #6529 would be the way to go. Personally, I'd be concerned about allowing users to say "don't rebuild, trust me". Doing that requires a certain level of checking anyways, so why not use that checking to ensure the mtime is unchanged? |
Not sure about the author of the issue, however in my case the But the problem is that the moment the |
Build script is usually used to do code generating, and sometimes, even the build script is triggered to rerun, the output generated code may not change at all. In that case, rebuilding the whole crate (and all its dependants) doesn't make sense.
There should be a mechanism for build script to inform that a rebuild is not needed from it.
The text was updated successfully, but these errors were encountered: