-
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 unit-graph JSON output. #7977
Conversation
This looks quite good to me! Mind adding to the unstable docs documentation the info you have about the original motivation (features and units)? I didn't actually realize what the motivation was until after I read the PR and then read the description (I know, a bit backwards on my end...) Other than that this all seems pretty lightweight and flexible in the sense that it won't be a burden on us while it's not stabilized and it has a comfy path to stabilization too. |
☔ The latest upstream changes (presumably #7533) made this pull request unmergeable. Please resolve the merge conflicts. |
Updated docs (and added tracking issue). |
@bors: r+ |
📌 Commit 4107872 has been approved by |
☀️ Test successful - checks-azure |
Update cargo Update cargo 21 commits in bda50510d1daf6e9c53ad6ccf603da6e0fa8103f..7019b3ed3d539db7429d10a343b69be8c426b576 2020-03-02 18:05:34 +0000 to 2020-03-17 21:02:00 +0000 - Run through clippy (rust-lang/cargo#8015) - Fix config profiles using "dev" in `cargo test`. (rust-lang/cargo#8012) - Run CI on all PRs. (rust-lang/cargo#8011) - Add unit-graph JSON output. (rust-lang/cargo#7977) - Split workspace/validate() into multiple functions (rust-lang/cargo#8008) - Use Option::as_deref (rust-lang/cargo#8005) - De-duplicate edges (rust-lang/cargo#7993) - Revert "Disable preserving mtimes on archives" (rust-lang/cargo#7935) - Close the front door for clippy but open the back (rust-lang/cargo#7533) - Fix CHANGELOG.md typos (rust-lang/cargo#7999) - Update changelog note about crate-versions flag. (rust-lang/cargo#7998) - Bump to 0.45.0, update changelog (rust-lang/cargo#7997) - Bump libgit2 dependencies (rust-lang/cargo#7996) - Avoid buffering large amounts of rustc output. (rust-lang/cargo#7838) - Add "Updating" status for git submodules. (rust-lang/cargo#7989) - WorkspaceResolve: Use descriptive lifetime label. (rust-lang/cargo#7990) - Support old html anchors in manifest chapter. (rust-lang/cargo#7983) - Don't create hardlink for library test and integrations tests, fixing rust-lang/cargo#7960 (rust-lang/cargo#7965) - Partially revert change to filter debug_assertions. (rust-lang/cargo#7970) - Try to better handle restricted crate names. (rust-lang/cargo#7959) - Fix bug with new feature resolver and required-features. (rust-lang/cargo#7962)
This adds a
--unit-graph
flag that will emit a JSON object of Cargo's internal build graph. See unstable.md for more details.The primary motivator is to provide an accurate picture of which features are set. With the new feature resolver it is not possible to properly represent the features in the
cargo metadata
structure, because features are no longer unified. Also, features selected depend on the command, and exactly which packages are being built. To handle that incargo metadata
, it would need to add a "mode" flag, and a superset of flags for all build commands (test, check, build, etc.). To me that seemed like a difficult path to take.This may also be helpful for making visualizations of the true dependencies.
cargo metadata
doesn't show the intra-package dependencies like build scripts or test units, and walking thecargo metadata
graph correctly isn't always obvious.This initial concept exposes almost all of the fields. That may be a little too much, but I imagine we could always trim it before stabilizing. This structure also has a high risk of being unstable, since it has a good chance of changing form in the future. I figure that can be addressed with documentation emphasizing that it may change and we may not always provide backwards-compatibility (though we will try if it is not too much burden).
This could also potentially be extended in the future to include things like artifact paths, or "freshness", if we'd like to.