Skip to content

Commit

Permalink
Remove unnecessary use of globals in compiler version methods
Browse files Browse the repository at this point in the history
  • Loading branch information
jacknagel committed Jul 21, 2013
1 parent ec8b5f6 commit 867f60b
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions Library/Homebrew/macos.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def locate tool
end
end


def dev_tools_path
@dev_tools_path ||= \
if File.exist? MacOS::CLT::STANDALONE_PKG_PATH and
Expand Down Expand Up @@ -107,19 +108,18 @@ def default_compiler
end

def gcc_40_build_version
@gcc_40_build_version ||= if locate("gcc-4.0")
`#{locate("gcc-4.0")} --version` =~ /build (\d{4,})/
$1.to_i
end
@gcc_40_build_version ||=
if (path = locate("gcc-4.0"))
%x{#{path} --version}[/build (\d{4,})/, 1]
end
end
alias_method :gcc_4_0_build_version, :gcc_40_build_version

def gcc_42_build_version
@gcc_42_build_version ||= if locate("gcc-4.2") \
and not locate("gcc-4.2").realpath.basename.to_s =~ /^llvm/
`#{locate("gcc-4.2")} --version` =~ /build (\d{4,})/
$1.to_i
end
@gcc_42_build_version ||=
if (path = locate("gcc-4.2")) && path.realpath.basename.to_s !~ /^llvm/
%x{#{path} --version}[/build (\d{4,})/, 1].to_i
end
end
alias_method :gcc_build_version, :gcc_42_build_version

Expand All @@ -133,17 +133,17 @@ def llvm_build_version
end

def clang_version
@clang_version ||= if locate("clang")
`#{locate("clang")} --version` =~ /(?:clang|LLVM) version (\d\.\d)/
$1
end
@clang_version ||=
if (path = locate("clang"))
%x{#{path} --version}[/(?:clang|LLVM) version (\d\.\d)/, 1]
end
end

def clang_build_version
@clang_build_version ||= if locate("clang")
`#{locate("clang")} --version` =~ %r[clang-(\d{2,})]
$1.to_i
end
@clang_build_version ||=
if (path = locate("clang"))
%x{#{path} --version}[%r[clang-(\d{2,})], 1]
end
end

# See these issues for some history:
Expand Down

0 comments on commit 867f60b

Please sign in to comment.