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

Investigate using cargo metadata internally #7

Closed
acmcarther opened this issue Feb 28, 2018 · 3 comments
Closed

Investigate using cargo metadata internally #7

acmcarther opened this issue Feb 28, 2018 · 3 comments

Comments

@acmcarther
Copy link
Member

I wrote most of the integration before cargo metadata existed. I'm content with just continuting to use Cargo's internals in the event that cargo metadata is missing something needed, but if its possible to use it today, we probably should.

Crosslinks:
rust-lang/cargo#3815

@acmcarther
Copy link
Member Author

acmcarther commented Mar 5, 2018

I've rewritten the planner to use output from cargo metadata, but I'm blocked by a small feature request to Cargo. rust-lang/cargo#5122 adds the extra data I need.

Once this change is in, the whole stack will get much more testable as it won't depend on weird internal state of Cargo objects.

EDIT: Prototype here https://github.com/google/cargo-raze/compare/use-cargo-metadata

bors added a commit to rust-lang/cargo that referenced this issue Mar 6, 2018
…a, r=alexcrichton

Emit Resolve.features_sorted in "cargo metadata"

This PR adds `features` to `metadata.resolve.nodes[*]` using the Resolve object's known features. This is different from the `features` fields that already exist elsewhere within metadata as this one is the actual features that need to be used in order to build the code.

Context: I'm currently using Cargo's internals to synthesize BUILD files for the Bazel build tool. `cargo metadata` currently provides almost everything I need in order to avoid using Cargo's internals -- *except* for this.

cc google/cargo-raze#7
@acmcarther
Copy link
Member Author

cc rust-lang/cargo#5583

I wasn't aware that these were outstanding issues. I'm currently working around lack of platform-specific details by performing dependency pruning:

if dep.target.is_some() {
// UNWRAP: Safe from above check
let target_str = dep.target.as_ref().unwrap();
let platform = try!(Platform::from_str(target_str));
// Skip this dep if it doesn't match our platform attributes
if !platform.matches(&settings.target, Some(&platform_attrs)) {
continue;
}
}

(using dependency.target and comparing with the configured target).

#53 tracks feature pruning (which is in an unclear state cargo-side as well).

@UebelAndre
Copy link
Collaborator

Is this investigation still open?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants