diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 2a695206b5..eafbfe021a 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -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), diff --git a/docs/Formula-Cookbook.md b/docs/Formula-Cookbook.md index a8a8004c4a..7451e5312e 100644 --- a/docs/Formula-Cookbook.md +++ b/docs/Formula-Cookbook.md @@ -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"` You’ll see stuff like this in some formulae. This moves the file `foo` into the formula’s `bin` directory (`/opt/homebrew/Cellar/pkg/0.1/bin`) and makes it executable (`chmod 0555 foo`).