Skip to content

Remove alias generic_* definitions in favour of using super #20120

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

Merged
merged 1 commit into from
Jun 16, 2025
Merged
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion Library/Homebrew/api/analytics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ class << self
def analytics_api_path
"analytics"
end
alias generic_analytics_api_path analytics_api_path

sig { params(category: String, days: T.any(Integer, String)).returns(T::Hash[String, T.untyped]) }
def fetch(category, days)
Expand Down
1 change: 1 addition & 0 deletions Library/Homebrew/dev-cmd/update-test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ def run

private

sig { returns(String) }
def git_tags
tags = Utils.popen_read("git", "tag", "--list", "--sort=-version:refname")
if tags.blank?
Expand Down
1 change: 0 additions & 1 deletion Library/Homebrew/diagnostic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,6 @@ def check_tmpdir_sticky_bit
sudo chmod +t #{HOMEBREW_TEMP}
EOS
end
alias generic_check_tmpdir_sticky_bit check_tmpdir_sticky_bit

def check_exist_directories
return if HOMEBREW_PREFIX.writable?
Expand Down
2 changes: 0 additions & 2 deletions Library/Homebrew/extend/ENV/shared.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ def setup_build_environment(formula: nil, cc: nil, build_bottle: false, bottle_a
@debug_symbols = debug_symbols
reset
end
alias generic_shared_setup_build_environment setup_build_environment
private :generic_shared_setup_build_environment

sig { void }
def reset
Expand Down
1 change: 0 additions & 1 deletion Library/Homebrew/extend/ENV/std.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ def setup_build_environment(formula: nil, cc: nil, build_bottle: false, bottle_a
gcc_formula = gcc_version_formula(cc)
append_path "PATH", gcc_formula.opt_bin.to_s
end
alias generic_setup_build_environment setup_build_environment

sig { returns(T.nilable(PATH)) }
def determine_pkg_config_libdir
Expand Down
4 changes: 1 addition & 3 deletions Library/Homebrew/extend/ENV/super.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ def setup_build_environment(formula: nil, cc: nil, build_bottle: false, bottle_a
# These flags will also be present:
# a - apply fix for apr-1-config path
end
alias generic_setup_build_environment setup_build_environment

private

Expand All @@ -152,7 +151,6 @@ def homebrew_extra_paths
.reverse
.map { |d| d.opt_libexec/"bin" }
end
alias generic_homebrew_extra_paths homebrew_extra_paths

sig { returns(T.nilable(PATH)) }
def determine_path
Expand Down Expand Up @@ -372,8 +370,8 @@ def refurbish_args
append_to_cccfg "O"
end

# This is an exception where we want to use this method name format.
# rubocop: disable Naming/MethodName
# Fixes style error `Naming/MethodName: Use snake_case for method names.`
sig { params(block: T.nilable(T.proc.void)).void }
def O0(&block)
if block
Expand Down
22 changes: 11 additions & 11 deletions Library/Homebrew/extend/os/linux/dev-cmd/update-test.rb
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# typed: strict
# frozen_string_literal: true

module Homebrew
module DevCmd
class UpdateTest < AbstractCommand
alias generic_git_tags git_tags
module OS
module Linux
module DevCmd
module UpdateTest
private

private

sig { returns(String) }
def git_tags
tags = generic_git_tags
tags = Utils.popen_read("git tag --list | sort -rV") if tags.blank?
tags
sig { returns(String) }
def git_tags
super.presence || Utils.popen_read("git tag --list | sort -rV")

Check warning on line 12 in Library/Homebrew/extend/os/linux/dev-cmd/update-test.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/extend/os/linux/dev-cmd/update-test.rb#L12

Added line #L12 was not covered by tests
end
end
end
end
end

Homebrew::DevCmd::UpdateTest.prepend(OS::Linux::DevCmd::UpdateTest)
2 changes: 1 addition & 1 deletion Library/Homebrew/extend/os/linux/development_tools.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def needs_compiler_formula?
def build_system_info
super.merge({
"glibc_version" => OS::Linux::Glibc.version.to_s.presence,
"oldest_cpu_family" => Hardware.oldest_cpu.to_s,
"oldest_cpu_family" => ::Hardware.oldest_cpu.to_s,
})
end
end
Expand Down
8 changes: 4 additions & 4 deletions Library/Homebrew/extend/os/linux/diagnostic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
end

def check_tmpdir_sticky_bit
message = generic_check_tmpdir_sticky_bit
message = super

Check warning on line 35 in Library/Homebrew/extend/os/linux/diagnostic.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/extend/os/linux/diagnostic.rb#L35

Added line #L35 was not covered by tests
return if message.nil?

message + <<~EOS
Expand Down Expand Up @@ -74,11 +74,11 @@
end

def check_supported_architecture
return if Hardware::CPU.intel?
return if Homebrew::EnvConfig.developer? && ENV["HOMEBREW_ARM64_TESTING"].present? && Hardware::CPU.arm?
return if ::Hardware::CPU.intel?
return if Homebrew::EnvConfig.developer? && ENV["HOMEBREW_ARM64_TESTING"].present? && ::Hardware::CPU.arm?

<<~EOS
Your CPU architecture (#{Hardware::CPU.arch}) is not supported. We only support
Your CPU architecture (#{::Hardware::CPU.arch}) is not supported. We only support
x86_64 CPU architectures. You will be unable to use binary packages (bottles).

#{support_tier_message(tier: 2)}
Expand Down
26 changes: 16 additions & 10 deletions Library/Homebrew/extend/os/linux/extend/ENV/shared.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

module SharedEnvExtension
def effective_arch
if @build_bottle && @bottle_arch
@bottle_arch.to_sym
elsif @build_bottle
Hardware.oldest_cpu
elsif Hardware::CPU.intel? || Hardware::CPU.arm?
:native
else
:dunno
module OS
module Linux
module SharedEnvExtension
def effective_arch
if @build_bottle && @bottle_arch
@bottle_arch.to_sym
elsif @build_bottle
::Hardware.oldest_cpu
elsif ::Hardware::CPU.intel? || ::Hardware::CPU.arm?
:native
else
:dunno
end
end
end
end
end

SharedEnvExtension.prepend(OS::Linux::SharedEnvExtension)
69 changes: 39 additions & 30 deletions Library/Homebrew/extend/os/linux/extend/ENV/std.rb
Original file line number Diff line number Diff line change
@@ -1,36 +1,45 @@
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

module Stdenv
sig {
params(
formula: T.nilable(Formula),
cc: T.nilable(String),
build_bottle: T.nilable(T::Boolean),
bottle_arch: T.nilable(String),
testing_formula: T::Boolean,
debug_symbols: T.nilable(T::Boolean),
).void
}
def setup_build_environment(formula: nil, cc: nil, build_bottle: false, bottle_arch: nil, testing_formula: false,
debug_symbols: false)
generic_setup_build_environment(formula:, cc:, build_bottle:, bottle_arch:,
testing_formula:, debug_symbols:)

prepend_path "CPATH", HOMEBREW_PREFIX/"include"
prepend_path "LIBRARY_PATH", HOMEBREW_PREFIX/"lib"
prepend_path "LD_RUN_PATH", HOMEBREW_PREFIX/"lib"

return unless @formula

prepend_path "CPATH", @formula.include
prepend_path "LIBRARY_PATH", @formula.lib
prepend_path "LD_RUN_PATH", @formula.lib
end
module OS
module Linux
module Stdenv
extend T::Helpers

requires_ancestor { ::SharedEnvExtension }

sig {
params(

Check warning on line 12 in Library/Homebrew/extend/os/linux/extend/ENV/std.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/extend/os/linux/extend/ENV/std.rb#L12

Added line #L12 was not covered by tests
formula: T.nilable(::Formula),
cc: T.nilable(String),
build_bottle: T.nilable(T::Boolean),
bottle_arch: T.nilable(String),
testing_formula: T::Boolean,
debug_symbols: T.nilable(T::Boolean),
).void
}
def setup_build_environment(formula: nil, cc: nil, build_bottle: false, bottle_arch: nil,
testing_formula: false, debug_symbols: false)
super

Check warning on line 23 in Library/Homebrew/extend/os/linux/extend/ENV/std.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/extend/os/linux/extend/ENV/std.rb#L23

Added line #L23 was not covered by tests

prepend_path "CPATH", HOMEBREW_PREFIX/"include"
prepend_path "LIBRARY_PATH", HOMEBREW_PREFIX/"lib"
prepend_path "LD_RUN_PATH", HOMEBREW_PREFIX/"lib"

Check warning on line 27 in Library/Homebrew/extend/os/linux/extend/ENV/std.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/extend/os/linux/extend/ENV/std.rb#L25-L27

Added lines #L25 - L27 were not covered by tests

def libxml2
append "CPPFLAGS", "-I#{Formula["libxml2"].include/"libxml2"}"
rescue FormulaUnavailableError
nil
return unless @formula

prepend_path "CPATH", @formula.include
prepend_path "LIBRARY_PATH", @formula.lib
prepend_path "LD_RUN_PATH", @formula.lib

Check warning on line 33 in Library/Homebrew/extend/os/linux/extend/ENV/std.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/extend/os/linux/extend/ENV/std.rb#L31-L33

Added lines #L31 - L33 were not covered by tests
end

def libxml2
append "CPPFLAGS", "-I#{::Formula["libxml2"].include/"libxml2"}"

Check warning on line 37 in Library/Homebrew/extend/os/linux/extend/ENV/std.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/extend/os/linux/extend/ENV/std.rb#L37

Added line #L37 was not covered by tests
rescue FormulaUnavailableError
nil

Check warning on line 39 in Library/Homebrew/extend/os/linux/extend/ENV/std.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/extend/os/linux/extend/ENV/std.rb#L39

Added line #L39 was not covered by tests
end
end
end
end

Stdenv.prepend(OS::Linux::Stdenv)
146 changes: 80 additions & 66 deletions Library/Homebrew/extend/os/linux/extend/ENV/super.rb
Original file line number Diff line number Diff line change
@@ -1,79 +1,93 @@
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

module Superenv
sig { returns(Pathname) }
def self.shims_path
HOMEBREW_SHIMS_PATH/"linux/super"
end
module OS
module Linux
module Superenv
extend T::Helpers

sig { returns(T.nilable(Pathname)) }
def self.bin
shims_path.realpath
end
requires_ancestor { SharedEnvExtension }
requires_ancestor { ::Superenv }

sig {
params(
formula: T.nilable(Formula),
cc: T.nilable(String),
build_bottle: T.nilable(T::Boolean),
bottle_arch: T.nilable(String),
testing_formula: T::Boolean,
debug_symbols: T.nilable(T::Boolean),
).void
}
def setup_build_environment(formula: nil, cc: nil, build_bottle: false, bottle_arch: nil, testing_formula: false,
debug_symbols: false)
generic_setup_build_environment(formula:, cc:, build_bottle:, bottle_arch:,
testing_formula:, debug_symbols:)
self["HOMEBREW_OPTIMIZATION_LEVEL"] = "O2"
self["HOMEBREW_DYNAMIC_LINKER"] = determine_dynamic_linker_path
self["HOMEBREW_RPATH_PATHS"] = determine_rpath_paths(@formula)
m4_path_deps = ["libtool", "bison"]
self["M4"] = "#{HOMEBREW_PREFIX}/opt/m4/bin/m4" if deps.any? { m4_path_deps.include?(_1.name) }
module ClassMethods
sig { returns(Pathname) }
def shims_path
HOMEBREW_SHIMS_PATH/"linux/super"
end

# Pointer authentication and BTI are hardening techniques most distros
# use by default on their packages. arm64 Linux we're packaging
# everything from scratch so the entire dependency tree can have it.
append_to_cccfg "b" if Hardware::CPU.arch == :arm64 && DevelopmentTools.gcc_version("gcc") >= 9
end
sig { returns(T.nilable(Pathname)) }
def bin
shims_path.realpath
end
end

def homebrew_extra_paths
paths = generic_homebrew_extra_paths
paths += %w[binutils make].filter_map do |f|
bin = Formulary.factory(f).opt_bin
bin if bin.directory?
rescue FormulaUnavailableError
nil
end
paths
end
sig {
params(
formula: T.nilable(Formula),
cc: T.nilable(String),
build_bottle: T.nilable(T::Boolean),
bottle_arch: T.nilable(String),
testing_formula: T::Boolean,
debug_symbols: T.nilable(T::Boolean),
).void
}
def setup_build_environment(formula: nil, cc: nil, build_bottle: false, bottle_arch: nil,
testing_formula: false, debug_symbols: false)
super

def homebrew_extra_isystem_paths
paths = []
# Add paths for GCC headers when building against versioned glibc because we have to use -nostdinc.
if deps.any? { |d| d.name.match?(/^glibc@.+$/) }
gcc_include_dir = Utils.safe_popen_read(cc, "--print-file-name=include").chomp
gcc_include_fixed_dir = Utils.safe_popen_read(cc, "--print-file-name=include-fixed").chomp
paths << gcc_include_dir << gcc_include_fixed_dir
end
paths
end
self["HOMEBREW_OPTIMIZATION_LEVEL"] = "O2"
self["HOMEBREW_DYNAMIC_LINKER"] = determine_dynamic_linker_path
self["HOMEBREW_RPATH_PATHS"] = determine_rpath_paths(@formula)
m4_path_deps = ["libtool", "bison"]
self["M4"] = "#{HOMEBREW_PREFIX}/opt/m4/bin/m4" if deps.any? { m4_path_deps.include?(_1.name) }

def determine_rpath_paths(formula)
PATH.new(
*formula&.lib,
"#{HOMEBREW_PREFIX}/opt/gcc/lib/gcc/current",
PATH.new(run_time_deps.map { |dep| dep.opt_lib.to_s }).existing,
"#{HOMEBREW_PREFIX}/lib",
)
end
# Pointer authentication and BTI are hardening techniques most distros
# use by default on their packages. arm64 Linux we're packaging
# everything from scratch so the entire dependency tree can have it.
append_to_cccfg "b" if ::Hardware::CPU.arch == :arm64 && ::DevelopmentTools.gcc_version("gcc") >= 9
end

def homebrew_extra_paths
paths = super
paths += %w[binutils make].filter_map do |f|
bin = Formulary.factory(f).opt_bin
bin if bin.directory?
rescue FormulaUnavailableError
nil

Check warning on line 56 in Library/Homebrew/extend/os/linux/extend/ENV/super.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/extend/os/linux/extend/ENV/super.rb#L56

Added line #L56 was not covered by tests
end
paths
end

def homebrew_extra_isystem_paths
paths = []
# Add paths for GCC headers when building against versioned glibc because we have to use -nostdinc.
if deps.any? { |d| d.name.match?(/^glibc@.+$/) }
gcc_include_dir = Utils.safe_popen_read(cc, "--print-file-name=include").chomp
gcc_include_fixed_dir = Utils.safe_popen_read(cc, "--print-file-name=include-fixed").chomp
paths << gcc_include_dir << gcc_include_fixed_dir

Check warning on line 67 in Library/Homebrew/extend/os/linux/extend/ENV/super.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/extend/os/linux/extend/ENV/super.rb#L66-L67

Added lines #L66 - L67 were not covered by tests
end
paths
end

sig { returns(T.nilable(String)) }
def determine_dynamic_linker_path
path = "#{HOMEBREW_PREFIX}/lib/ld.so"
return unless File.readable? path
def determine_rpath_paths(formula)
PATH.new(
*formula&.lib,
"#{HOMEBREW_PREFIX}/opt/gcc/lib/gcc/current",
PATH.new(run_time_deps.map { |dep| dep.opt_lib.to_s }).existing,

Check warning on line 76 in Library/Homebrew/extend/os/linux/extend/ENV/super.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/extend/os/linux/extend/ENV/super.rb#L76

Added line #L76 was not covered by tests
"#{HOMEBREW_PREFIX}/lib",
)
end

path
sig { returns(T.nilable(String)) }
def determine_dynamic_linker_path
path = "#{HOMEBREW_PREFIX}/lib/ld.so"
return unless File.readable? path

path

Check warning on line 86 in Library/Homebrew/extend/os/linux/extend/ENV/super.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/extend/os/linux/extend/ENV/super.rb#L86

Added line #L86 was not covered by tests
end
end
end
end

Superenv.singleton_class.prepend(OS::Linux::Superenv::ClassMethods)
Superenv.prepend(OS::Linux::Superenv)
Loading
Loading