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
|
|
|
|
case default_cc
|
|
|
|
when /^gcc/ then :gcc_4_2
|
|
|
|
when "clang" then :clang
|
|
|
|
else
|
|
|
|
# guess :(
|
|
|
|
if MacOS::Xcode.version >= "4.3"
|
|
|
|
:clang
|
|
|
|
else
|
|
|
|
:gcc_4_2
|
|
|
|
end
|
|
|
|
end
|
|
|
|
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
|
|
|
|
if MacOS.version >= "10.9"
|
2017-10-15 02:28:32 +02:00
|
|
|
<<~EOS
|
2016-09-11 17:53:00 +01:00
|
|
|
Install the Command Line Tools:
|
|
|
|
xcode-select --install
|
|
|
|
EOS
|
2016-07-16 21:01:22 +01:00
|
|
|
elsif MacOS.version == "10.8" || MacOS.version == "10.7"
|
2017-10-15 02:28:32 +02:00
|
|
|
<<~EOS
|
2016-07-16 21:01:22 +01:00
|
|
|
Install the Command Line Tools from
|
2017-03-28 11:12:34 -04:00
|
|
|
https://developer.apple.com/download/more/
|
2016-07-16 21:01:22 +01:00
|
|
|
or via Xcode's preferences.
|
|
|
|
EOS
|
|
|
|
else
|
2017-10-15 02:28:32 +02:00
|
|
|
<<~EOS
|
2016-07-16 21:01:22 +01:00
|
|
|
Install Xcode from
|
2017-03-28 11:12:34 -04:00
|
|
|
https://developer.apple.com/download/more/
|
2016-07-16 21:01:22 +01:00
|
|
|
EOS
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def custom_installation_instructions
|
2019-01-08 19:13:46 +00:00
|
|
|
<<~EOS
|
|
|
|
Install GNU's GCC
|
|
|
|
brew install gcc
|
|
|
|
EOS
|
2016-07-16 21:01:22 +01:00
|
|
|
end
|
2016-04-25 18:01:03 +01:00
|
|
|
end
|
|
|
|
end
|