Separate Xcode and CLT doctor checks by OS X version

Closes Homebrew/homebrew#29206.
This commit is contained in:
Jack Nagel 2014-05-12 14:46:50 -05:00
parent be6029c634
commit 1845b39d41
2 changed files with 64 additions and 66 deletions

View File

@ -198,71 +198,79 @@ def check_for_broken_symlinks
end end
end end
def check_xcode_clt if MacOS.version >= "10.9"
if MacOS.version >= :mavericks def check_for_installed_developer_tools
__check_clt_up_to_date unless MacOS::CLT.installed? then <<-EOS.undent
elsif MacOS::Xcode.installed? No developer tools installed.
__check_xcode_up_to_date Install the Command Line Tools:
elsif MacOS.version >= :lion xcode-select --install
__check_clt_up_to_date EOS
else <<-EOS.undent end
Xcode is not installed
Most formulae need Xcode to build.
It can be installed from https://developer.apple.com/downloads/
EOS
end end
end
def __check_xcode_up_to_date def check_xcode_up_to_date
if MacOS::Xcode.outdated? if MacOS::Xcode.installed? && MacOS::Xcode.outdated? then <<-EOS.undent
message = <<-EOS.undent
Your Xcode (#{MacOS::Xcode.version}) is outdated Your Xcode (#{MacOS::Xcode.version}) is outdated
Please update to Xcode #{MacOS::Xcode.latest_version}. Please update to Xcode #{MacOS::Xcode.latest_version}.
EOS
if MacOS.version >= :lion
message += <<-EOS.undent
Xcode can be updated from the App Store. Xcode can be updated from the App Store.
EOS EOS
else end
message += <<-EOS.undent end
Xcode can be updated from https://developer.apple.com/downloads/
def check_clt_up_to_date
if MacOS::CLT.installed? && MacOS::CLT.outdated? then <<-EOS.undent
A newer Command Line Tools release is available.
Update them from Software Update in the App Store.
EOS EOS
end end
message
end end
end elsif MacOS.version == "10.8" || MacOS.version == "10.7"
def check_for_installed_developer_tools
def __check_clt_up_to_date unless MacOS::Xcode.installed? || MacOS::CLT.installed? then <<-EOS.undent
if not MacOS::CLT.installed?
message = <<-EOS.undent
No developer tools installed. No developer tools installed.
You should install the Command Line Tools. You should install the Command Line Tools.
EOS The standalone package can be obtained from
if MacOS.version >= :mavericks https://developer.apple.com/downloads
message += <<-EOS.undent or it can be installed via Xcode's preferences.
Run `xcode-select --install` to install them.
EOS
else
message += <<-EOS.undent
The standalone package can be obtained from
https://developer.apple.com/downloads/,
or it can be installed via Xcode's preferences.
EOS EOS
end end
message end
elsif MacOS::CLT.outdated?
message = <<-EOS.undent def check_xcode_up_to_date
A newer Command Line Tools release is available if MacOS::Xcode.installed? && MacOS::Xcode.outdated? then <<-EOS.undent
EOS Your Xcode (#{MacOS::Xcode.version}) is outdated
if MacOS.version >= :mavericks Please update to Xcode #{MacOS::Xcode.latest_version}.
message += <<-EOS.undent Xcode can be updated from
Update them from Software Update in the App Store. https://developer.apple.com/downloads
EOS EOS
else end
message += <<-EOS.undent end
The standalone package can be obtained from
https://developer.apple.com/downloads/, def check_clt_up_to_date
or it can be installed via Xcode's preferences. if MacOS::CLT.installed? && MacOS::CLT.outdated? then <<-EOS.undent
A newer Command Line Tools release is available.
The standalone package can be obtained from
https://developer.apple.com/downloads
or it can be installed via Xcode's preferences.
EOS
end
end
else
def check_for_installed_developer_tools
unless MacOS::Xcode.installed? then <<-EOS.undent
Xcode is not installed. Most formulae need Xcode to build.
It can be installed from
https://developer.apple.com/downloads
EOS
end
end
def check_xcode_up_to_date
if MacOS::Xcode.installed? && MacOS::Xcode.outdated? then <<-EOS.undent
Your Xcode (#{MacOS::Xcode.version}) is outdated
Please update to Xcode #{MacOS::Xcode.latest_version}.
Xcode can be updated from
https://developer.apple.com/downloads
EOS EOS
end end
end end
@ -304,18 +312,6 @@ def check_for_stray_developer_directory
end end
end end
def check_standard_compilers
return if check_xcode_clt # only check if Xcode is up to date
compiler_status = MacOS.compilers_standard?
if not compiler_status and not compiler_status.nil? then <<-EOS.undent
Your compilers are different from the standard versions for your Xcode.
If you have Xcode 4.3 or newer, you should install the Command Line Tools for
Xcode from within Xcode's Download preferences.
Otherwise, you should reinstall Xcode.
EOS
end
end
def __check_subdir_access base def __check_subdir_access base
target = HOMEBREW_PREFIX+base target = HOMEBREW_PREFIX+base
return unless target.exist? return unless target.exist?

View File

@ -64,9 +64,11 @@ module Homebrew extend self
def check_xcode def check_xcode
require 'cmd/doctor' require 'cmd/doctor'
checks = Checks.new checks = Checks.new
doctor_methods = ['check_xcode_clt', 'check_xcode_license_approved', %w[
'check_for_osx_gcc_installer'] check_for_installed_developer_tools
doctor_methods.each do |check| check_xcode_license_approved
check_for_osx_gcc_installer
].each do |check|
out = checks.send(check) out = checks.send(check)
opoo out unless out.nil? opoo out unless out.nil?
end end