Improve Xcode and CLT config reporting

We support three configurations: Xcode-only, CLT-only, and Xcode with
CLT. Our configuration output should correctly reflect this.

While MacOS::Xcode.version has to continue to return a guess if Xcode is
not installed in order to maintain backwards compatibility, this is an
implementation detail that we don't need to expose to the user. And it
makes `brew --config` output confusing.

So let's only print the "Xcode" line when an actual Xcode installation
is present. This makes it easy to quickly figure out which of the three
possible configurations the user is running.

Addresses Homebrew/homebrew#14941, more or less.
This commit is contained in:
Jack Nagel 2012-09-14 13:24:28 -05:00
parent fe4e73db32
commit 5ce1caa1f3
2 changed files with 26 additions and 24 deletions

View File

@ -29,24 +29,22 @@ module Homebrew extend self
@clang_build ||= MacOS.clang_build_version @clang_build ||= MacOS.clang_build_version
end end
def describe_xcode def xcode
@describe_xcode ||= begin if instance_variable_defined?(:@xcode)
default_prefix = case MacOS.version @xcode
when 10.5, 10.6 then '/Developer' elsif MacOS::Xcode.installed?
else '/Applications/Xcode.app/Contents/Developer' @xcode = MacOS::Xcode.version
end @xcode += " => #{MacOS::Xcode.prefix}" unless MacOS::Xcode.default_prefix?
@xcode
guess = '(guessed)' unless MacOS::Xcode.installed?
prefix = if MacOS::Xcode.installed?
"=> #{MacOS::Xcode.prefix}" unless MacOS::Xcode.prefix.to_s == default_prefix
end
[MacOS::Xcode.version, guess, prefix].compact.join(' ')
end end
end end
def describe_clt def clt
@describe_clt ||= if MacOS::CLT.installed? then MacOS::CLT.version else 'N/A' end if instance_variable_defined?(:@clt)
@clt
elsif MacOS::CLT.installed? && MacOS::Xcode.version.to_f >= 4.3
@clt = MacOS::CLT.version
end
end end
def head def head
@ -95,8 +93,8 @@ module Homebrew extend self
puts "HOMEBREW_CELLAR: #{HOMEBREW_CELLAR}" if HOMEBREW_CELLAR.to_s != "#{HOMEBREW_PREFIX}/Cellar" puts "HOMEBREW_CELLAR: #{HOMEBREW_CELLAR}" if HOMEBREW_CELLAR.to_s != "#{HOMEBREW_PREFIX}/Cellar"
puts hardware puts hardware
puts "OS X: #{MACOS_FULL_VERSION}-#{kernel}" puts "OS X: #{MACOS_FULL_VERSION}-#{kernel}"
puts "Xcode: #{describe_xcode}" puts "Xcode: #{xcode}" if xcode
puts "CLT: #{describe_clt}" if MacOS::Xcode.version.to_f >= 4.3 puts "CLT: #{clt}" if clt
puts "/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby:\n #{RUBY_VERSION}-#{RUBY_PATCHLEVEL}" if RUBY_VERSION.to_f != 1.8 puts "/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby:\n #{RUBY_VERSION}-#{RUBY_PATCHLEVEL}" if RUBY_VERSION.to_f != 1.8
unless MacOS.compilers_standard? unless MacOS.compilers_standard?
@ -127,8 +125,8 @@ module Homebrew extend self
puts "HOMEBREW_CELLAR: #{HOMEBREW_CELLAR}" puts "HOMEBREW_CELLAR: #{HOMEBREW_CELLAR}"
puts hardware puts hardware
puts "OS X: #{MACOS_FULL_VERSION}-#{kernel}" puts "OS X: #{MACOS_FULL_VERSION}-#{kernel}"
puts "Xcode: #{describe_xcode}" puts "Xcode: #{xcode}" if xcode
puts "CLT: #{describe_clt}\n" if MacOS::Xcode.version.to_f >= 4.3 puts "CLT: #{clt}" if clt
puts "GCC-4.0: build #{gcc_40}" if gcc_40 puts "GCC-4.0: build #{gcc_40}" if gcc_40
puts "GCC-4.2: build #{gcc_42}" if gcc_42 puts "GCC-4.2: build #{gcc_42}" if gcc_42
puts "LLVM-GCC: #{llvm ? "build #{llvm}" : "N/A"}" puts "LLVM-GCC: #{llvm ? "build #{llvm}" : "N/A"}"
@ -147,11 +145,7 @@ module Homebrew extend self
print MACOS_FULL_VERSION print MACOS_FULL_VERSION
print "-#{kernel}" if MacOS.version < :lion print "-#{kernel}" if MacOS.version < :lion
print ' ' print ' '
if MacOS::Xcode.version > "4.3" print MacOS::Xcode.prefix unless MacOS::Xcode.default_prefix?
print MacOS::Xcode.prefix unless MacOS::Xcode.prefix.to_s =~ %r{^/Applications/Xcode.app}
else
print MacOS::Xcode.prefix unless MacOS::Xcode.prefix.to_s =~ %r{^/Developer}
end
print "#{MacOS::Xcode.version}" print "#{MacOS::Xcode.version}"
print "-noclt" unless MacOS::CLT.installed? print "-noclt" unless MacOS::CLT.installed?
print " clang-#{clang_build} llvm-#{llvm} " print " clang-#{clang_build} llvm-#{llvm} "

View File

@ -147,6 +147,14 @@ module MacOS::Xcode extend self
def provides_gcc? def provides_gcc?
version.to_f < 4.3 version.to_f < 4.3
end end
def default_prefix?
if version.to_f < 4.3
%r{^/Developer} === prefix
else
%r{^/Applications/Xcode.app} === prefix
end
end
end end
module MacOS::CLT extend self module MacOS::CLT extend self