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
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class CompilerSelector
|
module OS
|
||||||
sig { returns(String) }
|
module Linux
|
||||||
def self.preferred_gcc
|
module CompilerSelector
|
||||||
OS::LINUX_PREFERRED_GCC_COMPILER_FORMULA
|
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
|
||||||
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 "Host glibc: #{host_glibc_version}"
|
||||||
out.puts "#{::DevelopmentTools.host_gcc_path}: #{host_gcc_version}"
|
out.puts "#{::DevelopmentTools.host_gcc_path}: #{host_gcc_version}"
|
||||||
out.puts "/usr/bin/ruby: #{host_ruby_version}" if RUBY_PATH != HOST_RUBY_PATH
|
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)}"
|
out.puts "#{f}: #{formula_linked_version(f)}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,13 +1,26 @@
|
|||||||
# typed: strict
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Language
|
module OS
|
||||||
module Java
|
module Mac
|
||||||
def self.java_home(version = nil)
|
module Language
|
||||||
openjdk = find_openjdk_formula(version)
|
module Java
|
||||||
return unless openjdk
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Language::Java.singleton_class.prepend(OS::Mac::Language::Java::ClassMethods)
|
||||||
|
@ -1,9 +1,21 @@
|
|||||||
# typed: strict
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class Sandbox
|
module OS
|
||||||
sig { returns(T::Boolean) }
|
module Mac
|
||||||
def self.available?
|
module Sandbox
|
||||||
File.executable?(SANDBOX_EXEC)
|
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
|
||||||
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.
|
# Helper class for running a sub-process inside of a sandboxed environment.
|
||||||
class Sandbox
|
class Sandbox
|
||||||
SANDBOX_EXEC = "/usr/bin/sandbox-exec"
|
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 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.
|
# This value can be found by compiling a C program that prints TIOCSCTTY.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user