aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/development_tools.rb
diff options
context:
space:
mode:
authorMike McQuaid2016-11-15 14:43:56 +0000
committerMike McQuaid2016-11-15 14:43:56 +0000
commit727263e90620b1edabffdb6444018d08f8c43fda (patch)
tree90dcdcf13c82379f694d0845f18da1bf9138d79a /Library/Homebrew/development_tools.rb
parentc1af8fba55dc2bdee54c41cb1e0dfe327ddf1084 (diff)
downloadbrew-727263e90620b1edabffdb6444018d08f8c43fda.tar.bz2
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.
Diffstat (limited to 'Library/Homebrew/development_tools.rb')
-rw-r--r--Library/Homebrew/development_tools.rb25
1 files changed, 15 insertions, 10 deletions
diff --git a/Library/Homebrew/development_tools.rb b/Library/Homebrew/development_tools.rb
index febe04b21..62f9b3d71 100644
--- a/Library/Homebrew/development_tools.rb
+++ b/Library/Homebrew/development_tools.rb
@@ -43,8 +43,9 @@ class DevelopmentTools
def gcc_40_build_version
@gcc_40_build_version ||=
- if (path = locate("gcc-4.0"))
- Version.new `#{path} --version 2>/dev/null`[/build (\d{4,})/, 1].to_i
+ if (path = locate("gcc-4.0")) &&
+ build_version = `#{path} --version 2>/dev/null`[/build (\d{4,})/, 1]
+ Version.new build_version
else
Version::NULL
end
@@ -55,8 +56,9 @@ class DevelopmentTools
@gcc_42_build_version ||=
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")
- Version.new `#{gcc} --version 2>/dev/null`[/build (\d{4,})/, 1]
+ if gcc.exist? && !gcc.realpath.basename.to_s.start_with?("llvm")&&
+ build_version = `#{gcc} --version 2>/dev/null`[/build (\d{4,})/, 1]
+ Version.new build_version
else
Version::NULL
end
@@ -66,8 +68,9 @@ class DevelopmentTools
def clang_version
@clang_version ||=
- if (path = locate("clang"))
- Version.new `#{path} --version`[/(?:clang|LLVM) version (\d\.\d)/, 1]
+ if (path = locate("clang")) &&
+ build_version = `#{path} --version`[/(?:clang|LLVM) version (\d\.\d)/, 1]
+ Version.new build_version
else
Version::NULL
end
@@ -75,8 +78,9 @@ class DevelopmentTools
def clang_build_version
@clang_build_version ||=
- if (path = locate("clang"))
- Version.new `#{path} --version`[/clang-(\d{2,})/, 1]
+ if (path = locate("clang")) &&
+ build_version = `#{path} --version`[/clang-(\d{2,})/, 1]
+ Version.new build_version
else
Version::NULL
end
@@ -86,8 +90,9 @@ class DevelopmentTools
(@non_apple_gcc_version ||= {}).fetch(cc) do
path = HOMEBREW_PREFIX.join("opt", "gcc", "bin", cc)
path = locate(cc) unless path.exist?
- version = if path
- Version.new(`#{path} --version`[/gcc(?:-\d(?:\.\d)? \(.+\))? (\d\.\d\.\d)/, 1])
+ version = if path &&
+ build_version = `#{path} --version`[/gcc(?:-\d(?:\.\d)? \(.+\))? (\d\.\d\.\d)/, 1]
+ Version.new build_version
else
Version::NULL
end