-
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 a JSON output mode to cargo package
.
#14262
base: master
Are you sure you want to change the base?
Conversation
In multi-crate workspaces, it can be ambiguous where files are sourced from when building packages. This extends the existing `--list` command line flag to optionally emit JSON when called as `-l=json` or `--list=json`. Existing behaviour is unaffected. The JSON format is slightly different to that proposed in rust-lang#11666: it exposes the distinction within `cargo::ops::cargo_package` itself around whether an archive file is generated or sourced from the disk. A new crate created with `cargo new --lib foo` generates this output: ```json { ".cargo_vcs_info.json": { "Generated": { "VcsInfo": { "git": { "sha1": "af0bf5917934ec4684cd23763f90c16242d7c5ce" }, "path_in_vcs": "" } } }, ".gitignore": { "OnDisk": "/tmp/foo/.gitignore" }, "Cargo.toml": { "Generated": "Manifest" }, "Cargo.toml.orig": { "OnDisk": "/tmp/foo/Cargo.toml" }, "src/lib.rs": { "OnDisk": "/tmp/foo/src/lib.rs" } } ``` I'm open minded as to whether the `VcsInfo` should actually be included, but it feels like there's little harm in doing so. Fixes rust-lang#11666, and is at least extremely relevant to rust-lang#13953.
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @weihanglo (or someone else) some time within the next two weeks. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
FYI I'm moving this to Draft as this has not been We generally reserve PRs for discussing the implementation and leaving problem, requirements, and solution discussions to the issues. I'd recommend furthering the discussion on the Issue. |
☔ The latest upstream changes (presumably #13947) made this pull request unmergeable. Please resolve the merge conflicts. |
☔ The latest upstream changes (possibly 081d7ba) made this pull request unmergeable. Please resolve the merge conflicts. |
In multi-crate workspaces, it can be ambiguous where files are sourced from when building packages. This extends the existing
--list
command line flag to optionally emit JSON when called as-l=json
or--list=json
. Existing behaviour is unaffected.The JSON format is slightly different to that proposed in #11666: it exposes the distinction within
cargo::ops::cargo_package
itself around whether an archive file is generated or sourced from the disk. A new crate created withcargo new --lib foo
generates this output:I'm open minded as to whether the
VcsInfo
should actually be included, but it feels like there's little harm in doing so.Fixes #11666, and is at least extremely relevant to #13953.