Class: CompilerSelector

Inherits:
Object
  • Object
show all
Includes:
CompilerConstants
Defined in:
Library/Homebrew/compilers.rb

Defined Under Namespace

Classes: Compiler

Constant Summary collapse

COMPILER_PRIORITY =
{
  clang: [:clang, :gcc_4_2, :gnu, :gcc_4_0, :llvm_clang],
  gcc_4_2: [:gcc_4_2, :gnu, :clang, :gcc_4_0],
  gcc_4_0: [:gcc_4_0, :gcc_4_2, :gnu, :clang],
}.freeze

Constants included from CompilerConstants

CompilerConstants::COMPILERS, CompilerConstants::COMPILER_SYMBOL_MAP, CompilerConstants::GNU_GCC_REGEXP, CompilerConstants::GNU_GCC_VERSIONS

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(formula, versions, compilers) ⇒ CompilerSelector

Returns a new instance of CompilerSelector



116
117
118
119
120
121
# File 'Library/Homebrew/compilers.rb', line 116

def initialize(formula, versions, compilers)
  @formula = formula
  @failures = formula.compiler_failures
  @versions = versions
  @compilers = compilers
end

Instance Attribute Details

#compilersObject (readonly)

Returns the value of attribute compilers



114
115
116
# File 'Library/Homebrew/compilers.rb', line 114

def compilers
  @compilers
end

#failuresObject (readonly)

Returns the value of attribute failures



114
115
116
# File 'Library/Homebrew/compilers.rb', line 114

def failures
  @failures
end

#formulaObject (readonly)

Returns the value of attribute formula



114
115
116
# File 'Library/Homebrew/compilers.rb', line 114

def formula
  @formula
end

#versionsObject (readonly)

Returns the value of attribute versions



114
115
116
# File 'Library/Homebrew/compilers.rb', line 114

def versions
  @versions
end

Class Method Details

.compilersObject



110
111
112
# File 'Library/Homebrew/compilers.rb', line 110

def self.compilers
  COMPILER_PRIORITY.fetch(DevelopmentTools.default_compiler)
end

.select_for(formula, compilers = self.compilers) ⇒ Object



106
107
108
# File 'Library/Homebrew/compilers.rb', line 106

def self.select_for(formula, compilers = self.compilers)
  new(formula, DevelopmentTools, compilers).compiler
end

Instance Method Details

#compilerObject



123
124
125
126
# File 'Library/Homebrew/compilers.rb', line 123

def compiler
  find_compiler { |c| return c.name unless fails_with?(c) }
  raise CompilerSelectionError, formula
end