-
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 "metadata" subcommand (machine-readable package metadata output) #1434
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @wycats (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. |
Can you say more about the intended use case? |
I'm currently working on implementing cargo import support for intellij idea's rust plugin (https://github.com/Vektah/idea-rust). I'm going to send a PR to idea-rust with cargo import support in a couple of days, will post the link here. |
What about |
On Wed, Mar 18, 2015 at 09:05:41PM -0700, Yehuda Katz wrote:
My motivation for starting the subcommand 'dependencies' was to get more Currently it's a bit of a mess to extract this information from the So having a command that outputs infos about the really used |
@wycats, sure, will rename it to 'metadata'. @dan-t, sorry for hijacking your PR :) |
On Thu, Mar 19, 2015 at 03:10:15PM -0700, Vladislav Isenbaev wrote:
The name 'metadata' is a bit abstract and doesn't tell that much. I still
Well, I can't say that I'm absolutely happy about this, but the PR was |
@dan-t, sorry, I just wanted to push this change forward but chose inappropriate way to do so. I'll update this request so that it would be easier to incorporate my changes to your's and close it. As for naming, I don't think that limiting command to only output dependencies' info is a bit too strict. External programs may require information beyond that, for example project metadata, available features, targets information. |
On Fri, Mar 20, 2015 at 10:32:09AM -0700, Vladislav Isenbaev wrote:
It's ok :).
The question is if one command has to output all of these informations |
a46a574
to
f0af937
Compare
In my opinion, one configurable command is better, because calling multiple commands will cause additional overhead for parsing manifests/resolving dependencies compared to a single call. |
On Fri, Mar 20, 2015 at 02:02:45PM -0700, Vladislav Isenbaev wrote:
Yes, it might be the better option. I think that having a low level function that does only the resolving - Then everything else could be build on top of it. Currently I don't have that much time and energy, so if you want to push We shouldn't keep two PRs open for the same thing, so if you want to |
☔ The latest upstream changes (presumably #1440) made this pull request unmergeable. Please resolve the merge conflicts. |
It should be mergeable now. |
I'd really like to see this command as well, for flycheck-rust, which enables Emacs to check Rust code in Cargo projects on the fly. Currently it's pretty flaky, since it's essentially just guessing how the Cargo layout looks like. |
The subcommand dependencies outputs the resolved dependencies of a project, the concrete used versions including overrides, in a TOML format.
- Rebase to latest - Fix build - Rename dependencies -> metadata - Implement rustc-serialize based output with toml and json support - Add output-format and features flags - Output status messages to stderr instead of stdout
I'm not sure I know what you're referring to? What |
|
cc me |
@winger so this is looking good, but I'm still pretty worried about the output. For example there's quite a bit of information missing from the output, and the output is also currently ambiguous in some cases (e.g. you can't connect a dependency to what it's depending on). A lot of this stems from the fact that the Some specific information that I'm thinking is missing is:
Overall it seems like this command is kinda just a grab bag of putting information on stdout, and it's unclear what its purpose is beyond "learn some metadata about the local crate and its dependencies". I'd love to see a more targeted purpose for this subcommand which can precisely answer what sort of data needs to be emitted on stdout. It's ok to start out small/conservative (e.g. we can leave some fields out), but the output should never be ambiguous where dots can't be connected. One example could possibly be intending to use this command in conjunction with |
|
||
[packages.libB.features] | ||
featureA = ["featureB"] | ||
featureB = [] |
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 documentation seems to have diverged from what's actually output
☔ The latest upstream changes (presumably #1629) made this pull request unmergeable. Please resolve the merge conflicts. |
Closing due to inactivity, but feel free to reopen with a rebase and comments addressed! |
API changes needed for https://github.com/winger/cargo-metadata external command. See #1434 for previous discussion.
This hides `SerializedDependency` from general public, as requested [here](#1434 (comment)). It also hides `SerializedManifest` which was (wrongly?) exposed. This is required for #2196. I want to move in small steps this time, hence the separate PR. Technically this break backwards compatibility, because `SerializedDependency` and `SerializedManifest` were public (`SerializedPackage` was private however). Are such changes allowed in cargo?
Most of the work was done by @dan-t in rust-lang#1225 and by @winger in rust-lang#1434 Fixes rust-lang#2193
Most of the work was done by @dan-t in #1225 and by @winger in #1434 Fixes #2193 I failed to properly rebase previous attempts so I just salvaged this from bits and pieces. @alexcrichton are you sure that the default format should be TOML? I think that TOML is more suitable for humans, and JSON is better (at the moment at least) for tools. Maybe we should default to ~~TOML~~ JSON?
Export subcommand outputs project info in machine-readable format (currently TOML or JSON).
Currently output include: resolved dependencies (with overrides applied) with versions, local paths and features list.
Intended use cases include IDE and other build systems integration.
Example TOML output for cargo: https://gist.github.com/winger/d218f25aeb3c9ba36b3a
Note: this PR is based on @dan-t's PR: #1225