formula: add std_zig_args

This commit is contained in:
botantony 2025-02-21 14:53:34 +01:00
parent 9bc0ef0dca
commit 21714d63a4
No known key found for this signature in database
GPG Key ID: 7FE721557EA6AAD6
2 changed files with 17 additions and 0 deletions

View File

@ -1946,6 +1946,17 @@ class Formula
args args
end end
# Standard parameters for zig builds.
#
# @api public
sig {
params(prefix: T.any(String, Pathname),
release_mode: String).returns(T::Array[String])
}
def std_zig_args(prefix: self.prefix, release_mode: "fast")
["--prefix", prefix.to_s, "--release=#{release_mode}", "--summary", "all"]
end
# Shared library names according to platform conventions. # Shared library names according to platform conventions.
# #
# Optionally specify a `version` to restrict the shared library to a specific # Optionally specify a `version` to restrict the shared library to a specific
@ -3029,6 +3040,8 @@ class Formula
pretty_args -= std_go_args pretty_args -= std_go_args
when "meson" when "meson"
pretty_args -= std_meson_args pretty_args -= std_meson_args
when "zig"
pretty_args -= std_zig_args
when %r{(^|/)(pip|python)(?:[23](?:\.\d{1,2})?)?$} when %r{(^|/)(pip|python)(?:[23](?:\.\d{1,2})?)?$}
pretty_args -= std_pip_args pretty_args -= std_pip_args
end end

View File

@ -151,6 +151,8 @@ module Homebrew
uses_from_macos "ruby" uses_from_macos "ruby"
<% elsif @mode == :rust %> <% elsif @mode == :rust %>
depends_on "rust" => :build depends_on "rust" => :build
<% elsif @mode == :zig %>
depends_on "zig" => :build
<% elsif @mode.nil? %> <% elsif @mode.nil? %>
# depends_on "cmake" => :build # depends_on "cmake" => :build
<% end %> <% end %>
@ -217,6 +219,8 @@ module Homebrew
bin.env_script_all_files(libexec/"bin", GEM_HOME: ENV["GEM_HOME"]) bin.env_script_all_files(libexec/"bin", GEM_HOME: ENV["GEM_HOME"])
<% elsif @mode == :rust %> <% elsif @mode == :rust %>
system "cargo", "install", *std_cargo_args system "cargo", "install", *std_cargo_args
<% elsif @mode == :zig %>
system "zig", "build", *std_zig_args
<% else %> <% else %>
# Remove unrecognized options if they cause configure to fail # Remove unrecognized options if they cause configure to fail
# https://rubydoc.brew.sh/Formula.html#std_configure_args-instance_method # https://rubydoc.brew.sh/Formula.html#std_configure_args-instance_method