I need some help on setting up a build environment for cargo.
In our project, we stick to cargo as the build tool. We have a workspace with many crates.
Beside cargo itself, we have some further dependencies. For example we need to ensure that
- an own version of cmake is available
- rustfmt has to be installed
- mold linker is the default
To ensure that the environment is in a valid state, we want to set the correct PATH environment
and download some artifacts before cargo starts building the crates.
I know about the possibilities to set the linker and environment variables in config.toml.
This is unfortunately not enough. We would also like to ensure that our artifacts ( like cmake ) get'downloaded and are available the path, before cargo starts to build.
Is there any way to tell cargo to run a shell-script before starting a build in our workspace ?
Maybe there is a way to inject every start of cargo once ?
Some things I already tried:
Set a rust-wrapper in config.toml
This is possible but will execute for every crate that's build. We need it only once.
I vendored crates that access external dependencies and modified the build scripts to
use our artifcats. For example I modified the cc create to point to our compiler
Further I added a [patch.crates-io] entry.
Unfortunately this has some drawbacks, when the versions of the cc crate changes, the patched version will not be used anymore. This leads also to maintenance efforts. Thefore I'd like to get away from this approach.