Class: CompilerFailure Private

Inherits:
Object
  • Object
show all
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 checking compiler compatibility for a formula.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

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



22
23
24
# File 'compilers.rb', line 22

def type
  @type
end

Class Method Details

.create(spec, &block) ⇒ 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.



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'compilers.rb', line 42

def self.create(spec, &block)
  # Non-Apple compilers are in the format fails_with compiler => version
  if spec.is_a?(Hash)
    compiler, major_version = spec.first
    raise ArgumentError, "The hash `fails_with` syntax only supports GCC" if compiler != :gcc

    type = compiler
    # so fails_with :gcc => '7' simply marks all 7 releases incompatible
    version = "#{major_version}.999"
    exact_major_match = true
  else
    type = spec
    version = 9999
    exact_major_match = false
  end
  new(type, version, exact_major_match: exact_major_match, &block)
end

.for_standard(standard) ⇒ 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.



36
37
38
39
40
# File 'compilers.rb', line 36

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. 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.

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



34
# File 'compilers.rb', line 34

def cause(_); end

#fails_with?(compiler) ⇒ Boolean

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:

  • (Boolean)


60
61
62
63
64
65
66
67
68
69
# File 'compilers.rb', line 60

def fails_with?(compiler)
  version_matched = if type != :gcc
    version >= compiler.version
  elsif @exact_major_match
    gcc_major(version) == gcc_major(compiler.version) && version >= compiler.version
  else
    gcc_major(version) >= gcc_major(compiler.version)
  end
  type == compiler.type && version_matched
end

#inspectObject

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.



71
72
73
# File 'compilers.rb', line 71

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

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

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.



24
25
26
27
# File 'compilers.rb', line 24

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