-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add a way to set a default --target
#2332
Comments
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:
And I can jump from one crate directory to another and run |
Aha yes indeed! That somewhat falls under the purview of #2122 where that shouldn't be a downside, but there's still some design work to do there as well. |
Fixed #2332. This PR adds `build.target` to the Cargo config file, which behaves in the same way as passing `--target` to Cargo. Example `.cargo/config`: ``` [build] target = "thumbv6m-none-eabi" ``` Similar to how `--jobs` overrides `build.jobs`, `--target` will override `build.target`. I added documentation to `config.md`, and a test to `test_cargo_cross_compile.rs`. I couldn't get cross compile working on my machine for `cargo test`. Hopefully travis passes it. This is my first PR against Cargo; sorry if I missed any procedures.
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:That will let you simply call
cargo build
to cross compile your project forthumbv6m-none-eabi
. This would also extend tocargo doc
.Originally reported here.
The text was updated successfully, but these errors were encountered: