Guess Xcode version if xcodebuild doesn't exist

This commit is contained in:
Max Howell 2011-09-02 11:53:41 +01:00
parent a0763dfc2c
commit 7aa45e81cb

View File

@ -297,8 +297,30 @@ module MacOS extend self
def xcode_version
@xcode_version ||= begin
raise unless system "/usr/bin/which -s xcodebuild"
`xcodebuild -version 2>&1` =~ /Xcode (\d(\.\d)*)/
$1
rescue
# for people who don't have xcodebuild installed due to using
# some variety of minimal installer, let's try and guess their
# Xcode version
case llvm_build_version.to_i
when 0..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
"3.2.0"
when 2326
# also applies to "3.2.3"
"3.2.4"
when 2327..2333 then "3.2.5"
when 2335
# this build number applies to 3.2.6, 4.0 and 4.1
# https://github.com/mxcl/homebrew/wiki/Xcode
"4.0"
else
"4.2"
end
end
end