aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
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