Control over the environment and rustflags with custom profiles

I want to use the new feature "custom profiles" to simplify my build wrapper: for example when I use cargo build --profile coverage I want everything to happen inside instead of having a build script ./ coverage that internally calls cargo.

For this I need per profile control over the environment variables (CFLAGS and more) and the rustc flags.

A nice way I found, that nearly does it are bash scripts that are configured as rustc-wrapper or rustc-workspace-wrapper in .cargo/config.toml. The only thing missing would be, that I have the profile name in some environment or parameter to set everything accordingly in my script. I was not able to find such a variable.

Is there a way to do what I am doing? Is there a recommended way? I know that per profile rustflags are being considered, but they are not here and the do not add (so I could configure flags for everything and additional flags for certain profiles). Also I do not see environment variables per profile anywhere.

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.