mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
development_tools: don't create Versions from nil
This cause issues when e.g. using `debrew.rb` on a failing `system` command in a formula.
This commit is contained in:
parent
c1af8fba55
commit
727263e906
@ -43,8 +43,9 @@ class DevelopmentTools
|
|||||||
|
|
||||||
def gcc_40_build_version
|
def gcc_40_build_version
|
||||||
@gcc_40_build_version ||=
|
@gcc_40_build_version ||=
|
||||||
if (path = locate("gcc-4.0"))
|
if (path = locate("gcc-4.0")) &&
|
||||||
Version.new `#{path} --version 2>/dev/null`[/build (\d{4,})/, 1].to_i
|
build_version = `#{path} --version 2>/dev/null`[/build (\d{4,})/, 1]
|
||||||
|
Version.new build_version
|
||||||
else
|
else
|
||||||
Version::NULL
|
Version::NULL
|
||||||
end
|
end
|
||||||
@ -55,8 +56,9 @@ class DevelopmentTools
|
|||||||
@gcc_42_build_version ||=
|
@gcc_42_build_version ||=
|
||||||
begin
|
begin
|
||||||
gcc = locate("gcc-4.2") || HOMEBREW_PREFIX.join("opt/apple-gcc42/bin/gcc-4.2")
|
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")
|
if gcc.exist? && !gcc.realpath.basename.to_s.start_with?("llvm")&&
|
||||||
Version.new `#{gcc} --version 2>/dev/null`[/build (\d{4,})/, 1]
|
build_version = `#{gcc} --version 2>/dev/null`[/build (\d{4,})/, 1]
|
||||||
|
Version.new build_version
|
||||||
else
|
else
|
||||||
Version::NULL
|
Version::NULL
|
||||||
end
|
end
|
||||||
@ -66,8 +68,9 @@ class DevelopmentTools
|
|||||||
|
|
||||||
def clang_version
|
def clang_version
|
||||||
@clang_version ||=
|
@clang_version ||=
|
||||||
if (path = locate("clang"))
|
if (path = locate("clang")) &&
|
||||||
Version.new `#{path} --version`[/(?:clang|LLVM) version (\d\.\d)/, 1]
|
build_version = `#{path} --version`[/(?:clang|LLVM) version (\d\.\d)/, 1]
|
||||||
|
Version.new build_version
|
||||||
else
|
else
|
||||||
Version::NULL
|
Version::NULL
|
||||||
end
|
end
|
||||||
@ -75,8 +78,9 @@ class DevelopmentTools
|
|||||||
|
|
||||||
def clang_build_version
|
def clang_build_version
|
||||||
@clang_build_version ||=
|
@clang_build_version ||=
|
||||||
if (path = locate("clang"))
|
if (path = locate("clang")) &&
|
||||||
Version.new `#{path} --version`[/clang-(\d{2,})/, 1]
|
build_version = `#{path} --version`[/clang-(\d{2,})/, 1]
|
||||||
|
Version.new build_version
|
||||||
else
|
else
|
||||||
Version::NULL
|
Version::NULL
|
||||||
end
|
end
|
||||||
@ -86,8 +90,9 @@ class DevelopmentTools
|
|||||||
(@non_apple_gcc_version ||= {}).fetch(cc) do
|
(@non_apple_gcc_version ||= {}).fetch(cc) do
|
||||||
path = HOMEBREW_PREFIX.join("opt", "gcc", "bin", cc)
|
path = HOMEBREW_PREFIX.join("opt", "gcc", "bin", cc)
|
||||||
path = locate(cc) unless path.exist?
|
path = locate(cc) unless path.exist?
|
||||||
version = if path
|
version = if path &&
|
||||||
Version.new(`#{path} --version`[/gcc(?:-\d(?:\.\d)? \(.+\))? (\d\.\d\.\d)/, 1])
|
build_version = `#{path} --version`[/gcc(?:-\d(?:\.\d)? \(.+\))? (\d\.\d\.\d)/, 1]
|
||||||
|
Version.new build_version
|
||||||
else
|
else
|
||||||
Version::NULL
|
Version::NULL
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user