From 09b7a7bceb1c292ac01435056b1465d46292ee67 Mon Sep 17 00:00:00 2001 From: Eric Knibbe Date: Fri, 22 Dec 2023 21:44:42 -0500 Subject: [PATCH] docs: mention standard argument methods --- docs/Formula-Cookbook.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docs/Formula-Cookbook.md b/docs/Formula-Cookbook.md index 71d3999ced995..ad39e98597c6a 100644 --- a/docs/Formula-Cookbook.md +++ b/docs/Formula-Cookbook.md @@ -435,6 +435,17 @@ if build.head? end ``` +### Standard arguments + +For any formula using a well-known build system, there'll be arguments that should be passed during compilation such that its build conforms to Homebrew standards. These have been collected into a set of `std_*_args` methods (like [`std_configure_args`](https://rubydoc.brew.sh/Formula#std_configure_args-instance_method) and [`std_cmake_args`](https://rubydoc.brew.sh/Formula#std_cmake_args-instance_method) as seen in the [output of `brew create`](#grab-the-url)) that set the build type and installation paths, plus any other applicable options. + +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`: + +```ruby +system "./configure", *std_configure_args(prefix: libexec) +system "cmake", "-S", ".", "-B", "build", *std_cmake_args(install_prefix: libexec) +``` + ### `bin.install "foo"` You’ll see stuff like this in some formulae. This moves the file `foo` into the formula’s `bin` directory (`/usr/local/Cellar/pkg/0.1/bin`) and makes it executable (`chmod 0555 foo`).