-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[WIP, do not commit] set Cargo.toml configuration from the command line #4380
Conversation
r? @matklad (rust_highfive has picked a reviewer for you, use r? to override) |
Thanks for the PR @froydnj! This seems pretty solid to me as an idea in terms of an implementation, especially b/c it just merges at the level of parsed TOML. I'd have a few reservations about the overall approach, though:
In terms of a solution for the problem at hand (especially if you'd like to backport to beta) my preference would be a |
Ah and also cc @rust-lang/cargo |
The original motivation is just profile configuration, yes. It's possible that we could restrict the power somewhat, either by:
Assuming I understand things correctly,
|
The Cargo team plans to discuss this PR, and the broader context, when we meet tomorrow morning. Should have an update for you after that! |
Cargo already looks at environment variables to override bits of .cargo/config (e.g. |
@froydnj hm ok you excellent point! The more I think about this though the more I'm thinking that the only section of You mentioned "--config applies to whatever Cargo.toml we find to build" which is I think sort of correct, but it's a bit deeper than this as well. This can lead to some perhaps surprising things though. For example:
In a sense the Basically along those lines I think there's a strong case to be made here for "profiles" specifically being overridden at build time, as they're a global resource. Similarly I think it naturally, to me at least, leads to the conclusion that environment-based Cargo.toml overrides (like @sfackler mentioned) may not work out as it's a global configuration overriding a non-global resource. (boy does placing So in that sense your alternative of Following that line of thinking, I'm actually sort of coming to the conclusion that we should just add flags everywhere! Taking TOML on the command line is a bit odd (seems weird to me at least), but I could imagine us adding something like:
That is, every "reasonable" option in Again though I think the most expedient solution would probably be |
☔ The latest upstream changes (presumably #4400) made this pull request unmergeable. Please resolve the merge conflicts. |
I'm going to close this due to inactivity, and I think the various issues were solved or otherwise worked around in the meantime? |
This pull request introduces
cargo build -c CONFIG
for settingCargo.toml
key-value pairs from the command line, suggested in #4349. Any config settings provided on the command line override those set inCargo.toml
. This sort of thing is probably most useful for settingprofile.$PROFILE.$X
options, but there are a number of other possibilities.It's not complete--there are a few XXX comments, tests are needed, and it's an open question how many commands should support this--but it is at least in a state where I thought feedback could be provided. @alexcrichton WDYT? Is this heading in the right direction?