development_tools: update type signatures

This commit is contained in:
fn ⌃ ⌥ 2021-09-29 17:43:47 -07:00
parent 61a7ffb999
commit 9638e3e8c0
7 changed files with 18 additions and 20 deletions

View File

@ -38,19 +38,6 @@ class DevelopmentTools
installation_instructions
end
# TODO: This method appears to be unused. Can it be deleted?
sig { returns(T.nilable(String)) }
def default_cc
cc = DevelopmentTools.locate "cc"
return if cc.nil?
begin
cc.realpath.basename.to_s
rescue
nil
end
end
sig { returns(Symbol) }
def default_compiler
:clang
@ -126,7 +113,7 @@ class DevelopmentTools
{
"os" => ENV["HOMEBREW_SYSTEM"],
"os_version" => OS_VERSION,
"cpu_family" => Hardware::CPU.family,
"cpu_family" => Hardware::CPU.family.to_s,
}
end
alias generic_build_system_info build_system_info

View File

@ -21,11 +21,11 @@ class DevelopmentTools
:gcc
end
sig { returns(T::Hash[String, T.untyped]) }
sig { returns(T::Hash[String, T.nilable(String)]) }
def build_system_info
generic_build_system_info.merge({
"glibc_version" => OS::Linux::Glibc.version,
"oldest_cpu_family" => Hardware.oldest_cpu,
"glibc_version" => OS::Linux::Glibc.version.to_s.presence,
"oldest_cpu_family" => Hardware.oldest_cpu.to_s,
})
end
end

View File

@ -64,7 +64,7 @@ class DevelopmentTools
EOS
end
sig { returns(T::Hash[String, T.untyped]) }
sig { returns(T::Hash[String, T.nilable(String)]) }
def build_system_info
build_info = {
"xcode" => MacOS::Xcode.version.to_s.presence,

View File

@ -4,7 +4,12 @@
module Hardware
extend T::Sig
sig { params(version: T.nilable(Version)).returns(Symbol) }
def self.oldest_cpu(version = MacOS.version)
def self.oldest_cpu(version = nil)
version = if version
MacOS::Version.new(version.to_s)
else
MacOS.version
end
if CPU.arch == :arm64
:arm_vortex_tempest
# TODO: this cannot be re-enabled until either Rosetta 2 supports AVX

View File

@ -11,6 +11,7 @@ module OS
module_function
sig { returns(Version) }
def system_version
@system_version ||= begin
version = Utils.popen_read("/usr/bin/ldd", "--version")[/ (\d+\.\d+)/, 1]
@ -22,6 +23,7 @@ module OS
end
end
sig { returns(Version) }
def version
@version ||= begin
version = Utils.popen_read(HOMEBREW_PREFIX/"opt/glibc/bin/ldd", "--version")[/ (\d+\.\d+)/, 1]
@ -38,6 +40,7 @@ module OS
Version.new(ENV.fetch("HOMEBREW_LINUX_MINIMUM_GLIBC_VERSION"))
end
sig { returns(T::Boolean) }
def below_minimum_version?
system_version < minimum_version
end

View File

@ -24,16 +24,19 @@ module OS
# This can be compared to numerics, strings, or symbols
# using the standard Ruby Comparable methods.
sig { returns(Version) }
def version
@version ||= full_version.strip_patch
end
# This can be compared to numerics, strings, or symbols
# using the standard Ruby Comparable methods.
sig { returns(Version) }
def full_version
@full_version ||= Version.new((ENV["HOMEBREW_MACOS_VERSION"]).chomp)
end
sig { params(version: Version).void }
def full_version=(version)
@full_version = Version.new(version.chomp)
@version = nil

View File

@ -89,7 +89,7 @@ module OS
# Returns a Pathname object corresponding to Xcode.app's Developer
# directory or nil if Xcode.app is not installed.
sig { returns(Pathname) }
sig { returns(T.nilable(Pathname)) }
def prefix
@prefix ||=
begin