Skip to content
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 kind/platform info to `cargo metadata` #7132

Open
wants to merge 1 commit into
base: master
from

Conversation

@ehuss
Copy link
Contributor

commented Jul 14, 2019

This adds an array "dep_kinds" to the resolve nodes of the cargo metadata output. It looks something like this:

"resolve": {
  "nodes": [
    "id": "cargo 0.39.0 (path+file:///Users/eric/Proj/rust/cargo2)",
    "deps": [
      {
        "name": "bufstream",
        "pkg": "bufstream 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
        "dep_kinds": [
          {
            "kind": "dev",
            "target": null
          }
        ]
      },
      {
        "name": "winapi",
        "pkg": "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
        "dep_kinds": [
          {
            "kind": null,
            "target": "cfg(windows)"
          }
        ]
      }
    ]
  ]
}

This allows one to filter the graph based on the dependency kind and platform.

I'm not completely confident that this is the right course, but I can't think of a better design. In particular, it seems a little strange to include all platforms, but features get filtered. This is probably not a problem in practice (one can use --all-features to ensure all features are shown for the top-level packages). Filtering out based on platform is very difficult, because you cannot determine from the resolve alone which nodes will be host vs target. That requires the entire Unit graph. We may expose the Unit graph in the future, but this seems like a useful and simple step.

This is a draft because I wanted to discuss this before moving forward. I'd like to add some more tests.

cc #4632. This doesn't filter based on target, but does expose the target names. As mentioned above, I don't think filtering is possible.
cc #5583. This adds more information.
Closes #3984.
Closes #4631 (I think).

cc @sfackler who filed some of these issues.

@alexcrichton

This comment has been minimized.

Copy link
Member

commented Jul 15, 2019

Seems like a reasonable approach to me! I agree this is a pretty simple, actionable, and useful step. Also agreed we can add more later!

@ehuss ehuss force-pushed the ehuss:metadata-kind branch from dcee3c3 to 8478379 Jul 22, 2019

@matklad

This comment has been minimized.

Copy link
Member

commented Jul 25, 2019

LGTM!

@sfackler

This comment has been minimized.

Copy link
Member

commented Jul 25, 2019

Awesome! With respect to platform-specific cfgs, it'd be great to have some utility (whether it's part of the cargo binary or a library) that can evaluate them against a target to see if they match.

@alexcrichton

This comment has been minimized.

Copy link
Member

commented Jul 25, 2019

Ok I think this has sat long enough, let's see support from the team about adding these fields!

@rfcbot fcp merge

@rfcbot

This comment has been minimized.

Copy link
Collaborator

commented Jul 25, 2019

Team member @alexcrichton has proposed to merge this. The next step is review by the rest of the tagged team members:

Concerns:

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@bors

This comment has been minimized.

Copy link
Contributor

commented Jul 29, 2019

☔️ The latest upstream changes (presumably #7186) made this pull request unmergeable. Please resolve the merge conflicts.

@ehuss ehuss force-pushed the ehuss:metadata-kind branch from 8478379 to 1401625 Jul 29, 2019

@Xanewok
Copy link
Member

left a comment

Looks good!

@bors

This comment has been minimized.

Copy link
Contributor

commented Aug 7, 2019

☔️ The latest upstream changes (presumably #7214) made this pull request unmergeable. Please resolve the merge conflicts.

@ehuss ehuss force-pushed the ehuss:metadata-kind branch from 1401625 to ef19c70 Aug 9, 2019

@joshtriplett

This comment has been minimized.

Copy link
Member

commented Aug 14, 2019

Based on discussion in the cargo meeting:

@rfcbot concern target should be cfg or similar

@rfcbot concern Document handling of features (and decide if we should emit a features field)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
8 participants
You can’t perform that action at this time.