Class: CompilerSelector Private

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
extend/os/linux/compilers.rb,
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, :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

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.



123
124
125
126
127
128
# File 'compilers.rb', line 123

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

Instance Attribute Details

#compilersObject (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.



121
122
123
# File 'compilers.rb', line 121

def compilers
  @compilers
end

#failuresObject (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.



121
122
123
# File 'compilers.rb', line 121

def failures
  @failures
end

#formulaObject (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.



121
122
123
# File 'compilers.rb', line 121

def formula
  @formula
end

#versionsObject (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.



121
122
123
# File 'compilers.rb', line 121

def versions
  @versions
end

Class Method Details

.compilersObject

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.



117
118
119
# File 'compilers.rb', line 117

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

.preferred_gccString

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:



6
7
8
9
10
# File 'extend/os/linux/compilers.rb', line 6

def self.preferred_gcc
  # gcc-5 is the lowest gcc version we support on Linux.
  # gcc-5 is the default gcc in Ubuntu 16.04 (used for our CI)
  "gcc@5"
end

.select_for(formula, compilers = self.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.



113
114
115
# File 'compilers.rb', line 113

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

Instance Method Details

#compilerObject

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.



130
131
132
133
# File 'compilers.rb', line 130

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