Class: DevelopmentTools
Overview
Helper class for gathering information about development tools.
Class Method Summary collapse
- .build_system_info ⇒ Hash{String => String, nil} private
 - .ca_file_handles_most_https_certificates? ⇒ Boolean private
 - .ca_file_substitution_required? ⇒ Boolean private
 - 
  
    
      .clang_build_version  ⇒ Version 
    
    
  
  
  
  
  
  
  
  
  
    
Get the Clang build version.
 - 
  
    
      .clang_version  ⇒ Version 
    
    
  
  
  
  
  
  
  
  
  
    
Get the Clang version.
 - .clear_version_cache ⇒ void private
 - .curl_handles_most_https_certificates? ⇒ Boolean private
 - .curl_substitution_required? ⇒ Boolean private
 - .custom_installation_instructions ⇒ String private
 - 
  
    
      .default_compiler  ⇒ Symbol 
    
    
  
  
  
  
  
  
  
  
  
    
Get the default C compiler.
 - 
  
    
      .gcc_version(cc = host_gcc_path.to_s)  ⇒ Version 
    
    
  
  
  
  
  
  
  
  
  
    
Get the GCC version.
 - .host_gcc_path ⇒ Pathname private
 - .insecure_download_warning(resource) ⇒ String private
 - .installation_instructions ⇒ String private
 - .installed? ⇒ Boolean private
 - .ld64_version ⇒ Version private
 - 
  
    
      .llvm_clang_build_version  ⇒ Version 
    
    
  
  
  
  
  
  
  
  
  
    
Get the LLVM Clang build version.
 - 
  
    
      .locate(tool)  ⇒ Pathname? 
    
    
  
  
  
  
  
  
  
  
  
    
Locate a development tool.
 - .needs_build_formulae? ⇒ Boolean private
 - .needs_compiler_formula? ⇒ Boolean private
 - .needs_libc_formula? ⇒ Boolean private
 - .subversion_handles_most_https_certificates? ⇒ Boolean private
 
Class Method Details
.build_system_info ⇒ Hash{String => String, nil}
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
      185 186 187 188 189 190 191  | 
    
      # File 'development_tools.rb', line 185 def build_system_info { "os" => HOMEBREW_SYSTEM, "os_version" => OS_VERSION, "cpu_family" => Hardware::CPU.family.to_s, } end  | 
  
.ca_file_handles_most_https_certificates? ⇒ Boolean
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
      157 158 159 160 161  | 
    
      # File 'development_tools.rb', line 157 def ca_file_handles_most_https_certificates? # The system CA file is too old for some modern HTTPS certificates on # older OS versions. ENV["HOMEBREW_SYSTEM_CA_CERTIFICATES_TOO_OLD"].nil? end  | 
  
.ca_file_substitution_required? ⇒ Boolean
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
      169 170 171 172  | 
    
      # File 'development_tools.rb', line 169 def ca_file_substitution_required? (!ca_file_handles_most_https_certificates? || ENV["HOMEBREW_FORCE_BREWED_CA_CERTIFICATES"].present?) && !(HOMEBREW_PREFIX/"etc/ca-certificates/cert.pem").exist? end  | 
  
.clang_build_version ⇒ Version
Get the Clang build version.
      84 85 86 87 88 89 90 91 92 93  | 
    
      # File 'development_tools.rb', line 84 def clang_build_version @clang_build_version ||= T.let( if (path = locate("clang")) && (build_version = `#{path} --version`[%r{clang(-| version [^ ]+ \(tags/RELEASE_)(\d{2,})}, 2]) Version.new(build_version) else Version::NULL end, T.nilable(Version) ) end  | 
  
.clang_version ⇒ Version
Get the Clang version.
      69 70 71 72 73 74 75 76 77 78  | 
    
      # File 'development_tools.rb', line 69 def clang_version @clang_version ||= T.let( if (path = locate("clang")) && (build_version = `#{path} --version`[/(?:clang|LLVM) version (\d+\.\d(?:\.\d)?)/, 1]) Version.new(build_version) else Version::NULL end, T.nilable(Version) ) end  | 
  
