-
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
"cargo metadata" no longer displays "example" kind if example specifies crate-type #3654
Comments
@alexcrichton, Do we have tests for |
I think metadata should show both type of output and the information required to determine the correct cargo cmd line. |
@jethrogb, |
But you can execute build, rustc, or test with that flag. |
But I would rather prefer to add a field |
I think that would be sufficient? |
@jethrogb, |
I posted on the PR as well but I think we should revert the breaking change here and just extend the metadata format to otherwise accommodate examples-as-libraries in metadata. @KalitaAlexey would you be willing to prepare such a PR? |
@alexcrichton, |
@alexcrichton, |
Sure it is a breaking change. Before it was |
@jethrogb, |
@KalitaAlexey yeah this was a breaking change from before because existing code has broken. I think "kind" was probably a misnomer from before, so we should leave "kind" as it was and then add a separate "crate-types" field which has the information about crate types. |
@alexcrichton, |
Thanks @KalitaAlexey |
@alexcrichton, |
@alexcrichton, |
I think we've already got a list of crate types for any target (IIRC there's a method). Something like At this point |
Can we do the opposite and add a field named |
@jethrogb yes that's what I'd like to do. |
Just FYI, here are some in-the-wild usages of the "kind" metadata, if it will help you see how it is used:
|
Okay. |
Reverted the "kind" field to the previous value. Added a new field named "crate_types". Fixes #3654 After this PR `cargo metadata` would output: ```json { "packages": [ { "targets": [ { "kind": ["lib"], "crate_types": ["lib"] }, { "kind": ["example"], "crate_types": ["staticlib"] } ] } ] } ``` I have added tests.
As of /pull/3556, the
cargo metadata
command does not output the "kind" as "example" if the example specifies a crate-type. Sample Cargo.toml:I am working on a tool that uses the metadata output to determine which command-line arguments to pass to Cargo in order to build a target. Without knowing this is an example, it is impossible to know to pass --example.
I am unsure of what the correct solution is. Some ideas:
The text was updated successfully, but these errors were encountered: