Short Question use build.rs for an batch after compiling?

Hello,

i want to use the build.rs to copy some files and use upx in the end of the batch process. But all Cargo Build Envs don't point directly to target/release folder and don't give me the correct FullPathname of the target/release/binary.exe.

Knows anybody how i can use envs for the target/release/binary.exe that i can use copy operations and upx in the build.rs?

thx

Are you trying to use build.rs to run upx on the compiled binary of the same crate? Build scripts run before compilation so you can't really do that. You can try using something like cargo-xtask or a Makefile.

(see also Add Cargo post-build scripts by dylanmckay · Pull Request #1777 · rust-lang/rfcs · GitHub)

build.rs is not for this purpose. it is run before compiling the crate, and it is invoked per package, not per binary/library/example/etc, so it makes no sense to provide the path of the target artifact as input to the build script.

1 Like

@yyogo thx for that informations, now is all clear. I will do some with shell-scripting/batching or try the links.

I can use makefiles? You mean make from the gnu-toolchain?

you can, but it may be simpler to just write a script/batch as you said, depending on your usecase

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.