Merge pull request #19420 from botantony/std_args

docs: add a bit more information about `std_*_args` to Formula Cookbook
This commit is contained in:
Patrick Linnane 2025-03-04 19:24:36 +00:00 committed by GitHub
commit d760e40919
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 1 deletions

View File

@ -1865,6 +1865,9 @@ class Formula
# Standard parameters for zig builds.
#
# `release_mode` can be set to either `:safe`, `:fast`, or `:small`
# with `:fast` being the default value
#
# @api public
sig {
params(prefix: T.any(String, Pathname),

View File

@ -460,7 +460,7 @@ end
### Standard arguments
For any formula using certain well-known build systems, there will be arguments that should be passed during compilation so that the build conforms to Homebrew standards. These have been collected into a set of `std_*_args` methods.
For any formula using certain well-known build systems, there will be arguments that should be passed during compilation so that the build conforms to Homebrew standards. These have been collected into a set of `std_*_args` methods. Detailed information about each of those methods can be found in [Rubydoc](https://rubydoc.brew.sh/Formula).
Most of these methods accept parameters to customize their output. For example, to set the install prefix to [**`libexec`**](#variables-for-directory-locations) for `configure` or `cmake`:
@ -517,6 +517,8 @@ The `std_*_args` methods, as well as the arguments they pass, are:
"-o=#{output}"
```
It also provides a convenient way to set `-ldflags` and `-gcflags`, see examples: [`babelfish`](https://github.com/Homebrew/homebrew-core/blob/master/Formula/b/babelfish.rb) and [`wazero`](https://github.com/Homebrew/homebrew-core/blob/master/Formula/w/wazero.rb) formulae.
#### `std_meson_args`
```ruby
@ -546,6 +548,19 @@ The `std_*_args` methods, as well as the arguments they pass, are:
"--no-compile"
```
#### `std_zig_args`
```ruby
"--prefix"
prefix
"--release=#{release_mode}"
"-Doptimize=Release#{release_mode}"
"--summary"
"all"
```
`release_mode` is a symbol that accepts only `:fast`, `:safe`, and `:small` values (with `:fast` being default).
### `bin.install "foo"`
Youll see stuff like this in some formulae. This moves the file `foo` into the formulas `bin` directory (`/opt/homebrew/Cellar/pkg/0.1/bin`) and makes it executable (`chmod 0555 foo`).