Class: CompilerFailure Private

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

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Class for checking compiler compatibility for a formula.

Constant Summary collapse

COLLECTIONS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

{
  openmp: [
    create(:clang),
  ],
}.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, version, &block) ⇒ CompilerFailure

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of CompilerFailure.


55
56
57
58
59
# File 'Library/Homebrew/compilers.rb', line 55

def initialize(name, version, &block)
  @name = name
  @version = Version.parse(version.to_s)
  instance_eval(&block) if block_given?
end

Instance Attribute Details

#nameObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


21
22
23
# File 'Library/Homebrew/compilers.rb', line 21

def name
  @name
end

Class Method Details

.create(spec, &block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'Library/Homebrew/compilers.rb', line 41

def self.create(spec, &block)
  # Non-Apple compilers are in the format fails_with compiler => version
  if spec.is_a?(Hash)
    _, major_version = spec.first
    name = "gcc-#{major_version}"
    # so fails_with :gcc => '7' simply marks all 7 releases incompatible
    version = "#{major_version}.999"
  else
    name = spec
    version = 9999
  end
  new(name, version, &block)
end

.for_standard(standard) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


35
36
37
38
39
# File 'Library/Homebrew/compilers.rb', line 35

def self.for_standard(standard)
  COLLECTIONS.fetch(standard) do
    raise ArgumentError, "\"#{standard}\" is not a recognized standard"
  end
end

Instance Method Details

#cause(_) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The cause is no longer used so we need not hold a reference to the string


33
# File 'Library/Homebrew/compilers.rb', line 33

def cause(_); end

#fails_with?(compiler) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

61
62
63
# File 'Library/Homebrew/compilers.rb', line 61

def fails_with?(compiler)
  name == compiler.name && version >= compiler.version
end

#inspectObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


65
66
67
# File 'Library/Homebrew/compilers.rb', line 65

def inspect
  "#<#{self.class.name}: #{name} #{version}>"
end

#version(val = nil) ⇒ Object Also known as: build

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


23
24
25
26
# File 'Library/Homebrew/compilers.rb', line 23

def version(val = nil)
  @version = Version.parse(val.to_s) if val
  @version
end