diff --git a/Library/Homebrew/extend/os/linux/compilers.rb b/Library/Homebrew/extend/os/linux/compilers.rb index 8965b15100..db3e1cd00e 100644 --- a/Library/Homebrew/extend/os/linux/compilers.rb +++ b/Library/Homebrew/extend/os/linux/compilers.rb @@ -1,9 +1,21 @@ # typed: strict # frozen_string_literal: true -class CompilerSelector - sig { returns(String) } - def self.preferred_gcc - OS::LINUX_PREFERRED_GCC_COMPILER_FORMULA +module OS + module Linux + module CompilerSelector + module ClassMethods + extend T::Helpers + + requires_ancestor { T.class_of(::CompilerSelector) } + + sig { returns(String) } + def preferred_gcc + OS::LINUX_PREFERRED_GCC_COMPILER_FORMULA + end + end + end end end + +CompilerSelector.singleton_class.prepend(OS::Linux::CompilerSelector::ClassMethods) diff --git a/Library/Homebrew/extend/os/linux/system_config.rb b/Library/Homebrew/extend/os/linux/system_config.rb index 90dc2de624..a9aa5213d4 100644 --- a/Library/Homebrew/extend/os/linux/system_config.rb +++ b/Library/Homebrew/extend/os/linux/system_config.rb @@ -51,7 +51,7 @@ module OS out.puts "Host glibc: #{host_glibc_version}" out.puts "#{::DevelopmentTools.host_gcc_path}: #{host_gcc_version}" out.puts "/usr/bin/ruby: #{host_ruby_version}" if RUBY_PATH != HOST_RUBY_PATH - ["glibc", CompilerSelector.preferred_gcc, OS::LINUX_PREFERRED_GCC_RUNTIME_FORMULA, "xorg"].each do |f| + ["glibc", ::CompilerSelector.preferred_gcc, OS::LINUX_PREFERRED_GCC_RUNTIME_FORMULA, "xorg"].each do |f| out.puts "#{f}: #{formula_linked_version(f)}" end end diff --git a/Library/Homebrew/extend/os/mac/language/java.rb b/Library/Homebrew/extend/os/mac/language/java.rb index 3e8192c470..d052dc9ad4 100644 --- a/Library/Homebrew/extend/os/mac/language/java.rb +++ b/Library/Homebrew/extend/os/mac/language/java.rb @@ -1,13 +1,26 @@ # typed: strict # frozen_string_literal: true -module Language - module Java - def self.java_home(version = nil) - openjdk = find_openjdk_formula(version) - return unless openjdk +module OS + module Mac + module Language + module Java + module ClassMethods + extend T::Helpers - openjdk.opt_libexec/"openjdk.jdk/Contents/Home" + requires_ancestor { T.class_of(::Language::Java) } + + sig { params(version: T.nilable(String)).returns(T.nilable(Pathname)) } + def java_home(version = nil) + openjdk = find_openjdk_formula(version) + return unless openjdk + + openjdk.opt_libexec/"openjdk.jdk/Contents/Home" + end + end + end end end end + +Language::Java.singleton_class.prepend(OS::Mac::Language::Java::ClassMethods) diff --git a/Library/Homebrew/extend/os/mac/sandbox.rb b/Library/Homebrew/extend/os/mac/sandbox.rb index 976ede4716..a352f44fa2 100644 --- a/Library/Homebrew/extend/os/mac/sandbox.rb +++ b/Library/Homebrew/extend/os/mac/sandbox.rb @@ -1,9 +1,21 @@ # typed: strict # frozen_string_literal: true -class Sandbox - sig { returns(T::Boolean) } - def self.available? - File.executable?(SANDBOX_EXEC) +module OS + module Mac + module Sandbox + module ClassMethods + extend T::Helpers + + requires_ancestor { T.class_of(::Sandbox) } + + sig { returns(T::Boolean) } + def available? + File.executable?(::Sandbox::SANDBOX_EXEC) + end + end + end end end + +Sandbox.singleton_class.prepend(OS::Mac::Sandbox::ClassMethods) diff --git a/Library/Homebrew/sandbox.rb b/Library/Homebrew/sandbox.rb index 6b3ad1dabd..1f8e29c0ae 100644 --- a/Library/Homebrew/sandbox.rb +++ b/Library/Homebrew/sandbox.rb @@ -10,7 +10,6 @@ require "utils/fork" # Helper class for running a sub-process inside of a sandboxed environment. class Sandbox SANDBOX_EXEC = "/usr/bin/sandbox-exec" - private_constant :SANDBOX_EXEC # This is defined in the macOS SDK but Ruby unfortunately does not expose it. # This value can be found by compiling a C program that prints TIOCSCTTY.