Reputation: 8052
I know that build.rs
can perform tasks before the program compilation starts, so I can prepare whatever I want.
What if there's a task to be performed after the compilation is complete, as some sort of cleanup? Is there any way to do such a thing?
As a simple example: before compilation I want rename a file from foo.txt
to abc.txt
for whatever reason. Then after the compilation terminates I want to rename it back to foo.txt
.
Upvotes: 4
Views: 5259
Reputation: 1781
A simple solution to this, if you have a workspace project:
thingamabob_post_build
build.rs
in the new projectUpvotes: 1
Reputation: 430961
No, there is nothing as of Rust 1.50. RFC #1777 — Add Cargo post-build scripts proposed this, but it was not accepted.
In the meantime, some crates make their own local Cargo third-party commands to mimic this. Documentation of one style of this can be found in the cargo-xtask repository. The TL;DR form:
cargo xtask build
.See also:
Upvotes: 7