brew/Library/Homebrew/extend/os/mac/development_tools.rb

85 lines
2.4 KiB
Ruby
Raw Normal View History

2020-10-10 14:16:11 +02:00
# typed: true
# frozen_string_literal: true
require "os/mac/xcode"
# @private
class DevelopmentTools
class << self
2020-10-20 12:03:48 +02:00
extend T::Sig
alias generic_locate locate
undef installed?, default_compiler, curl_handles_most_https_certificates?,
ca_file_handles_most_https_certificates?, subversion_handles_most_https_certificates?
2021-09-29 15:12:53 -07:00
sig { params(tool: String).returns(T.nilable(Pathname)) }
def locate(tool)
(@locate ||= {}).fetch(tool) do |key|
@locate[key] = if (located_tool = generic_locate(tool))
located_tool
else
path = Utils.popen_read("/usr/bin/xcrun", "-no-cache", "-find", tool, err: :close).chomp
Pathname.new(path) if File.executable?(path)
end
end
end
# Checks if the user has any developer tools installed, either via Xcode
# or the CLT. Convenient for guarding against formula builds when building
# is impossible.
2021-09-29 15:12:53 -07:00
sig { returns(T::Boolean) }
def installed?
MacOS::Xcode.installed? || MacOS::CLT.installed?
end
2020-10-20 12:03:48 +02:00
sig { returns(Symbol) }
def default_compiler
:clang
end
sig { returns(T::Boolean) }
def ca_file_handles_most_https_certificates?
# The system CA file is too old for some modern HTTPS certificates on
# older macOS versions.
ENV["HOMEBREW_SYSTEM_CA_CERTIFICATES_TOO_OLD"].nil?
end
2020-10-20 12:03:48 +02:00
sig { returns(T::Boolean) }
def curl_handles_most_https_certificates?
# The system Curl is too old for some modern HTTPS certificates on
# older macOS versions.
ENV["HOMEBREW_SYSTEM_CURL_TOO_OLD"].nil?
end
2020-10-20 12:03:48 +02:00
sig { returns(T::Boolean) }
def subversion_handles_most_https_certificates?
# The system Subversion is too old for some HTTPS certificates on
# older macOS versions.
MacOS.version >= :sierra
end
2020-10-20 12:03:48 +02:00
sig { returns(String) }
def installation_instructions
MacOS::CLT.installation_instructions
end
2020-10-20 12:03:48 +02:00
sig { returns(String) }
def custom_installation_instructions
<<~EOS
2019-04-08 12:47:15 -04:00
Install GNU's GCC:
brew install gcc
EOS
end
2020-04-06 13:04:48 +01:00
sig { returns(T::Hash[String, T.nilable(String)]) }
2020-04-06 13:04:48 +01:00
def build_system_info
build_info = {
"xcode" => MacOS::Xcode.version.to_s.presence,
"clt" => MacOS::CLT.version.to_s.presence,
"preferred_perl" => MacOS.preferred_perl_version,
2020-04-06 13:04:48 +01:00
}
generic_build_system_info.merge build_info
end
end
end