-
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
Support crate renames in cargo metadata
#5461
Conversation
I wonder if we could hit a few birds with one stone by changing the output to something like:
We could only include |
Hm, this sounded really neat, and I was really excited about using a map instead of a list, but now I think it won't fly :( There are two problems: First, you can't use renames as keys, because of examples like this
Second, we already really need to add more info to dependencies (like, is it a normal dep or a build-dep), and we would need to add even more info, if we implement target-specific deps. (EDIT: so we need to switch from package_id's to objects anyway) I also would love to include not only explicit renames, but non-renamed crate names as well: that way, clients won't have to figure out that library name might be different from the package name, and that I guess I'll just feature gate this properly, and will try to find a better name for |
Ah ok that makes sense to me, sounds like we'll need an auxiliary array no matter what to express the kind of dependencies, so seems fine by me! |
034f8e3
to
1a13469
Compare
Updated! The strategy now is to basically dump edges of resolve, which were introduced recently.
#4632 is not fixed, because we don't know |
Looks good to me, thanks! Could this also update https://doc.rust-lang.org/nightly/cargo/reference/external-tools.html with relevant information? |
Sure! We historically have been bad with keeping that page really comprehensive. What do you think about saying: "this is API intended for developers of tools, so it is documented via doc comments in the source code, [link to some revision of |
☔ The latest upstream changes (presumably #5358) made this pull request unmergeable. Please resolve the merge conflicts. |
Yeah I think that's ok if the previous documentation is deleted, b/c I think after this PR it'd be out of date |
The old `dependencies` key in `resolve` is deprecated. Instead, the new `deps` key introduced which lists dependencies kinds (dev/build/normal) as well as `extern crate` name for the dep.
Ok! Let's then merge this PR first, and then update the separately, so that I have an url with reasonable revision to put into the docs! |
@bors: r+ Sounds good to me! |
📌 Commit a312c55 has been approved by |
Support crate renames in `cargo metadata` This adds information about (currently unstable) crate renames to metadata. Unfortunately, we already expose dependencies as a list of package ids (which are strings), so we can't easily add a `rename` field easily. For this reason, I've added a parallel `deps` key, which basically deprecates `dependencies` field. So, the new format looks like this ```JavaScript { "dependencies": [ "bar 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "bar 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" ], "deps": [ { "extern_crate_name": "baz", // this one is actually renamed "id": "bar 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" }, { "extern_crate_name": "bar", "id": "bar 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" } ], "features": [], "id": "foo 0.5.0 (path+file://[..])" }, ``` Questions: * Is there a better name for `extern_crate_name`? This name is precise, but it's longer than I like, and might become opaque in meaning if we remove `extern crate` from the language :) * Should we feature gate this (i.e, only produce `deps` if we have a feature in `Cargo.toml`)? I think the answer is yes, but that'll require threading `Features` to `Workspace`... r? @alexcrichton
Cargo doesn't need to know which cfgs would be active if it was building the crate, it just needs to say that the dependency is only loaded for target X or cfg Y in the metadata JSON. |
☀️ Test successful - status-appveyor, status-travis |
I am having second thoughts here. Currently, we expose raw dependencies and make the clients to the work of figuring out which dep applies to which target. A theoretically better solution would be to directly produce, for each target, its dependent targets. The problem here is that we don't have a |
…chton" This reverts commit d0d3cb5, reversing changes made to 757112c. It is unclear if the design is right, see rust-lang#5558 (comment)
…chton" This reverts commit d0d3cb5, reversing changes made to 757112c. It is not clear that the design is right, see rust-lang#5558 (comment)
Revert "Auto merge of #5461 - matklad:meta-rename, r=alexcrichton" This reverts commit d0d3cb5, reversing changes made to 757112c. It is unclear if the design is right, see #5558 (comment)
Revert "Auto merge of #5461 - matklad:meta-rename, r=alexcrichton" This reverts commit d0d3cb5, reversing changes made to 757112c. It is not clear that the design is right, see #5558 (comment) this is the backport sibling of #5576
- rust-lang/cargo#5577 - revert rust-lang/cargo#5461 (Support crate renames in `cargo metadata`) - rust-lang/cargo#5567 - Copy `--all-features` request to all workspace members
[BETA] Update Cargo - rust-lang/cargo#5577 - revert rust-lang/cargo#5461 (Support crate renames in `cargo metadata`) - rust-lang/cargo#5567 - Copy `--all-features` request to all workspace members
This adds information about (currently unstable) crate renames to metadata. Unfortunately, we already expose dependencies as a list of package ids (which are strings), so we can't easily add a
rename
field easily. For this reason, I've added a paralleldeps
key, which basically deprecatesdependencies
field.So, the new format looks like this
Questions:
extern_crate_name
? This name is precise, but it's longer than I like, and might become opaque in meaning if we removeextern crate
from the language :)deps
if we have a feature inCargo.toml
)? I think the answer is yes, but that'll require threadingFeatures
toWorkspace
...r? @alexcrichton