Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

formula: change some private API to public API #18582

Merged
merged 2 commits into from
Nov 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 34 additions & 4 deletions Library/Homebrew/formula.rb
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,8 @@ def latest_version_installed?
end

# If at least one version of {Formula} is installed.
#
# @api public
sig { returns(T::Boolean) }
def any_version_installed?
installed_prefixes.any? { |keg| (keg/AbstractTab::FILENAME).file? }
Expand Down Expand Up @@ -1783,6 +1785,8 @@ def inspect
end

# Standard parameters for cabal-v2 builds.
#
# @api public
sig { returns(T::Array[String]) }
def std_cabal_v2_args
# cabal-install's dependency-resolution backtracking strategy can
Expand All @@ -1795,6 +1799,8 @@ def std_cabal_v2_args
end

# Standard parameters for cargo builds.
#
# @api public
sig {
params(root: T.any(String, Pathname), path: T.any(String, Pathname)).returns(T::Array[String])
}
Expand All @@ -1807,6 +1813,8 @@ def std_cargo_args(root: prefix, path: ".")
# Setting `CMAKE_FIND_FRAMEWORK` to "LAST" tells CMake to search for our
# libraries before trying to utilize Frameworks, many of which will be from
# 3rd party installs.
#
# @api public
sig {
params(
install_prefix: T.any(String, Pathname),
Expand All @@ -1828,6 +1836,8 @@ def std_cmake_args(install_prefix: prefix, install_libdir: "lib", find_framework
end

# Standard parameters for configure builds.
#
# @api public
sig {
params(
prefix: T.any(String, Pathname),
Expand All @@ -1840,6 +1850,8 @@ def std_configure_args(prefix: self.prefix, libdir: "lib")
end

# Standard parameters for Go builds.
#
# @api public
sig {
params(
output: T.any(String, Pathname),
Expand All @@ -1855,12 +1867,16 @@ def std_go_args(output: bin/name, ldflags: nil, gcflags: nil)
end

# Standard parameters for meson builds.
#
# @api public
sig { returns(T::Array[String]) }
def std_meson_args
["--prefix=#{prefix}", "--libdir=#{lib}", "--buildtype=release", "--wrap-mode=nofallback"]
end

# Standard parameters for npm builds.
#
# @api public
sig { params(prefix: T.any(String, Pathname, FalseClass)).returns(T::Array[String]) }
def std_npm_args(prefix: libexec)
require "language/node"
Expand All @@ -1871,6 +1887,8 @@ def std_npm_args(prefix: libexec)
end

# Standard parameters for pip builds.
#
# @api public
sig {
params(prefix: T.any(String, Pathname, FalseClass),
build_isolation: T::Boolean).returns(T::Array[String])
Expand All @@ -1897,6 +1915,8 @@ def std_pip_args(prefix: self.prefix, build_isolation: false)
# shared_library("foo", "*") #=> foo.2.dylib, foo.1.dylib, foo.dylib
# shared_library("*") #=> foo.dylib, bar.dylib
# ```
#
# @api public
sig { params(name: String, version: T.nilable(T.any(String, Integer))).returns(String) }
def shared_library(name, version = nil)
return "*.dylib" if name == "*" && (version.blank? || version == "*")
Expand All @@ -1921,6 +1941,8 @@ def shared_library(name, version = nil)
# rpath(target: frameworks) #=> "@loader_path/../Frameworks"
# rpath(source: libexec/"bin") #=> "@loader_path/../../lib"
# ```
#
# @api public
sig { params(source: Pathname, target: Pathname).returns(String) }
def rpath(source: bin, target: lib)
unless target.to_s.start_with?(HOMEBREW_PREFIX)
Expand All @@ -1930,6 +1952,9 @@ def rpath(source: bin, target: lib)
"#{loader_path}/#{target.relative_path_from(source)}"
end

# Linker variable for the directory containing the program or shared object.
#
# @api public
sig { returns(String) }
def loader_path
"@loader_path"
Expand All @@ -1951,6 +1976,8 @@ def time
#
# If called with no parameters, does this with all compatible
# universal binaries in a {Formula}'s {Keg}.
#
# @api public
sig { params(targets: T.nilable(T.any(Pathname, String))).void }
def deuniversalize_machos(*targets)
if targets.none?
Expand Down Expand Up @@ -2057,13 +2084,14 @@ def extract_macho_slice_from(file, arch = Hardware::CPU.arch)
# "completions", "--selected-shell=bash")
# ```
#
# @param commands [Pathname, String]
# @api public
# @param commands
# the path to the executable and any passed subcommand(s) to use for generating the completion scripts.
# @param base_name [String]
# @param base_name
# the base name of the generated completion script. Defaults to the formula name.
# @param shells [Array<Symbol>]
# @param shells
# the shells to generate completion scripts for. Defaults to `[:bash, :zsh, :fish]`.
# @param shell_parameter_format [String, Symbol]
# @param shell_parameter_format
# specify how `shells` should each be passed to the `executable`. Takes either a String representing a
# prefix, or one of `[:flag, :arg, :none, :click]`. Defaults to plainly passing the shell.
sig {
Expand Down Expand Up @@ -2982,6 +3010,8 @@ def undeclared_runtime_dependencies
# ```ruby
# system "make", "install"
# ```
#
# @api public
sig { params(cmd: T.any(String, Pathname), args: T.any(String, Integer, Pathname, Symbol)).void }
def system(cmd, *args)
verbose_using_dots = Homebrew::EnvConfig.verbose_using_dots?
Expand Down
Loading