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.
 { clang: [:clang, :llvm_clang, :gnu], gcc: [:gnu, :gcc, :llvm_clang, :clang], }.freeze
Constants included from CompilerConstants
CompilerConstants::COMPILERS, CompilerConstants::COMPILER_SYMBOL_MAP, CompilerConstants::GNU_GCC_REGEXP, CompilerConstants::GNU_GCC_VERSIONS
Instance Attribute Summary collapse
- #compilers ⇒ Object readonly private
 - #failures ⇒ Object readonly private
 - #formula ⇒ Object readonly private
 - #versions ⇒ Object readonly private
 
Class Method Summary collapse
- .compilers ⇒ Object private
 - .preferred_gcc ⇒ String private
 - .select_for(formula, compilers = nil, testing_formula: false) ⇒ Object private
 
Instance Method Summary collapse
- #compiler ⇒ Object private
 - 
  
    
      #initialize(formula, versions, compilers)  ⇒ CompilerSelector 
    
    
  
  
  
    constructor
  
  
  
  
  
  private
  
    
A new instance of CompilerSelector.
 
Constructor Details
#initialize(formula, versions, compilers) ⇒ CompilerSelector
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.
Returns a new instance of CompilerSelector.
      125 126 127 128 129 130  | 
    
      # File 'compilers.rb', line 125 def initialize(formula, versions, compilers) @formula = formula @failures = formula.compiler_failures @versions = versions @compilers = compilers end  | 
  
Instance Attribute Details
#compilers ⇒ Object (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.
      123 124 125  | 
    
      # File 'compilers.rb', line 123 def compilers @compilers end  | 
  
#failures ⇒ Object (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.
      123 124 125  | 
    
      # File 'compilers.rb', line 123 def failures @failures end  | 
  
#formula ⇒ Object (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.
      123 124 125  | 
    
      # File 'compilers.rb', line 123 def formula @formula end  | 
  
#versions ⇒ Object (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.
      123 124 125  | 
    
      # File 'compilers.rb', line 123 def versions @versions end  | 
  
Class Method Details
.compilers ⇒ Object
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.
      119 120 121  | 
    
      # File 'compilers.rb', line 119 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.
      138 139 140  | 
    
      # File 'compilers.rb', line 138 def self.preferred_gcc "gcc" end  | 
  
.select_for(formula, compilers = nil, testing_formula: false) ⇒ Object
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.
      109 110 111 112 113 114 115 116 117  | 
    
      # File 'compilers.rb', line 109 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 ⇒ Object
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.
      132 133 134 135  | 
    
      # File 'compilers.rb', line 132 def compiler find_compiler { |c| return c.name unless fails_with?(c) } raise CompilerSelectionError, formula end  |