I'd like the build output directory to follow the architecture I'm building on.
Currently when I use "Cargo build" without any target it puts the output in ./target/debug or ./target/release. When I build for other target architectures, it puts them into ./target/[architecture string]/debug (or release).
Seems internally rust is using rustc -vV to determine the architecture and I want to use that.
Is there a way to have it default to the current target architecture folder without hardcoding the path output directory?
The use-case here is we are building apps on multiple platforms by multiple people. And everybody's building into the same directory. We'd like it to output to the same directory as the target architecture as they're building on.
We can configure Cargo to use the target architecture as the output directory for build artifacts by setting the CARGO_TARGET_DIR environment variable.
Set up CARGO_TARGET_DIR directly in command line:
$ CARGO_TARGET_DIR="./target/$(rustc -vV:target_arch)/" cargo build
Or it would be handy if we put up on each project basis (.env
file):
CARGO_TARGET_DIR="./target/$(rustc -vV:target_arch)/"
In this way, you don't have to specify the target directory every time you cargo build
.