docs: add a bit more information about std_*_args to Formula Cookbook

This commit is contained in:
botantony 2025-03-04 13:04:10 +01:00
parent 9ad86c9e42
commit bf7514f328
No known key found for this signature in database
GPG Key ID: 7FE721557EA6AAD6
2 changed files with 19 additions and 1 deletions

View File

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

View File

@ -460,7 +460,7 @@ end
### Standard arguments ### 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`: 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}" "-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` #### `std_meson_args`
```ruby ```ruby
@ -546,6 +548,19 @@ The `std_*_args` methods, as well as the arguments they pass, are:
"--no-compile" "--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"` ### `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`). 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`).