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

Create feature flags for optional dependencies #307

Closed
wants to merge 1 commit into from
Closed

Create feature flags for optional dependencies #307

wants to merge 1 commit into from

Conversation

fschutt
Copy link

@fschutt fschutt commented Oct 25, 2018

If a crate depends on geo-types this makes it easier to turn off serde and spade. Since these features are enabled by default, this is not a breaking change.

Right now there is no way to actually turn off serde and spade - geo-types = { version = "0.2.0", default-features = false } still includes those dependencies. If this gets merged, it would be great if a new minor version of geo-types could be published.

If a crate depends on geo-types this makes it easier to turn off serde and spade.
Since these features are enabled by default, this is not a breaking change.
@KodrAus
Copy link

KodrAus commented Oct 25, 2018

Hi @fschutt 👋

Hmm, the serde and spade dependencies are already optional in the geo-types crate, and don't appear to be enabled by default, so unless another dependency in your graph has explicitly opted in to either of those features they shouldn't be getting pulled in.

@fschutt
Copy link
Author

fschutt commented Oct 25, 2018

Yeah, that's what should happen, but that's not what happens in reality. Try it yourself - make a new crate, put geo-types = { version = "0.2.0", default-features = false } and run cargo tree on top of it to see the dependencies. The only way to disable these features right now is to make feature flags for them. Otherwise they still get pulled in, although that technically shouldn't happen.

@KodrAus
Copy link

KodrAus commented Oct 26, 2018

There must be something else going on here, when I make a new crate with the following Cargo.toml:

[dependencies]
geo-types = { version = "0.2.0", default-features = false }

And run cargo build I don't compile serde or space, and they don't find their way into my Cargo.lock:

[[package]]
name = "geo-type-test"
version = "0.0.0"
dependencies = [
 "geo-types 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "geo-types"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
 "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "num-traits"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"

[metadata]
"checksum geo-types 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7260ac8abfc04cc21b914254b69875c2548faf6f791f88ad9ec1a131d4251729"
"checksum num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0b3a5d7cc97d6d30d8b9bc8fa19bf45349ffe46241e8816f50f62f6d6aaabee1"

@fschutt
Copy link
Author

fschutt commented Oct 26, 2018

Alright, then it's not necessary. Not sure what happened, it showed me the whole spade dependency tree when I ran it here. Now it works as expected so I'll just close this.

@fschutt fschutt closed this Oct 26, 2018
@frewsxcv
Copy link
Member

It's possible cargo tree shows all dependencies, even if they're not enabled in the current feature set

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.

3 participants