Class: CompilerSelector Private
- Includes:
- CompilerConstants
- Defined in:
- compilers/compiler_selector.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.
57 58 59 60 61 62 |
# File 'compilers/compiler_selector.rb', line 57 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.
48 49 50 |
# File 'compilers/compiler_selector.rb', line 48 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.
42 43 44 |
# File 'compilers/compiler_selector.rb', line 42 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.
39 40 41 |
# File 'compilers/compiler_selector.rb', line 39 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.
45 46 47 |
# File 'compilers/compiler_selector.rb', line 45 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.
34 35 36 |
# File 'compilers/compiler_selector.rb', line 34 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.
71 72 73 |
# File 'compilers/compiler_selector.rb', line 71 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.
23 24 25 26 27 28 29 30 31 |
# File 'compilers/compiler_selector.rb', line 23 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.
65 66 67 68 |
# File 'compilers/compiler_selector.rb', line 65 def compiler find_compiler { |c| return c.name unless fails_with?(c) } raise CompilerSelectionError, formula end |