Skip to content

cargo enable features when building binary #10889

@NobodyXu

Description

@NobodyXu

Problem

Use case: bindgen requires feature clap to be enabled when building binaries, however if we put that feature into default feature set, then the entire ecosystem needs to pay the price for building clap even if most of them use bindgen as a build dependency and does not need clap.

rust-lang/rust-bindgen#2238

This unfortunate situation is caused by lack of mechanism to enable features when building binary.

Proposed Solution

Provides a mechanism to enable features when building binaries.

E.g. a new feature set called "default-binary" that enables specified features when building binaries.
Or we can enable all the required-features of [[bin]].

Notes

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions