HiveBrain v1.2.0
Get Started
← Back to all entries
snippetrustCritical

How can I set default build target for Cargo?

Submitted by: @import:stackoverflow-api··
0
Viewed 0 times
howsetfortargetcancargobuilddefault

Problem

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?

Solution

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.toml file in it with the following contents:
[build]
target = "wasm32-unknown-unknown"


Put this in .cargo/config.toml. Not in your cargo.toml.

Context

Stack Overflow Q#49453571, score: 102

Revisions (0)

No revisions yet.