Formula-Cookbook: add std_*_args explanations
Signed-off-by: Patrick Linnane <patrick@linnane.io>
This commit is contained in:
parent
321498c327
commit
7b8d0e6b7f
@ -1773,16 +1773,16 @@ class Formula
|
|||||||
"#<Formula #{name} (#{active_spec_sym}) #{path}>"
|
"#<Formula #{name} (#{active_spec_sym}) #{path}>"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Standard parameters for configure builds.
|
# Standard parameters for cabal-v2 builds.
|
||||||
sig {
|
sig { returns(T::Array[String]) }
|
||||||
params(
|
def std_cabal_v2_args
|
||||||
prefix: T.any(String, Pathname),
|
# cabal-install's dependency-resolution backtracking strategy can
|
||||||
libdir: T.any(String, Pathname),
|
# easily need more than the default 2,000 maximum number of
|
||||||
).returns(T::Array[String])
|
# "backjumps," since Hackage is a fast-moving, rolling-release
|
||||||
}
|
# target. The highest known needed value by a formula was 43,478
|
||||||
def std_configure_args(prefix: self.prefix, libdir: "lib")
|
# for git-annex, so 100,000 should be enough to avoid most
|
||||||
libdir = Pathname(libdir).expand_path(prefix)
|
# gratuitous backjumps build failures.
|
||||||
["--disable-debug", "--disable-dependency-tracking", "--prefix=#{prefix}", "--libdir=#{libdir}"]
|
["--jobs=#{ENV.make_jobs}", "--max-backjumps=100000", "--install-method=copy", "--installdir=#{bin}"]
|
||||||
end
|
end
|
||||||
|
|
||||||
# Standard parameters for cargo builds.
|
# Standard parameters for cargo builds.
|
||||||
@ -1819,6 +1819,18 @@ class Formula
|
|||||||
end
|
end
|
||||||
alias generic_std_cmake_args std_cmake_args
|
alias generic_std_cmake_args std_cmake_args
|
||||||
|
|
||||||
|
# Standard parameters for configure builds.
|
||||||
|
sig {
|
||||||
|
params(
|
||||||
|
prefix: T.any(String, Pathname),
|
||||||
|
libdir: T.any(String, Pathname),
|
||||||
|
).returns(T::Array[String])
|
||||||
|
}
|
||||||
|
def std_configure_args(prefix: self.prefix, libdir: "lib")
|
||||||
|
libdir = Pathname(libdir).expand_path(prefix)
|
||||||
|
["--disable-debug", "--disable-dependency-tracking", "--prefix=#{prefix}", "--libdir=#{libdir}"]
|
||||||
|
end
|
||||||
|
|
||||||
# Standard parameters for Go builds.
|
# Standard parameters for Go builds.
|
||||||
sig {
|
sig {
|
||||||
params(output: T.any(String, Pathname),
|
params(output: T.any(String, Pathname),
|
||||||
@ -1830,18 +1842,6 @@ class Formula
|
|||||||
args
|
args
|
||||||
end
|
end
|
||||||
|
|
||||||
# Standard parameters for cabal-v2 builds.
|
|
||||||
sig { returns(T::Array[String]) }
|
|
||||||
def std_cabal_v2_args
|
|
||||||
# cabal-install's dependency-resolution backtracking strategy can
|
|
||||||
# easily need more than the default 2,000 maximum number of
|
|
||||||
# "backjumps," since Hackage is a fast-moving, rolling-release
|
|
||||||
# target. The highest known needed value by a formula was 43,478
|
|
||||||
# for git-annex, so 100,000 should be enough to avoid most
|
|
||||||
# gratuitous backjumps build failures.
|
|
||||||
["--jobs=#{ENV.make_jobs}", "--max-backjumps=100000", "--install-method=copy", "--installdir=#{bin}"]
|
|
||||||
end
|
|
||||||
|
|
||||||
# Standard parameters for meson builds.
|
# Standard parameters for meson builds.
|
||||||
sig { returns(T::Array[String]) }
|
sig { returns(T::Array[String]) }
|
||||||
def std_meson_args
|
def std_meson_args
|
||||||
|
|||||||
@ -448,7 +448,7 @@ end
|
|||||||
|
|
||||||
### Standard arguments
|
### 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.
|
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.
|
||||||
|
|
||||||
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`:
|
||||||
|
|
||||||
@ -457,6 +457,73 @@ system "./configure", *std_configure_args(prefix: libexec)
|
|||||||
system "cmake", "-S", ".", "-B", "build", *std_cmake_args(install_prefix: libexec)
|
system "cmake", "-S", ".", "-B", "build", *std_cmake_args(install_prefix: libexec)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
The `std_*_args` methods, as well as the arguments they pass, are:
|
||||||
|
|
||||||
|
#### `std_cabal_v2_args`
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
"--jobs=#{ENV.make_jobs}"
|
||||||
|
"--max-backjumps=100000"
|
||||||
|
"--install-method=copy"
|
||||||
|
"--installdir=#{bin}"
|
||||||
|
```
|
||||||
|
|
||||||
|
#### `std_cargo_args`
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
"--locked"
|
||||||
|
"--root=#{root}"
|
||||||
|
"--path=#{path}"
|
||||||
|
```
|
||||||
|
|
||||||
|
#### `std_cmake_args`
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
"-DCMAKE_INSTALL_PREFIX=#{install_prefix}"
|
||||||
|
"-DCMAKE_INSTALL_LIBDIR=#{install_libdir}"
|
||||||
|
"-DCMAKE_BUILD_TYPE=Release"
|
||||||
|
"-DCMAKE_FIND_FRAMEWORK=#{find_framework}"
|
||||||
|
"-DCMAKE_VERBOSE_MAKEFILE=ON"
|
||||||
|
"-DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=#{HOMEBREW_LIBRARY_PATH}/cmake/trap_fetchcontent_provider.cmake"
|
||||||
|
"-Wno-dev"
|
||||||
|
"-DBUILD_TESTING=OFF"
|
||||||
|
```
|
||||||
|
|
||||||
|
#### `std_configure_args`
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
"--disable-debug"
|
||||||
|
"--disable-dependency-tracking"
|
||||||
|
"--prefix=#{prefix}"
|
||||||
|
"--libdir=#{libdir}"
|
||||||
|
```
|
||||||
|
|
||||||
|
#### `std_go_args`
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
"-trimpath"
|
||||||
|
"-o=#{output}"
|
||||||
|
```
|
||||||
|
|
||||||
|
#### `std_meson_args`
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
"--prefix=#{prefix}"
|
||||||
|
"--libdir=#{lib}"
|
||||||
|
"--buildtype=release"
|
||||||
|
"--wrap-mode=nofallback"
|
||||||
|
```
|
||||||
|
|
||||||
|
#### `std_pip_args`
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
"--verbose"
|
||||||
|
"--no-deps"
|
||||||
|
"--no-binary=:all:"
|
||||||
|
"--ignore-installed"
|
||||||
|
"--no-compile"
|
||||||
|
```
|
||||||
|
|
||||||
### `bin.install "foo"`
|
### `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`).
|
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`).
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user