From c1545fe56a939ce3f353e541693cede233b8a902 Mon Sep 17 00:00:00 2001 From: Max Howell Date: Fri, 16 Mar 2012 00:59:09 +0000 Subject: [PATCH] xcode_version works for Xcode 4.3 without CLITools Also correct heinous error when I put `case nil` in the code. Also outputs "dunno" if we really can't figure it out. I think this is safe. --- Library/Homebrew/utils.rb | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index 4ef0a5a674..b335c45eac 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -378,6 +378,14 @@ module MacOS extend self def xcode_version @xcode_version ||= begin + # this shortcut makes xcode_version work for people who don't realise you + # need to install the CLI tools + xcode43build = "/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild" + if File.file? xcode43build + `#{xcode43build} -version 2>/dev/null` =~ /Xcode (\d(\.\d)*)/ + return $1 if $1 + end + # Xcode 4.3 xc* tools hang indefinately if xcode-select path is set thus raise if `xcode-select -print-path 2>/dev/null`.chomp == "/" @@ -389,8 +397,8 @@ module MacOS extend self # For people who's xcode-select is unset, or who have installed # xcode-gcc-installer or whatever other combinations we can try and # supprt. See https://github.com/mxcl/homebrew/wiki/Xcode - case nil - when 0..2063 then "3.1.0" + case llvm_build_version.to_i + when 1..2063 then "3.1.0" when 2064..2065 then "3.1.4" when 2366..2325 # we have no data for this range so we are guessing @@ -405,7 +413,9 @@ module MacOS extend self "4.0" else case (clang_version.to_f * 10).to_i - when 0..14 + when 0 + "dunno" + when 1..14 "3.2.2" when 15 "3.2.4"