2019-04-19 15:38:03 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-07-06 11:07:24 +01:00
|
|
|
require "os/mac/xcode"
|
|
|
|
|
2016-04-25 18:01:03 +01:00
|
|
|
# @private
|
|
|
|
class DevelopmentTools
|
|
|
|
class << self
|
2018-04-07 20:28:56 +01:00
|
|
|
alias generic_locate locate
|
|
|
|
undef installed?, default_compiler, curl_handles_most_https_certificates?,
|
|
|
|
subversion_handles_most_https_certificates?
|
|
|
|
|
2016-04-25 18:01:03 +01:00
|
|
|
def locate(tool)
|
|
|
|
(@locate ||= {}).fetch(tool) do |key|
|
2018-04-07 20:28:56 +01:00
|
|
|
@locate[key] = if (located_tool = generic_locate(tool))
|
2016-04-25 18:01:03 +01:00
|
|
|
located_tool
|
2019-01-08 19:13:46 +00:00
|
|
|
else
|
2017-09-19 10:19:56 -07:00
|
|
|
path = Utils.popen_read("/usr/bin/xcrun", "-no-cache", "-find", tool, err: :close).chomp
|
2016-04-25 18:01:03 +01:00
|
|
|
Pathname.new(path) if File.executable?(path)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-07-06 11:07:24 +01:00
|
|
|
# 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.
|
|
|
|
def installed?
|
|
|
|
MacOS::Xcode.installed? || MacOS::CLT.installed?
|
|
|
|
end
|
|
|
|
|
2018-04-07 20:28:56 +01:00
|
|
|
def default_compiler
|
2019-01-26 17:13:14 +00:00
|
|
|
:clang
|
2018-04-07 20:28:56 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
def subversion_handles_most_https_certificates?
|
|
|
|
# The system Subversion is too old for some HTTPS certificates on
|
|
|
|
# older macOS versions.
|
|
|
|
MacOS.version >= :sierra
|
|
|
|
end
|
|
|
|
|
2016-07-16 21:01:22 +01:00
|
|
|
def installation_instructions
|
2019-01-26 17:13:14 +00:00
|
|
|
<<~EOS
|
|
|
|
Install the Command Line Tools:
|
|
|
|
xcode-select --install
|
|
|
|
EOS
|
2016-07-16 21:01:22 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def custom_installation_instructions
|
2019-01-08 19:13:46 +00:00
|
|
|
<<~EOS
|
2019-04-08 12:47:15 -04:00
|
|
|
Install GNU's GCC:
|
2019-01-08 19:13:46 +00:00
|
|
|
brew install gcc
|
|
|
|
EOS
|
2016-07-16 21:01:22 +01:00
|
|
|
end
|
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,
|
|
|
|
}
|
|
|
|
generic_build_system_info.merge build_info
|
|
|
|
end
|
2016-04-25 18:01:03 +01:00
|
|
|
end
|
|
|
|
end
|