From 21714d63a42bc0933d3b423ec0e1e8b60b41cf65 Mon Sep 17 00:00:00 2001 From: botantony Date: Fri, 21 Feb 2025 14:53:34 +0100 Subject: [PATCH] formula: add std_zig_args --- Library/Homebrew/formula.rb | 13 +++++++++++++ Library/Homebrew/formula_creator.rb | 4 ++++ 2 files changed, 17 insertions(+) diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 5ebe184eff..945fc21482 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -1946,6 +1946,17 @@ class Formula args 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. # # Optionally specify a `version` to restrict the shared library to a specific @@ -3029,6 +3040,8 @@ class Formula pretty_args -= std_go_args when "meson" pretty_args -= std_meson_args + when "zig" + pretty_args -= std_zig_args when %r{(^|/)(pip|python)(?:[23](?:\.\d{1,2})?)?$} pretty_args -= std_pip_args end diff --git a/Library/Homebrew/formula_creator.rb b/Library/Homebrew/formula_creator.rb index 7aea843537..609d23e8d7 100644 --- a/Library/Homebrew/formula_creator.rb +++ b/Library/Homebrew/formula_creator.rb @@ -151,6 +151,8 @@ module Homebrew uses_from_macos "ruby" <% elsif @mode == :rust %> depends_on "rust" => :build + <% elsif @mode == :zig %> + depends_on "zig" => :build <% elsif @mode.nil? %> # depends_on "cmake" => :build <% end %> @@ -217,6 +219,8 @@ module Homebrew bin.env_script_all_files(libexec/"bin", GEM_HOME: ENV["GEM_HOME"]) <% elsif @mode == :rust %> system "cargo", "install", *std_cargo_args + <% elsif @mode == :zig %> + system "zig", "build", *std_zig_args <% else %> # Remove unrecognized options if they cause configure to fail # https://rubydoc.brew.sh/Formula.html#std_configure_args-instance_method