Class: CompilerFailure Private

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



19
20
21
# File 'compilers.rb', line 19

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.



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'compilers.rb', line 39

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:, &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.



33
34
35
36
37
# File 'compilers.rb', line 33

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.



31
# File 'compilers.rb', line 31

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)


57
58
59
60
61
62
63
64
65
66
# File 'compilers.rb', line 57

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

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



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

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