Return compiler versions and builds as Versions
This commit is contained in:
parent
16529a4de5
commit
20bbeb5e9c
@ -14,7 +14,14 @@ end
|
||||
|
||||
class CompilerFailure
|
||||
attr_reader :name
|
||||
attr_rw :version
|
||||
|
||||
def version(val = nil)
|
||||
if val
|
||||
@version = Version.parse(val.to_s)
|
||||
else
|
||||
@version
|
||||
end
|
||||
end
|
||||
|
||||
# Allows Apple compiler `fails_with` statements to keep using `build`
|
||||
# even though `build` and `version` are the same internally
|
||||
@ -45,7 +52,7 @@ class CompilerFailure
|
||||
|
||||
def initialize(name, version, &block)
|
||||
@name = name
|
||||
@version = version
|
||||
@version = Version.parse(version.to_s)
|
||||
instance_eval(&block) if block_given?
|
||||
end
|
||||
|
||||
|
@ -44,7 +44,9 @@ class DevelopmentTools
|
||||
def gcc_40_build_version
|
||||
@gcc_40_build_version ||=
|
||||
if (path = locate("gcc-4.0"))
|
||||
`#{path} --version 2>/dev/null`[/build (\d{4,})/, 1].to_i
|
||||
Version.new `#{path} --version 2>/dev/null`[/build (\d{4,})/, 1].to_i
|
||||
else
|
||||
Version::NULL
|
||||
end
|
||||
end
|
||||
alias gcc_4_0_build_version gcc_40_build_version
|
||||
@ -54,7 +56,9 @@ class DevelopmentTools
|
||||
begin
|
||||
gcc = locate("gcc-4.2") || HOMEBREW_PREFIX.join("opt/apple-gcc42/bin/gcc-4.2")
|
||||
if gcc.exist? && !gcc.realpath.basename.to_s.start_with?("llvm")
|
||||
`#{gcc} --version 2>/dev/null`[/build (\d{4,})/, 1].to_i
|
||||
Version.new `#{gcc} --version 2>/dev/null`[/build (\d{4,})/, 1]
|
||||
else
|
||||
Version::NULL
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -63,14 +67,18 @@ class DevelopmentTools
|
||||
def clang_version
|
||||
@clang_version ||=
|
||||
if (path = locate("clang"))
|
||||
`#{path} --version`[/(?:clang|LLVM) version (\d\.\d)/, 1]
|
||||
Version.new `#{path} --version`[/(?:clang|LLVM) version (\d\.\d)/, 1]
|
||||
else
|
||||
Version::NULL
|
||||
end
|
||||
end
|
||||
|
||||
def clang_build_version
|
||||
@clang_build_version ||=
|
||||
if (path = locate("clang"))
|
||||
`#{path} --version`[/clang-(\d{2,})/, 1].to_i
|
||||
Version.new `#{path} --version`[/clang-(\d{2,})/, 1]
|
||||
else
|
||||
Version::NULL
|
||||
end
|
||||
end
|
||||
|
||||
@ -78,7 +86,11 @@ class DevelopmentTools
|
||||
(@non_apple_gcc_version ||= {}).fetch(cc) do
|
||||
path = HOMEBREW_PREFIX.join("opt", "gcc", "bin", cc)
|
||||
path = locate(cc) unless path.exist?
|
||||
version = `#{path} --version`[/gcc(?:-\d(?:\.\d)? \(.+\))? (\d\.\d\.\d)/, 1] if path
|
||||
version = if path
|
||||
Version.new(`#{path} --version`[/gcc(?:-\d(?:\.\d)? \(.+\))? (\d\.\d\.\d)/, 1])
|
||||
else
|
||||
Version::NULL
|
||||
end
|
||||
@non_apple_gcc_version[cc] = version
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user