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 --all-features flag to cargo #3038

Merged
merged 1 commit into from
Aug 31, 2016
Merged

Add --all-features flag to cargo #3038

merged 1 commit into from
Aug 31, 2016

Conversation

esclear
Copy link
Contributor

@esclear esclear commented Aug 24, 2016

As (more or less) requested in #1173 I added a --all-features flag to cargo that builds all available features.

I hope I documented it in all the right places.

If there's something weird or wrong, please give me a heads up.

@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 @alexcrichton (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. Due to 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.

@alexcrichton
Copy link
Member

Thanks for the PR @esclear! Looking pretty good to me, but the println! may want to get converted into actually enabling all features? Can you also be sure to add some tests for this functionality as well?

cc @rust-lang/tools, a new flag to cargo

@esclear
Copy link
Contributor Author

esclear commented Aug 26, 2016

Well…
It does enable all featues, since it overwrites the features vec.
But you're right, one wouldn't want to see this kind of debugging information 😳.

I'll try to think of some test and get back to this PR.

@esclear
Copy link
Contributor Author

esclear commented Aug 26, 2016

@alexcrichton Removed the println! and added a simple test.

@brson
Copy link
Contributor

brson commented Aug 29, 2016

Seems reasonable to me given the current design of features. It might be worth considering how this plays out with any future changes to cargo features. For example, some features may be mutually-incompatible. Cargo has no way to encode that today, but maybe not forever.

@sfackler
Copy link
Member

This shouldn't impact this PR from landing, but here's one example of me forcing incompatible traits to help ease a rename (of e.g. feature openssl to feature with-openssl): https://github.com/sfackler/rust-postgres/blob/breaks/src/feature_check.rs

@esclear
Copy link
Contributor Author

esclear commented Aug 29, 2016

Given that exclusive features are already being discussed in #2980 this should be considered.

My main intent behind this flag was to simplify enabling all features while building crate documentation or testing.
I think in that case you'd still want all features to be built.

On the other hand, there might be problems when testing with exclusive features enabled.

In my opinion, the user would have to enable all of the needed features manually if there are any exclusive features.
In case one uses the --all-features flag when building a crate with exclusive features, cargo should warn the user and stop.

@alexcrichton
Copy link
Member

Looking good! I think though that this'll also need to enable any optional dependencies as well as [feature]-style features. Perhaps this could look into using Method::Everything as that should enable all features by default as well?

@alexcrichton
Copy link
Member

Could you also add a test for an optional dependency getting activated as well?

@alexcrichton
Copy link
Member

(other than that though looks good to me)

@alexcrichton alexcrichton added the relnotes Release-note worthy label Aug 31, 2016

[features]
foo = []
bar = ["baz"]
Copy link
Member

Choose a reason for hiding this comment

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

This dependency on "baz" may want to be removed because otherwise activating bar is the same as activating baz (e.g. --all-features should activate optional dependencies that aren't listed in [features])

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, now I get what you meant by that.

@alexcrichton
Copy link
Member

Thanks! Could you squash the commits down as well?

@esclear
Copy link
Contributor Author

esclear commented Aug 31, 2016

I'll try, even though I merged multiple times now.

@esclear esclear reopened this Aug 31, 2016
@esclear
Copy link
Contributor Author

esclear commented Aug 31, 2016

After some manual rebasing it should be fine now.


[features]
foo = []
bar = []
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed baz from the feature dependencies of bar.

@alexcrichton
Copy link
Member

@bors: r+ 1f8b398

Thanks!

bors added a commit that referenced this pull request Aug 31, 2016
Add --all-features flag to cargo

As (more or less) requested in #1173 I added a `--all-features` flag to cargo that builds all available features.

I hope I documented it in all the right places.

If there's something weird or wrong, please give me a heads up.
@bors
Copy link
Collaborator

bors commented Aug 31, 2016

⌛ Testing commit 1f8b398 with merge e713e7f...

@bors
Copy link
Collaborator

bors commented Aug 31, 2016

☀️ Test successful - cargo-cross-linux, cargo-linux-32, cargo-linux-64, cargo-mac-32, cargo-mac-64, cargo-win-gnu-32, cargo-win-gnu-64, cargo-win-msvc-32, cargo-win-msvc-64
Approved by: alexcrichton
Pushing e713e7f to master...

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

Successfully merging this pull request may close these issues.

6 participants