For example, if for your project you always cross compile using cargo build --target=thumbv6m-none-eabi
. This feature would let you add a key value pair to your cargo config file:
# .cargo/config
[target]
default = "thumbv6m-none-eabi"
That will let you simply call cargo build
to cross compile your project for thumbv6m-none-eabi
. This would also extend to cargo doc
.
Originally reported here.
This seems pretty reasonable to me, although I might go as far as to say that it should be in Cargo.toml as it's likely a per-project thing _if_ it's a thing to start out with.
One downside (?) of making it a project setting is that the setting will always be ignored for dependencies. Example: If my project P depends on crate D and D has set T as its default target, that setting will _always_ be ignored because D will always be compiled for the target I choose for P.
One advantage of using .cargo/config is that if I'm developing several crates locally, then I can have a setup like this:
$ tree .
my-RTOS-project
├── .cargo
│ └── config
├── allocator
│ └── (...)
├── hal
│ └── (...)
├── RusTOS
│ └── (...)
└── scheduler
└── (...)
And I can jump from one crate directory to another and run cargo test
. At some point I can edit a single line in .cargo/config and start testing my crates for a different target.
Aha yes indeed! That somewhat falls under the purview of https://github.com/rust-lang/cargo/issues/2122 where that _shouldn't_ be a downside, but there's still some design work to do there as well.
Most helpful comment
This seems pretty reasonable to me, although I might go as far as to say that it should be in Cargo.toml as it's likely a per-project thing _if_ it's a thing to start out with.