How can I set default build target for Cargo?
22,735
Solution 1
You could use a Cargo configuration file to specify a default target-triple for your project. In your project's root, create a .cargo
directory and a config
file in it with the following contents:
[build]
target = "wasm32-unknown-unknown"
Solution 2
As listed in the Cargo documentation, you can create a .cargo/config
and specify the target:
[build]
target = "my-custom-target"
Related videos on Youtube
Comments
-
antono almost 2 years
I tried to make 'Hello World' in Rust using this tutorial, but the build command is a bit verbose:
cargo +nightly build --target wasm32-unknown-unknown --release
Is it possible to set the default target for
cargo build
? -
Usagi Ito over 3 yearsIs it work expectedly too now? I got the warning:
warning: unused manifest key: build
using 1.47.0-nightly. -
Jeff Muizelaar over 3 yearsAre you putting it in
Cargo.toml
?. You need to use.cargo/config
-
C. Dunn over 3 yearsThank you! And for others reading this in the future, you can see what targets Rust supports using
rustc --print target-list
. -
Peter Hansen about 2 years@C.Dunn And if using rustup, you can do
rustup target list
as well.