diff options
| author | Max Howell | 2010-11-13 22:45:22 +0000 |
|---|---|---|
| committer | Adam Vandenberg | 2011-03-12 11:55:04 -0800 |
| commit | 167721c4ab37c4e61171c1c5aa70bed800ff0a8b (patch) | |
| tree | dcc64b93cf50ff6064c2b2594d9f75dcfcb901ca /Library | |
| parent | 453a5c692b70ec9d55b5739e7af5b4d034798f2b (diff) | |
| download | homebrew-167721c4ab37c4e61171c1c5aa70bed800ff0a8b.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/Formula/tcpflow.rb | 3 | ||||
| -rw-r--r-- | Library/Homebrew/extend/ENV.rb | 6 | ||||
| -rw-r--r-- | Library/Homebrew/utils.rb | 29 |
3 files changed, 27 insertions, 11 deletions
diff --git a/Library/Formula/tcpflow.rb b/Library/Formula/tcpflow.rb index d03f12931..30eae9c42 100644 --- a/Library/Formula/tcpflow.rb +++ b/Library/Formula/tcpflow.rb @@ -11,8 +11,7 @@ class Tcpflow <Formula end def install - where = `xcode-select --print-path`.chomp - cp Dir["#{where}/usr/share/libtool/config/config.*"], "." + cp Dir["#{MacOS.xcode_prefix}/usr/share/libtool/config/config.*"], "." system "./configure", "--disable-debug", "--disable-dependency-tracking", "--prefix=#{prefix}", "--mandir=#{man}" 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 |
