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 feature dependencies to all targets but lib #2056

Closed
wants to merge 3 commits into from
Closed

Add feature dependencies to all targets but lib #2056

wants to merge 3 commits into from

Conversation

tsurai
Copy link

@tsurai tsurai commented Oct 14, 2015

This small PR adds the ability to use feature dependencies for all targets but lib fixing issue #1570

# ...

[features]
a = []
b = []

[[example]]
name = "ex_5"
features = ["a", "b"]

[[bin]]
name = "foobar"
path = "src/foo.rs"
features = ["a"]

Please tell me if and how the user should be notified about ignored targets as I am not sure how verbose cargo should be. Big thanks to @alexcrichton for guiding me.

As always, critique is much appreciated.

@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @wycats (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

features.clone()
}
}
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The set of activated features for a package is actually best learned through Resolve which should be available by the time this gets down below I believe.

@alexcrichton
Copy link
Member

Thanks! Can you be sure to add some tests for this as well?

@bors
Copy link
Contributor

bors commented Oct 20, 2015

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

@tsurai
Copy link
Author

tsurai commented Oct 22, 2015

I've made the changes you suggested and added a few tests. Please tell me if those are insufficient.

@@ -361,6 +363,16 @@ fn generate_targets<'a>(pkg: &'a Package,
Ok(targets)
}
};

targets.map(|x| x.iter().filter_map(|&(t, p)| {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm perhaps this changed from before? It looks like the map part of filter_map isn't being used, so this may be able to just be a filter.

It may also be more clear here to explicitly use if/else instead of a match for the logic, the multi-line guard for one of the arms was a little jarring.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, instead of having targets be of the type CargoResult<Vec<_>> it's probably best to have it just be Vec<_> (e.g. remove all the Ok above) and just wrap it in Ok after the filtering is done.

Ah and as a final point I think this can use retain instead of iter + filter + collect

@bors
Copy link
Contributor

bors commented Nov 10, 2015

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

@JanLikar
Copy link
Contributor

Is this still being worked on?

@alexcrichton
Copy link
Member

@JanLikar I think this may be going a bit stale, so if you want to pick it up feel free to!

@ebkalderon
Copy link

I am really looking forward to this feature. Any progress on this?

@alexcrichton
Copy link
Member

I think this should be good to go with comments addressed and a rebase, but @ebkalderon if you'd like to spearhead that feel free!

@JanLikar
Copy link
Contributor

I'm working on this.

JanLikar added a commit to JanLikar/cargo that referenced this pull request Jan 28, 2016
Fix rust-lang#1570 based on commits from PR rust-lang#2056 by @tsurai to master
@JanLikar JanLikar mentioned this pull request Jan 28, 2016
@alexcrichton
Copy link
Member

Closing in favor of the rebase over at #2325, but thanks for the PR regardless @tsurai!

branan pushed a commit to branan/cargo that referenced this pull request Apr 11, 2016
Fix rust-lang#1570 based on commits from PR rust-lang#2056 by @tsurai to master
jbendig added a commit to jbendig/cargo that referenced this pull request Feb 8, 2017
bors added a commit that referenced this pull request Feb 10, 2017
Added required_features for issue #1570.

Based on PR #2056 by @tsurai and PR #2325 by @JanLikar

I tried to fix most everything that was talked about in the previous pull requests. Docs still need to be updated though.
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

Successfully merging this pull request may close these issues.

7 participants