Skip to content

Provide a way to run build.rs and then cancel the build because it decides nothing has changed #5663

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

Closed
golddranks opened this issue Jun 28, 2018 · 4 comments
Labels
A-build-scripts Area: build.rs scripts C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`

Comments

@golddranks
Copy link
Contributor

golddranks commented Jun 28, 2018

There is the rerun-if-changed and rerun-if-env-changed which are very useful to avoid needless reruns. However, I'd like to rerun when there has been a new commit, because I'm using build.rs to embed the commit hash and title into the binary. build.rs can't find this out using just filesystem and environment variable monitoring. Currently I pass cargo:rerun-if-changed=.git, but it's prone to false positives, because any git operation will trigger rerun.

It would be useful if build.rs could be built and run, but it could then decide by itself whether anything has changed or not. Then I could check the latest git commit inside build.rs and act according to that. There is surely other cases too where "env var changed" and "file modified" don't cut it as the only rerun triggers; one might want to check if the contents of a file changed, or do some further processing, like parse a file and check if a specific field changed.

@alexcrichton alexcrichton added C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` A-build-scripts Area: build.rs scripts labels Jun 28, 2018
@golddranks
Copy link
Contributor Author

Btw. a quick question: would a feature like this need an RFC, or would it be sufficient to just implement it? I'm a bit out of the loop how the decision process works W.R.T Cargo features.

@fenhl
Copy link
Contributor

fenhl commented Sep 8, 2019

So the idea would be to use something like cargo:rerun-if-script-changed=git rev-parse --verify HEAD, right? That would be very useful.

@dtolnay
Copy link
Member

dtolnay commented Mar 13, 2021

I think this is a near duplicate of #3404.

@ehuss
Copy link
Contributor

ehuss commented Mar 15, 2021

Yea, seems like the same, closing as a duplicate of #3404.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-build-scripts Area: build.rs scripts C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`
Projects
None yet
Development

No branches or pull requests

5 participants