aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMax Howell2012-02-17 13:34:06 +0000
committerMax Howell2012-02-17 13:34:06 +0000
commit17af67977e2c4bb16fb54c69564d85ed34e7afa8 (patch)
tree885aa37db385d2aa6e79a28c5f1e8df3d0e95835 /Library
parent88cc0141b8cf5990c5d4fdee87106e8541f406bc (diff)
downloadhomebrew-17af67977e2c4bb16fb54c69564d85ed34e7afa8.tar.bz2
Find xcrun if user doesn't ever install Xcode 4.3 helper tools
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/cmd/--env.rb4
-rw-r--r--Library/Homebrew/extend/ENV.rb12
-rw-r--r--Library/Homebrew/utils.rb10
3 files changed, 17 insertions, 9 deletions
diff --git a/Library/Homebrew/cmd/--env.rb b/Library/Homebrew/cmd/--env.rb
index 7d9796061..f4baefdab 100644
--- a/Library/Homebrew/cmd/--env.rb
+++ b/Library/Homebrew/cmd/--env.rb
@@ -18,8 +18,8 @@ module Homebrew extend self
value = env[k]
if value
results = value
- if value =~ %r{^/usr/bin/xcrun (.*)}
- path = `/usr/bin/xcrun -find #{$1}`
+ if value =~ /^[^\s]*xcrun (.*)/
+ path = `#{MacOS.xcrun} -find #{$1}`
results += " => #{path}"
elsif File.exists? value and File.symlink? value
results += " => #{Pathname.new(value).realpath}"
diff --git a/Library/Homebrew/extend/ENV.rb b/Library/Homebrew/extend/ENV.rb
index b059927a6..8689d977a 100644
--- a/Library/Homebrew/extend/ENV.rb
+++ b/Library/Homebrew/extend/ENV.rb
@@ -89,7 +89,7 @@ module HomebrewEnvExtension
def xcrun tool
if File.executable? "/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
# tool usage thus avoiding various bugs
"/usr/bin/xcrun #{tool}"
@@ -106,10 +106,10 @@ module HomebrewEnvExtension
# if your formula doesn't like CC having spaces use this
def expand_xcrun
- ENV['CC'] =~ %r{/usr/bin/xcrun (.*)}
- ENV['CC'] = `/usr/bin/xcrun -find #{$1}`.chomp if $1
- ENV['CXX'] =~ %r{/usr/bin/xcrun (.*)}
- ENV['CXX'] = `/usr/bin/xcrun -find #{$1}`.chomp if $1
+ ENV['CC'] =~ %r{#{MacOS.xcrun} (.*)}
+ ENV['CC'] = `#{MacOS.xcrun} -find #{$1}`.chomp if $1
+ ENV['CXX'] =~ %r{#{MacOS.xcrun} (.*)}
+ ENV['CXX'] = `#{MacOS.xcrun} -find #{$1}`.chomp if $1
end
def gcc args = {}
@@ -126,7 +126,7 @@ module HomebrewEnvExtension
raise "GCC could not be found" if not File.exist? ENV['CC']
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/
end
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb
index b552a4121..1fcb23591 100644
--- a/Library/Homebrew/utils.rb
+++ b/Library/Homebrew/utils.rb
@@ -266,8 +266,16 @@ module MacOS extend self
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
- 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?
Pathname.new(cc).realpath.basename.to_s rescue nil
end