Default Cargo Target

To build my STM32F0 project I run cargo build --target=thumbv6m-none-eabi. Is there some way to make thumbv6m-none-eabi the default target so I can just run cargo build like a normal cargo project?

I searched Google and here for "cargo target" and "cargo default target", but came up with no answers.

I really have no idea about it, but this seems relevant: https://github.com/rust-lang/cargo/blob/master/src/doc/config.md. At least, it has [target.$triple]

That's for configuring Cargo's linking toolchain on a per-target basis. Not relevant to my problem. Thanks for trying though.

There is no cargo feature for this, but I've wanted this before. So I've opened an issue for it.

The quick way to do it - use a wrapper script instead of your cargo binary containing:

~/rust/bin/cargo.bin --target=thumbv6m-none-eabi "$@"

after renaming cargo to cargo.bin

If you're running a shell, an alias could probably help you, although I am not sure if that is what you want.

Using a shell function would also make sense.

You can create a project-specific .cargo/config containing:

[build]
target = "thumbv6m-none-eabi"

It gets processed first, then your global .cargo/config would get processed. See Configuration - The Cargo Book.