Find xcrun if user doesn't ever install Xcode 4.3 helper tools

This commit is contained in:
Max Howell 2012-02-17 13:34:06 +00:00
parent 30cbb25147
commit 607c13c32b
3 changed files with 17 additions and 9 deletions

View File

@ -18,8 +18,8 @@ module Homebrew extend self
value = env[k] value = env[k]
if value if value
results = value results = value
if value =~ %r{^/usr/bin/xcrun (.*)} if value =~ /^[^\s]*xcrun (.*)/
path = `/usr/bin/xcrun -find #{$1}` path = `#{MacOS.xcrun} -find #{$1}`
results += " => #{path}" results += " => #{path}"
elsif File.exists? value and File.symlink? value elsif File.exists? value and File.symlink? value
results += " => #{Pathname.new(value).realpath}" results += " => #{Pathname.new(value).realpath}"

View File

@ -89,7 +89,7 @@ module HomebrewEnvExtension
def xcrun tool def xcrun tool
if File.executable? "/usr/bin/#{tool}" if File.executable? "/usr/bin/#{tool}"
"/usr/bin/#{tool}" "/usr/bin/#{tool}"
elsif system "/usr/bin/xcrun -find #{tool} 2>1 1>/dev/null" elsif system "#{MacOS.xcrun} -find #{tool} 2>1 1>/dev/null"
# xcrun was provided first with Xcode 4.3 and allows us to proxy # xcrun was provided first with Xcode 4.3 and allows us to proxy
# tool usage thus avoiding various bugs # tool usage thus avoiding various bugs
"/usr/bin/xcrun #{tool}" "/usr/bin/xcrun #{tool}"
@ -106,10 +106,10 @@ module HomebrewEnvExtension
# if your formula doesn't like CC having spaces use this # if your formula doesn't like CC having spaces use this
def expand_xcrun def expand_xcrun
ENV['CC'] =~ %r{/usr/bin/xcrun (.*)} ENV['CC'] =~ %r{#{MacOS.xcrun} (.*)}
ENV['CC'] = `/usr/bin/xcrun -find #{$1}`.chomp if $1 ENV['CC'] = `#{MacOS.xcrun} -find #{$1}`.chomp if $1
ENV['CXX'] =~ %r{/usr/bin/xcrun (.*)} ENV['CXX'] =~ %r{#{MacOS.xcrun} (.*)}
ENV['CXX'] = `/usr/bin/xcrun -find #{$1}`.chomp if $1 ENV['CXX'] = `#{MacOS.xcrun} -find #{$1}`.chomp if $1
end end
def gcc args = {} def gcc args = {}
@ -126,7 +126,7 @@ module HomebrewEnvExtension
raise "GCC could not be found" if not File.exist? ENV['CC'] raise "GCC could not be found" if not File.exist? ENV['CC']
end end
if not ENV['CC'] =~ %r{^/usr/bin/xcrun} if not ENV['CC'] =~ /^[^\s]*xcrun /
raise "GCC could not be found" if Pathname.new(ENV['CC']).realpath.to_s =~ /llvm/ raise "GCC could not be found" if Pathname.new(ENV['CC']).realpath.to_s =~ /llvm/
end end

View File

@ -266,8 +266,16 @@ module MacOS extend self
end end
end end
def xcrun
@xcrun ||= begin
path = "#{xcode_prefix}/usr/bin/xcrun"
path = "xcrun" unless File.file? path # just in case
path
end
end
def default_cc def default_cc
cc = `/usr/bin/xcrun -find cc 2> /dev/null`.chomp cc = `#{xcrun} -find cc 2> /dev/null`.chomp
cc = "#{dev_tools_path}/cc" if cc.empty? cc = "#{dev_tools_path}/cc" if cc.empty?
Pathname.new(cc).realpath.basename.to_s rescue nil Pathname.new(cc).realpath.basename.to_s rescue nil
end end