-
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
add support for target.'cfg(..)'.runner
#5959
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
@@ -116,7 +116,7 @@ impl<'cfg> Compilation<'cfg> { | |||
rustc_process: rustc, | |||
host: bcx.host_triple().to_string(), | |||
target: bcx.target_triple().to_string(), | |||
target_runner: LazyCell::new(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made this eager which means that in the case of cfg
collision cargo run
will immediately fail.
Alternatively, if we kept this lazy in that scenario cargo run
will first build the crate and then emit an error message about the runners (I think).
I don't know if making this eager has any perceivable effects on existing uses of cargo run
.
Which behavior do we want here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nah I think eagerly loading it here should be fine!
let mut matching_runner = None; | ||
|
||
for t in table.val.keys() { | ||
if t.starts_with("cfg(") && t.ends_with(')') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like it's probably duplicating the logic when matching RUSTFLAGS
as well, could those two code paths perhaps be deduplicated?
☔ The latest upstream changes (presumably #5984) made this pull request unmergeable. Please resolve the merge conflicts. |
I'm writing the embedded Rust book and this would simplify instructions in a few places. Do you think this could still make it into 1.30-beta? In any case, I'll address the review comment as soon as I can. |
`cfg` can be used to reduce the number of `runner`s one needs to type in `.cargo/config`. So instead of writing this: ``` toml [target.thumbv6m-none-eabi] runner = "arm-none-eabi-gdb" [target.thumbv7m-none-eabi] runner = "arm-none-eabi-gdb" [target.thumbv7em-none-eabi] runner = "arm-none-eabi-gdb" [target.thumbv7em-none-eabihf] runner = "arm-none-eabi-gdb" ``` one can write: ``` toml [target.'cfg(all(target_arch = "arm", target_os = "none"))'] runner = "arm-none-eabi-gdb" ``` Handling of edge cases: - When `target.$triple.runner` matches it will be chosen regardless of the existence of others `target.'cfg(..)'.runner`s. - If more than one `target.'cfg(..)'.runner` matches the target the command will fail. closes rust-lang#5946
Rebased and addressed the review comment. |
@bors: r+ |
📌 Commit 33a6d99 has been approved by |
add support for `target.'cfg(..)'.runner` `cfg` can be used to reduce the number of `runner`s one needs to type in `.cargo/config`. So instead of writing this: ``` toml [target.thumbv6m-none-eabi] runner = "arm-none-eabi-gdb" [target.thumbv7m-none-eabi] runner = "arm-none-eabi-gdb" [target.thumbv7em-none-eabi] runner = "arm-none-eabi-gdb" [target.thumbv7em-none-eabihf] runner = "arm-none-eabi-gdb" ``` one can write: ``` toml [target.'cfg(all(target_arch = "arm", target_os = "none"))'] runner = "arm-none-eabi-gdb" ``` Handling of edge cases: - When `target.$triple.runner` matches it will be chosen regardless of the existence of others `target.'cfg(..)'.runner`s. - If more than one `target.'cfg(..)'.runner` matches the target the command will fail. closes #5946 --- Does this sound like a reasonable feature / implementation?
☀️ Test successful - status-appveyor, status-travis |
cfg
can be used to reduce the number ofrunner
s one needs to type in.cargo/config
. So instead of writing this:one can write:
Handling of edge cases:
When
target.$triple.runner
matches it will be chosen regardless of theexistence of others
target.'cfg(..)'.runner
s.If more than one
target.'cfg(..)'.runner
matches the target the command willfail.
closes #5946
Does this sound like a reasonable feature / implementation?