Merge pull request #19346 from botantony/zig-args
Zig template and std args
This commit is contained in:
commit
db657725b5
@ -40,6 +40,8 @@ module Homebrew
|
|||||||
description: "Create a basic template for a Ruby build."
|
description: "Create a basic template for a Ruby build."
|
||||||
switch "--rust",
|
switch "--rust",
|
||||||
description: "Create a basic template for a Rust build."
|
description: "Create a basic template for a Rust build."
|
||||||
|
switch "--zig",
|
||||||
|
description: "Create a basic template for a Zig build."
|
||||||
switch "--no-fetch",
|
switch "--no-fetch",
|
||||||
description: "Homebrew will not download <URL> to the cache and will thus not add its SHA-256 " \
|
description: "Homebrew will not download <URL> to the cache and will thus not add its SHA-256 " \
|
||||||
"to the formula for you, nor will it check the GitHub API for GitHub projects " \
|
"to the formula for you, nor will it check the GitHub API for GitHub projects " \
|
||||||
@ -58,7 +60,7 @@ module Homebrew
|
|||||||
description: "Ignore errors for disallowed formula names and names that shadow aliases."
|
description: "Ignore errors for disallowed formula names and names that shadow aliases."
|
||||||
|
|
||||||
conflicts "--autotools", "--cmake", "--crystal", "--go", "--meson", "--node",
|
conflicts "--autotools", "--cmake", "--crystal", "--go", "--meson", "--node",
|
||||||
"--perl", "--python", "--ruby", "--rust", "--cask"
|
"--perl", "--python", "--ruby", "--rust", "--zig", "--cask"
|
||||||
conflicts "--cask", "--HEAD"
|
conflicts "--cask", "--HEAD"
|
||||||
conflicts "--cask", "--set-license"
|
conflicts "--cask", "--set-license"
|
||||||
|
|
||||||
@ -173,6 +175,8 @@ module Homebrew
|
|||||||
:ruby
|
:ruby
|
||||||
elsif args.rust?
|
elsif args.rust?
|
||||||
:rust
|
:rust
|
||||||
|
elsif args.zig?
|
||||||
|
:zig
|
||||||
end
|
end
|
||||||
|
|
||||||
fc = FormulaCreator.new(
|
fc = FormulaCreator.new(
|
||||||
|
|||||||
@ -32,6 +32,18 @@ module OS
|
|||||||
|
|
||||||
args
|
args
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig {
|
||||||
|
params(
|
||||||
|
prefix: T.any(String, Pathname),
|
||||||
|
release_mode: Symbol,
|
||||||
|
).returns(T::Array[String])
|
||||||
|
}
|
||||||
|
def std_zig_args(prefix: self.prefix, release_mode: :fast)
|
||||||
|
args = super
|
||||||
|
args << "-fno-rosetta" if ::Hardware::CPU.arm?
|
||||||
|
args
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1946,6 +1946,26 @@ class Formula
|
|||||||
args
|
args
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Standard parameters for zig builds.
|
||||||
|
#
|
||||||
|
# @api public
|
||||||
|
sig {
|
||||||
|
params(prefix: T.any(String, Pathname),
|
||||||
|
release_mode: Symbol).returns(T::Array[String])
|
||||||
|
}
|
||||||
|
def std_zig_args(prefix: self.prefix, release_mode: :fast)
|
||||||
|
raise ArgumentError, "Invalid Zig release mode: #{release_mode}" if [:safe, :fast, :small].exclude?(release_mode)
|
||||||
|
|
||||||
|
release_mode_downcased = release_mode.to_s.downcase
|
||||||
|
release_mode_capitalized = release_mode.to_s.capitalize
|
||||||
|
[
|
||||||
|
"--prefix", prefix.to_s,
|
||||||
|
"--release=#{release_mode_downcased}",
|
||||||
|
"-Doptimize=Release#{release_mode_capitalized}",
|
||||||
|
"--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 +3049,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
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
@ -56,6 +56,9 @@ class Homebrew::DevCmd::Create::Args < Homebrew::CLI::Args
|
|||||||
sig { returns(T::Boolean) }
|
sig { returns(T::Boolean) }
|
||||||
def rust?; end
|
def rust?; end
|
||||||
|
|
||||||
|
sig { returns(T::Boolean) }
|
||||||
|
def zig?; end
|
||||||
|
|
||||||
sig { returns(T.nilable(String)) }
|
sig { returns(T.nilable(String)) }
|
||||||
def set_license; end
|
def set_license; end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user