.clear_version_cache ⇒ void
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
This method returns an undefined value.
      136 137 138 139  | 
    
      # File 'development_tools.rb', line 136 def clear_version_cache @clang_version = @clang_build_version = T.let(nil, T.nilable(Version)) @gcc_version = T.let({}, T.nilable(T::Hash[String, Version])) end  | 
  
.curl_handles_most_https_certificates? ⇒ Boolean
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
      164 165 166  | 
    
      # File 'development_tools.rb', line 164 def curl_handles_most_https_certificates? true end  | 
  
.curl_substitution_required? ⇒ Boolean
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
      175 176 177  | 
    
      # File 'development_tools.rb', line 175 def curl_substitution_required? !curl_handles_most_https_certificates? && !HOMEBREW_BREWED_CURL_PATH.exist? end  | 
  
.custom_installation_instructions ⇒ String
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
      40 41 42  | 
    
      # File 'development_tools.rb', line 40 def custom_installation_instructions installation_instructions end  | 
  
.default_compiler ⇒ Symbol
Get the default C compiler.
      56 57 58  | 
    
      # File 'development_tools.rb', line 56 def default_compiler :clang end  | 
  
.gcc_version(cc = host_gcc_path.to_s) ⇒ Version
Get the GCC version.
      121 122 123 124 125 126 127 128 129 130 131 132 133  | 
    
      # File 'development_tools.rb', line 121 def gcc_version(cc = host_gcc_path.to_s) (@gcc_version ||= T.let({}, T.nilable(T::Hash[String, Version]))).fetch(cc) do path = HOMEBREW_PREFIX/"opt/#{CompilerSelector.preferred_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 @gcc_version[cc] = version end end  | 
  
.host_gcc_path ⇒ Pathname
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
      113 114 115  | 
    
      # File 'development_tools.rb', line 113 def host_gcc_path Pathname.new("/usr/bin/gcc") end  | 
  
.insecure_download_warning(resource) ⇒ String
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
      45 46 47 48 49 50  | 
    
      # File 'development_tools.rb', line 45 def insecure_download_warning(resource) package = curl_handles_most_https_certificates? ? "ca-certificates" : "curl" "Using `--insecure` with curl to download #{resource} because we need it to run " \ "`brew install #{package}` in order to download securely from now on. " \ "Checksums will still be verified." end  | 
  
.installation_instructions ⇒ String
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
      35 36 37  | 
    
      # File 'development_tools.rb', line 35 def installation_instructions "Install Clang or run `brew install gcc`." end  | 
  
.installed? ⇒ Boolean
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
      30 31 32  | 
    
      # File 'development_tools.rb', line 30 def installed? locate("clang").present? || locate("gcc").present? end  | 
  
.ld64_version ⇒ Version
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
      61 62 63  | 
    
      # File 'development_tools.rb', line 61 def ld64_version Version::NULL end  | 
  
.llvm_clang_build_version ⇒ Version
Get the LLVM Clang build version.
      99 100 101 102 103 104 105 106 107 108 109 110  | 
    
      # File 'development_tools.rb', line 99 def llvm_clang_build_version @llvm_clang_build_version ||= T.let(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 rescue FormulaUnavailableError Version::NULL end, T.nilable(Version)) end  | 
  
.locate(tool) ⇒ Pathname?
Locate a development tool.
      15 16 17 18 19 20 21 22 23 24 25 26 27  | 
    
      # File 'development_tools.rb', line 15 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 ||= T.let({}, T.nilable(T::Hash[T.any(String, Symbol), T.untyped]))).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  | 
  
.needs_build_formulae? ⇒ Boolean
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
      142 143 144  | 
    
      # File 'development_tools.rb', line 142 def needs_build_formulae? needs_libc_formula? || needs_compiler_formula? end  | 
  
.needs_compiler_formula? ⇒ Boolean
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
      152 153 154  | 
    
      # File 'development_tools.rb', line 152 def needs_compiler_formula? false end  | 
  
.needs_libc_formula? ⇒ Boolean
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
      147 148 149  | 
    
      # File 'development_tools.rb', line 147 def needs_libc_formula? false end  | 
  
.subversion_handles_most_https_certificates? ⇒ Boolean
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
      180 181 182  | 
    
      # File 'development_tools.rb', line 180 def subversion_handles_most_https_certificates? true end  |