diff options
| author | Misty De Meo | 2013-09-28 12:21:16 -0700 | 
|---|---|---|
| committer | Misty De Meo | 2013-12-03 22:42:49 -0800 | 
| commit | 6647e4922533347cec7fb140818ecd0748209318 (patch) | |
| tree | 712b4c9698d4847939250f54adb0878141edd788 /Library/Homebrew/compilers.rb | |
| parent | e90d50f82cf7236339b539497316f1630e27b3da (diff) | |
| download | homebrew-6647e4922533347cec7fb140818ecd0748209318.tar.bz2 | |
Adjust fails_with syntax for non-Apple compilers
The old version worked like this:
fails_with :gcc => '4.8.1'
That wasn't really flexible enough, and made it harder to distinguish
different releases in the same GCC series. Since no one was really
using it yet, this adjusts the syntax to be more similar to the
Apple compilers:
fails_with :gcc => '4.8' do
  release '4.8.1'
end
Like with Apple compilers, omitting `release` blacklists the entire
series.
This also unifies the `build` and `version` attributes and accessors,
and exposes them under both names.
Diffstat (limited to 'Library/Homebrew/compilers.rb')
| -rw-r--r-- | Library/Homebrew/compilers.rb | 43 | 
1 files changed, 34 insertions, 9 deletions
| diff --git a/Library/Homebrew/compilers.rb b/Library/Homebrew/compilers.rb index 9561fc0fb..cb7d74334 100644 --- a/Library/Homebrew/compilers.rb +++ b/Library/Homebrew/compilers.rb @@ -1,30 +1,55 @@  class Compiler < Struct.new(:name, :priority) -  def build -    MacOS.send("#{name}_build_version") +  # The full version of the compiler for comparison purposes. +  def version +    if name.is_a? String +      MacOS.non_apple_gcc_version(name) +    else +      MacOS.send("#{name}_build_version") +    end    end -  def version -    MacOS.non_apple_gcc_version(name) if name.is_a? String +  # This is exposed under the `build` name for compatibility, since +  # `fails_with` continues to use `build` in the public API. +  # `build` indicates the build number of an Apple compiler. +  # This is preferred over version numbers since there are often +  # significant differences within the same version, +  # e.g. GCC 4.2 build 5553 vs 5666. +  # Non-Apple compilers don't have build numbers. +  alias_method :build, :version + +  # The major version for non-Apple compilers. Used to indicate a compiler +  # series; for instance, if the version is 4.8.2, it would return "4.8". +  def major_version +    version.match(/(\d\.\d)/)[0] if name.is_a? String    end  end  class CompilerFailure -  attr_reader :compiler, :version -  attr_rw :build, :cause +  attr_reader :compiler, :major_version +  attr_rw :cause, :version    def initialize compiler, &block      # Non-Apple compilers are in the format fails_with compiler => version      if compiler.is_a? Hash        # currently the only compiler for this case is GCC -      _, @version = compiler.shift -      @compiler = 'gcc-' + @version.match(/(\d\.\d)/)[0] +      _, @major_version = compiler.shift +      @compiler = 'gcc-' + @major_version      else        @compiler = compiler      end      instance_eval(&block) if block_given? -    @build = (@build || 9999).to_i unless compiler.is_a? Hash +    if !compiler.is_a? Hash +      @version = (@version || 9999).to_i +    else +      # so fails_with :gcc => '4.8' simply marks all 4.8 releases incompatible +      @version ||= @major_version + '.999' if compiler.is_a? Hash +    end    end + +  # Allows Apple compiler `fails_with` statements to keep using `build` +  # even though `build` and `value` are the same internally +  alias_method :build, :version  end  class CompilerQueue | 
