Skip to content

formula: add cargo features and bin options#21586

Open
daeho-ro wants to merge 1 commit intomainfrom
cargo-features
Open

formula: add cargo features and bin options#21586
daeho-ro wants to merge 1 commit intomainfrom
cargo-features

Conversation

@daeho-ro
Copy link
Member

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) with your changes locally?

Add features and bin options to std_cargo_args for cargo install.

Currently, around 60 files define features and 6 files define bin separately. By moving them into std_cargo_args, we can make more consistent cargo install usage.

Copilot AI review requested due to automatic review settings February 17, 2026 03:02
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR extends Homebrew’s Formula#std_cargo_args helper to support Cargo install feature selection and binary selection, aiming to reduce duplicated per-formula argument construction and standardize cargo install usage.

Changes:

  • Extend std_cargo_args with new features: and bin: keyword parameters.
  • Add logic to emit --all-features, --no-default-features, --features=..., and --bin=... based on the provided options.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Member

@Bo98 Bo98 left a comment

Choose a reason for hiding this comment

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

Seems ok given we have --root and --path already but the point of std_*_args isn't really to be an arg wrapper but rather be something that provides a base set of arguments that all formulae unconditionally use. Seems like this could very large very quickly if we're going to start adding conditional arguments? I'm not completely sold that *std_cargo_args(no_default_features: true) is better than *std_cargo_args, "--no-default-features".

Though there are of course exceptions: std_go_args's ldflags is an exception since you must pass multiple ldflags as a single argument (-ldflags=-a -ldflags=-b doesn't work) and we wanted to retain the ability to prepend default ldflags (e.g. to switch linkers) like we do for other languages - something that would require updating many formulae if we wanted to do later and didn't already have ldflags suppport.

@daeho-ro
Copy link
Member Author

@Bo98 If so, I’m happy to keep only the features option and revert the rest of the changes.

My original intent was to add support in std_*_args for arguments that are relatively common across many formulae. I see features as somewhat similar to tags in std_go_args.

As you pointed out, options like --all-features, --no-default-features, and --bin are not commonly used across formulae. Given that, it makes sense to exclude them from std_cargo_args and avoid expanding it with more conditional arguments than necessary.

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.

2 participants