aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMax Howell2010-11-13 22:45:22 +0000
committerAdam Vandenberg2011-03-12 11:55:04 -0800
commitd78b89dd2e0479390ca072d5bb9a09395d9c25f8 (patch)
tree1d92e054d48e3dac42ea1a43383830f46dd8946d /Library
parent48fe9224561a57af841614ae93e5ab88769a6e4d (diff)
downloadbrew-d78b89dd2e0479390ca072d5bb9a09395d9c25f8.tar.bz2
MacOS.xcode_prefix
More robust code than before, and replaces all usage of `xcode-select -print-path`.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/extend/ENV.rb6
-rw-r--r--Library/Homebrew/utils.rb29
2 files changed, 26 insertions, 9 deletions
diff --git a/Library/Homebrew/extend/ENV.rb b/Library/Homebrew/extend/ENV.rb
index a4e290d5f..bb2bbd544 100644
--- a/Library/Homebrew/extend/ENV.rb
+++ b/Library/Homebrew/extend/ENV.rb
@@ -121,10 +121,8 @@ module HomebrewEnvExtension
end
def llvm
- xcode_path = `/usr/bin/xcode-select -print-path`.chomp
- xcode_path = "/Developer" if xcode_path.to_s.empty?
- self['CC'] = "#{xcode_path}/usr/bin/llvm-gcc"
- self['CXX'] = "#{xcode_path}/usr/bin/llvm-g++"
+ self['CC'] = "#{MacOS.xcode_prefix}/usr/bin/llvm-gcc"
+ self['CXX'] = "#{MacOS.xcode_prefix}/usr/bin/llvm-g++"
self['LD'] = self['CC']
self.O4
end
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb
index 7f2001f91..8297ff08a 100644
--- a/Library/Homebrew/utils.rb
+++ b/Library/Homebrew/utils.rb
@@ -232,12 +232,31 @@ module MacOS extend self
end
end
+ # usually /Developer
+ def xcode_prefix
+ @xcode_prefix ||= begin
+ path = `/usr/bin/xcode-select -print-path 2>&1`.chomp
+ path = Pathname.new path
+ if path.directory? and path.absolute?
+ path
+ elsif File.directory? '/Developer'
+ # we do this to support cowboys who insist on installing
+ # only a subset of Xcode
+ '/Developer'
+ else
+ nil
+ end
+ end
+ end
+
def llvm_build_version
- if MACOS_VERSION >= 10.6
- xcode_path = `/usr/bin/xcode-select -print-path`.chomp
- return nil if xcode_path.empty?
- `#{xcode_path}/usr/bin/llvm-gcc -v 2>&1` =~ /LLVM build (\d{4,})/
- $1.to_i
+ unless xcode_prefix.to_s.empty?
+ llvm_gcc_path = xcode_prefix/"usr/bin/llvm-gcc"
+ # for Xcode 3 on OS X 10.5 this will not exist
+ if llvm_gcc_path.file?
+ `#{llvm_gcc_path} -v 2>&1` =~ /LLVM build (\d{4,})/
+ $1.to_i # if nil this raises and then you fix the regex
+ end
end
end