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.
This commit is contained in:
Max Howell 2012-03-16 00:59:09 +00:00
parent f1c26eb6e7
commit c1545fe56a

View File

@ -378,6 +378,14 @@ module MacOS extend self
def xcode_version def xcode_version
@xcode_version ||= begin @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 # Xcode 4.3 xc* tools hang indefinately if xcode-select path is set thus
raise if `xcode-select -print-path 2>/dev/null`.chomp == "/" 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 # For people who's xcode-select is unset, or who have installed
# xcode-gcc-installer or whatever other combinations we can try and # xcode-gcc-installer or whatever other combinations we can try and
# supprt. See https://github.com/mxcl/homebrew/wiki/Xcode # supprt. See https://github.com/mxcl/homebrew/wiki/Xcode
case nil case llvm_build_version.to_i
when 0..2063 then "3.1.0" when 1..2063 then "3.1.0"
when 2064..2065 then "3.1.4" when 2064..2065 then "3.1.4"
when 2366..2325 when 2366..2325
# we have no data for this range so we are guessing # we have no data for this range so we are guessing
@ -405,7 +413,9 @@ module MacOS extend self
"4.0" "4.0"
else else
case (clang_version.to_f * 10).to_i case (clang_version.to_f * 10).to_i
when 0..14 when 0
"dunno"
when 1..14
"3.2.2" "3.2.2"
when 15 when 15
"3.2.4" "3.2.4"