-
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
rustc subcommand #1568
rustc subcommand #1568
Conversation
- `cargo rustc` is starting out based on `cargo build`
- The new field is a list with arguments to compile the target with. - There should only be one target that gets compiled with these arguments
…tions. - The new tests verifies that the extra arguments gets appended to the command. One is for lib and one is for main - Currently the arguments gets passed on to *every* target that gets built, so the tests only contain one file each
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @alexcrichton (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see CONTRIBUTING.md for more information. |
Compile a package and all of its dependencies | ||
|
||
Usage: | ||
cargo rustc [options] [<pkgid>] [--] [<opts>...] |
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.
Ah when I originally wrote this spec we didn't have a -p
argument, but nowadays this <pkgid>
argument should be specified through -p, --package
instead.
Nice! I left a comment about how I think
I'm excited to see progress on this! |
Thanks for the quick review! I'll look into [profile.dev]
opt-level = 0
debug = true
rustc-args = "..." I have a feeling this could be confusing together with dependencies, since only the final target will be compiled with these flags. Also, that would probably make a new subcommand like this unnecessary. |
- This field will be set by the `cargo rustc` command, only if one target is being compiled - The field can not be read from the Cargo.toml
…e that's being compiled instead. - An error will be returned if the length of `targets` is not 1 - The profile of `targets` gets cloned in order to append the extra arguments. - The new test verifies that the build fails due to both `lib` and `main` being compiled
… a dependency. - The test verifies that the trailing arguments only gets passed to the binary being built
- `build_with_args_to_one_of_multiple_binaries`, verify that only one bin gets built - `fails_with_args_to_all_binaries` - `build_with_args_to_one_of_multiple_tests`, same behavious as for the binaries - `build_foo_with_bar_dependency`, verify that bar dependency gets built and only foo gets compiled with args - `build_only_bar_dependency`, build the bar package, that foo depends, on with the extra args
@alexcrichton Have you had a chance to look at this? What do you think about the error message? It can be more descriptive, e.g. by including some more info about the targets that it tries to compile. Another thing I'm not so sure about concerning the tests, is that they're currently relying on the extra arguments to rustc to come after the |
Ah I will take another look @sondrele! Feel free to ping a PR with a comment as otherwise github doesn't send out notifications. I'd also recommend avoiding editing comments as modifications also don't send out notifications, and a few extra pieces of mail never hurt anyone :) |
For now let's avoid adding this step, but it's always a future possibility! |
Oh don't worry, the tests are super brittle in terms of overhauling the output already, so adding a few more won't harm anyone! |
&Some(args) => { | ||
if targets.len() > 1 { | ||
return Err(human("extra arguments to `rustc` can only be \ | ||
invoked for one target")) |
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.
Yeah I agree that it would be nice to improve this error message a bit. It would be nice for it to mention the filtering utilities (e.g. --lib
and --bin
) and then also perhaps provide a suggestion along the lines of "consider passing --lib
" (or something like that)
I added an extra line in the error message which hopefully makes it a little better (if the grammar's correct).
|
@bors: r+ |
📌 Commit 2cd3c86 has been approved by |
## Work in progress I have followed issue #595 for a while now. I hope that this PR can solve it, after it's done of course. @alexcrichton: on IRC the other day, you suggested adding a `Vec<String>` to the `CompileOptions`. I have done this, but wasn't sure what the best way to identify the correct `Target` would be, so currently everything gets compiled with the additional arguments. I considered adding a `Target` structure to the `CompileOptions` as well, and then in `cargo_rustc::build_base_args` only append the arguments if the `Target` matches. What do you think about this? Is there an easier way of figuring out the correct `Target`? r? @alexcrichton
☀️ Test successful - cargo-linux-32, cargo-linux-64, cargo-mac-32, cargo-mac-64, cargo-win-32, cargo-win-64 |
Awesome! Thanks for the thorough reviews! 👍 |
👍 |
Work in progress
I have followed issue #595 for a while now. I hope that this PR can solve it, after it's done of course.
@alexcrichton: on IRC the other day, you suggested adding a
Vec<String>
to theCompileOptions
. I have done this, but wasn't sure what the best way to identify the correctTarget
would be, so currently everything gets compiled with the additional arguments.I considered adding a
Target
structure to theCompileOptions
as well, and then incargo_rustc::build_base_args
only append the arguments if theTarget
matches. What do you think about this? Is there an easier way of figuring out the correctTarget
?r? @alexcrichton