Query Cargo Configuration

How do I access the build configuration that Cargo actually uses to perform its work. If my Cargo.toml is fairly minimal, it won't have very much information. Cargo relies on conventions in order to figure out most of what it needs to do. Is there a way for me to query information about things like what filename Cargo will choose for the final executable of its build?

On Linux/Mac, my executable is build into the file target/debug/foo. Is there a way for me to ask Cargo to give me that filename? This is important because that name will be different on other platforms. On Windows for example it will be target/debug/foo.exe.

Related question: Is it possible to query information about the current build from a build script? For example, could I find out if the current build is a debug build or a release build?

1 Like

Cargo exposes some information via environment variables: https://github.com/rust-lang/cargo/blob/master/src/doc/environment-variables.md


These docs might be useful:Page Moved


Thank you both! Those links are exactly what I was looking for :smiley: