Default Cargo Target


#1

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.


#2

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]


#3

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


#4

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


#5

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


#6

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.