Class: CompilerSelector Private
- Includes:
- CompilerConstants
- Defined in:
- compilers.rb
Overview
This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.
Class for selecting a compiler for a formula.
Defined Under Namespace
Classes: Compiler
Constant Summary collapse
- COMPILER_PRIORITY =
This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.
T.let({ clang: [:clang, :llvm_clang, :gnu], gcc: [:gnu, :gcc, :llvm_clang, :clang], }.freeze, T::Hash[Symbol, T::Array[Symbol]])
Constants included from CompilerConstants
CompilerConstants::COMPILERS, CompilerConstants::COMPILER_SYMBOL_MAP, CompilerConstants::GNU_GCC_REGEXP, CompilerConstants::GNU_GCC_VERSIONS
Instance Attribute Summary collapse
- #compilers ⇒ Array<Symbol> readonly private
- #failures ⇒ Array<CompilerFailure> readonly private
- #formula ⇒ Formula, SoftwareSpec readonly private
- #versions ⇒ T.class_of(DevelopmentTools) readonly private
Class Method Summary collapse
- .compilers ⇒ Array<Symbol> private
- .preferred_gcc ⇒ String private
- .select_for(formula, compilers = nil, testing_formula: false) ⇒ String, Symbol private
Instance Method Summary collapse
- #compiler ⇒ String, Symbol private
- #initialize(formula, versions, compilers) ⇒ void constructor private
Constructor Details
#initialize(formula, versions, compilers) ⇒ 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.
152 153 154 155 156 157 |
# File 'compilers.rb', line 152 def initialize(formula, versions, compilers) @formula = formula @failures = T.let(formula.compiler_failures, T::Array[CompilerFailure]) @versions = versions @compilers = compilers end |
Instance Attribute Details
#compilers ⇒ Array<Symbol> (readonly)
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.
143 144 145 |
# File 'compilers.rb', line 143 def compilers @compilers end |
#failures ⇒ Array<CompilerFailure> (readonly)
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.
137 138 139 |
# File 'compilers.rb', line 137 def failures @failures end |
#formula ⇒ Formula, SoftwareSpec (readonly)
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.
134 135 136 |
# File 'compilers.rb', line 134 def formula @formula end |
#versions ⇒ T.class_of(DevelopmentTools) (readonly)
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.
140 141 142 |
# File 'compilers.rb', line 140 def versions @versions end |
Class Method Details
.compilers ⇒ Array<Symbol>
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.
129 130 131 |
# File 'compilers.rb', line 129 def self.compilers COMPILER_PRIORITY.fetch(DevelopmentTools.default_compiler) end |
.preferred_gcc ⇒ 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.
166 167 168 |
# File 'compilers.rb', line 166 def self.preferred_gcc "gcc" end |
.select_for(formula, compilers = nil, testing_formula: false) ⇒ String, Symbol
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.
118 119 120 121 122 123 124 125 126 |
# File 'compilers.rb', line 118 def self.select_for(formula, compilers = nil, testing_formula: false) if compilers.nil? && DevelopmentTools.default_compiler == :clang deps = formula.deps.filter_map do |dep| dep.name if dep.required? || (testing_formula && dep.test?) || (!testing_formula && dep.build?) end compilers = [:clang, :gnu, :llvm_clang] if deps.none?("llvm") && deps.any?(/^gcc(@\d+)?$/) end new(formula, DevelopmentTools, compilers || self.compilers).compiler end |
Instance Method Details
#compiler ⇒ String, Symbol
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.
160 161 162 163 |
# File 'compilers.rb', line 160 def compiler find_compiler { |c| return c.name unless fails_with?(c) } raise CompilerSelectionError, formula end |