Move more methods to DevelopmentTools.

Closes #1028.
This commit is contained in:
Mike McQuaid 2016-05-10 08:19:48 +01:00
parent 500f9eada8
commit 5c1f463ac0
3 changed files with 16 additions and 16 deletions

View File

@ -469,7 +469,7 @@ module Homebrew
unless installed_gcc
run_as_not_developer { test "brew", "install", "gcc" }
installed_gcc = true
OS::Mac.clear_version_cache
DevelopmentTools.clear_version_cache
retry
end
skip formula_name

View File

@ -74,6 +74,21 @@ class DevelopmentTools
`#{path} --version`[/clang-(\d{2,})/, 1].to_i
end
end
def non_apple_gcc_version(cc)
(@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
@non_apple_gcc_version[cc] = version
end
end
def clear_version_cache
@gcc_40_build_version = @gcc_42_build_version = @llvm_build_version = nil
@clang_version = @clang_build_version = nil
@non_apple_gcc_version = {}
end
end
end

View File

@ -109,21 +109,6 @@ module OS
s.path unless s.nil?
end
def non_apple_gcc_version(cc)
(@non_apple_gcc_version ||= {}).fetch(cc) do
path = HOMEBREW_PREFIX.join("opt", "gcc", "bin", cc)
path = DevelopmentTools.locate(cc) unless path.exist?
version = `#{path} --version`[/gcc(?:-\d(?:\.\d)? \(.+\))? (\d\.\d\.\d)/, 1] if path
@non_apple_gcc_version[cc] = version
end
end
def clear_version_cache
@gcc_40_build_version = @gcc_42_build_version = @llvm_build_version = nil
@clang_version = @clang_build_version = nil
@non_apple_gcc_version = {}
end
# See these issues for some history:
# https://github.com/Homebrew/legacy-homebrew/issues/13
# https://github.com/Homebrew/legacy-homebrew/issues/41