Class: DevelopmentTools
- Inherits:
-
Object
- Object
- DevelopmentTools
- Defined in:
- Library/Homebrew/development_tools.rb,
Library/Homebrew/extend/os/mac/development_tools.rb,
Library/Homebrew/extend/os/linux/development_tools.rb
Overview
typed: true frozen_string_literal: true
Class Method Summary collapse
- .build_system_info ⇒ Object
- .clang_build_version ⇒ Object
- .clang_version ⇒ Object
- .clear_version_cache ⇒ Object
- .curl_handles_most_https_certificates? ⇒ Boolean
- .custom_installation_instructions ⇒ Object
- .default_cc ⇒ Object
- .default_compiler ⇒ Object
- .generic_build_system_info ⇒ Object
- .generic_locate ⇒ Object
- .installation_instructions ⇒ Object
-
.installed? ⇒ Boolean
Checks if the user has any developer tools installed, either via Xcode or the CLT.
- .llvm_clang_build_version ⇒ Object
- .locate(tool) ⇒ Object
- .non_apple_gcc_version(cc) ⇒ Object
- .subversion_handles_most_https_certificates? ⇒ Boolean
Class Method Details
.build_system_info ⇒ Object
104 105 106 107 108 109 110 |
# File 'Library/Homebrew/development_tools.rb', line 104 def build_system_info { "os" => ENV["HOMEBREW_SYSTEM"], "os_version" => OS_VERSION, "cpu_family" => Hardware::CPU.family, } end |
.clang_build_version ⇒ Object
54 55 56 57 58 59 60 61 62 63 |
# File 'Library/Homebrew/development_tools.rb', line 54 def clang_build_version @clang_build_version ||= begin if (path = locate("clang")) && build_version = `#{path} --version`[%r{clang(-| version [^ ]+ \(tags/RELEASE_)(\d{2,})}, 2] Version.new build_version else Version::NULL end end end |
.clang_version ⇒ Object
43 44 45 46 47 48 49 50 51 52 |
# File 'Library/Homebrew/development_tools.rb', line 43 def clang_version @clang_version ||= begin if (path = locate("clang")) && build_version = `#{path} --version`[/(?:clang|LLVM) version (\d+\.\d)/, 1] Version.new build_version else Version::NULL end end end |
.clear_version_cache ⇒ Object
91 92 93 94 |
# File 'Library/Homebrew/development_tools.rb', line 91 def clear_version_cache @clang_version = @clang_build_version = nil @non_apple_gcc_version = {} end |
.curl_handles_most_https_certificates? ⇒ Boolean
96 97 98 |
# File 'Library/Homebrew/development_tools.rb', line 96 def curl_handles_most_https_certificates? true end |
.custom_installation_instructions ⇒ Object
28 29 30 |
# File 'Library/Homebrew/development_tools.rb', line 28 def installation_instructions "Install Clang or run `brew install gcc`." end |
.default_cc ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'Library/Homebrew/development_tools.rb', line 30 def default_cc cc = DevelopmentTools.locate "cc" begin cc.realpath.basename.to_s rescue nil end end |
.default_compiler ⇒ Object
39 40 41 |
# File 'Library/Homebrew/development_tools.rb', line 39 def default_compiler :clang end |
.generic_build_system_info ⇒ Object
111 112 113 114 115 116 117 |
# File 'Library/Homebrew/development_tools.rb', line 111 def build_system_info { "os" => ENV["HOMEBREW_SYSTEM"], "os_version" => OS_VERSION, "cpu_family" => Hardware::CPU.family, } end |
.generic_locate ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'Library/Homebrew/extend/os/mac/development_tools.rb', line 9 def locate(tool) # Don't call tools (cc, make, strip, etc.) directly! # Give the name of the binary you look for as a string to this method # in order to get the full path back as a Pathname. (@locate ||= {}).fetch(tool) do |key| @locate[key] = if File.executable?(path = "/usr/bin/#{tool}") Pathname.new path # Homebrew GCCs most frequently; much faster to check this before xcrun elsif (path = HOMEBREW_PREFIX/"bin/#{tool}").executable? path end end end |
.installation_instructions ⇒ Object
25 26 27 |
# File 'Library/Homebrew/development_tools.rb', line 25 def installation_instructions "Install Clang or run `brew install gcc`." end |
.installed? ⇒ Boolean
Checks if the user has any developer tools installed, either via Xcode or the CLT. Convenient for guarding against formula builds when building is impossible.
27 28 29 |
# File 'Library/Homebrew/extend/os/mac/development_tools.rb', line 27 def installed? locate("clang") || locate("gcc") end |
.llvm_clang_build_version ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 |
# File 'Library/Homebrew/development_tools.rb', line 65 def llvm_clang_build_version @llvm_clang_build_version ||= begin path = Formulary.factory("llvm").opt_prefix/"bin/clang" if path.executable? && build_version = `#{path} --version`[/clang version (\d\.\d\.\d)/, 1] Version.new build_version else Version::NULL end end end |
.locate(tool) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'Library/Homebrew/development_tools.rb', line 7 def locate(tool) # Don't call tools (cc, make, strip, etc.) directly! # Give the name of the binary you look for as a string to this method # in order to get the full path back as a Pathname. (@locate ||= {}).fetch(tool) do |key| @locate[key] = if File.executable?(path = "/usr/bin/#{tool}") Pathname.new path # Homebrew GCCs most frequently; much faster to check this before xcrun elsif (path = HOMEBREW_PREFIX/"bin/#{tool}").executable? path end end end |
.non_apple_gcc_version(cc) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'Library/Homebrew/development_tools.rb', line 77 def non_apple_gcc_version(cc) (@non_apple_gcc_version ||= {}).fetch(cc) do path = HOMEBREW_PREFIX/"opt/gcc/bin"/cc path = locate(cc) unless path.exist? version = if path && build_version = `#{path} --version`[/gcc(?:(?:-\d+(?:\.\d)?)? \(.+\))? (\d+\.\d\.\d)/, 1] Version.new build_version else Version::NULL end @non_apple_gcc_version[cc] = version end end |
.subversion_handles_most_https_certificates? ⇒ Boolean
100 101 102 |
# File 'Library/Homebrew/development_tools.rb', line 100 def subversion_handles_most_https_certificates? true end |