Class: CompilerSelector

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

Defined Under Namespace

Classes: Compiler

Constant Summary collapse

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

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



93
94
95
96
97
98
# File 'brew/Library/Homebrew/compilers.rb', line 93

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



91
92
93
# File 'brew/Library/Homebrew/compilers.rb', line 91

def compilers
  @compilers
end

#failuresObject (readonly)

Returns the value of attribute failures



91
92
93
# File 'brew/Library/Homebrew/compilers.rb', line 91

def failures
  @failures
end

#formulaObject (readonly)

Returns the value of attribute formula



91
92
93
# File 'brew/Library/Homebrew/compilers.rb', line 91

def formula
  @formula
end

#versionsObject (readonly)

Returns the value of attribute versions



91
92
93
# File 'brew/Library/Homebrew/compilers.rb', line 91

def versions
  @versions
end

Class Method Details

.compilersObject



87
88
89
# File 'brew/Library/Homebrew/compilers.rb', line 87

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

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



83
84
85
# File 'brew/Library/Homebrew/compilers.rb', line 83

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

Instance Method Details

#compilerObject



100
101
102
103
# File 'brew/Library/Homebrew/compilers.rb', line 100

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