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

cargo metadata and --no-default-features #200

Closed
jadamcrain opened this issue Aug 8, 2022 · 2 comments
Closed

cargo metadata and --no-default-features #200

jadamcrain opened this issue Aug 8, 2022 · 2 comments

Comments

@jadamcrain
Copy link

I have the following workspace:

https://github.com/stepfunc/rodbus

The main crate rodbus has default features serial and tls.

Workspace projects rodbus-ffi and rodbus-ffi-java have features that just activate the corresponding dependency features, e.g., in rodbus-ffi Cargo.toml:

[features]
default = ["serial", "tls"]
serial = ["rodbus/serial"]
tls = ["rodbus/tls"]

I cannot for the life of me figure out how to produce metadata that properly excludes the default features. I want to be able to use cargo metadata to produce a custom SBOM under different feature configurations, but I seem to always get all the dependencies even with the --no-default-features flag.

Any tips for debugging this?

@jadamcrain jadamcrain changed the title cargo metadata and --no-deafult-features cargo metadata and --no-default-features Aug 8, 2022
@ehuss
Copy link
Contributor

ehuss commented Aug 8, 2022

cargo metadata is currently only capable of resolving a workspace as a whole. That means all workspace members participate in resolving the features. In your workspace, rodbus-bindings enables the default features of rodbus-ffi. Setting default-features=false for that dependency can remove it.
rust-lang/cargo#7754 is tracking this limitation.

@jadamcrain
Copy link
Author

Extremely helpful, ty.

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