mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Remove more monkey-patching in extend/os
This commit is contained in:
parent
508c8b606c
commit
267afac198
@ -1,9 +1,21 @@
|
||||
# typed: strict
|
||||
# frozen_string_literal: true
|
||||
|
||||
class CompilerSelector
|
||||
module OS
|
||||
module Linux
|
||||
module CompilerSelector
|
||||
module ClassMethods
|
||||
extend T::Helpers
|
||||
|
||||
requires_ancestor { T.class_of(::CompilerSelector) }
|
||||
|
||||
sig { returns(String) }
|
||||
def self.preferred_gcc
|
||||
def preferred_gcc
|
||||
OS::LINUX_PREFERRED_GCC_COMPILER_FORMULA
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
CompilerSelector.singleton_class.prepend(OS::Linux::CompilerSelector::ClassMethods)
|
||||
|
@ -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
|
||||
|
@ -1,9 +1,17 @@
|
||||
# typed: strict
|
||||
# frozen_string_literal: true
|
||||
|
||||
module OS
|
||||
module Mac
|
||||
module Language
|
||||
module Java
|
||||
def self.java_home(version = nil)
|
||||
module ClassMethods
|
||||
extend T::Helpers
|
||||
|
||||
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
|
||||
|
||||
@ -11,3 +19,8 @@ module Language
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Language::Java.singleton_class.prepend(OS::Mac::Language::Java::ClassMethods)
|
||||
|
@ -1,9 +1,21 @@
|
||||
# typed: strict
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Sandbox
|
||||
module OS
|
||||
module Mac
|
||||
module Sandbox
|
||||
module ClassMethods
|
||||
extend T::Helpers
|
||||
|
||||
requires_ancestor { T.class_of(::Sandbox) }
|
||||
|
||||
sig { returns(T::Boolean) }
|
||||
def self.available?
|
||||
File.executable?(SANDBOX_EXEC)
|
||||
def available?
|
||||
File.executable?(::Sandbox::SANDBOX_EXEC)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Sandbox.singleton_class.prepend(OS::Mac::Sandbox::ClassMethods)
|
||||
|
@ -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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user