diff options
| author | Misty De Meo | 2013-06-28 01:38:09 -0500 |
|---|---|---|
| committer | Misty De Meo | 2013-09-01 13:19:13 -0700 |
| commit | ef1d9c0cd04c21b5b19cae17e83bbdc6ef28d712 (patch) | |
| tree | e65e63fa2b446cc0ec80694f2572acba589b70e7 /Library/Homebrew/compilers.rb | |
| parent | 71268b7f16f017a94304488e3b3cbc4c1ca3bfe7 (diff) | |
| download | brew-ef1d9c0cd04c21b5b19cae17e83bbdc6ef28d712.tar.bz2 | |
Implement fails_with for non-Apple compilers
This adds support for non-Apple GCC compilers in the fails_with code.
A fails_with block for a non-Apple compiler looks like:
fails_with :gcc => '4.8.1' do
cause 'Foo'
end
Non-Apple compilers don't have build numbers, so compiler failures are
based on version strings instead.
Internally non-Apple compilers can be distinguished because they are
passed around as strings instead of symbols.
In addition, this alters the priority list for compilers, with the
following changes:
* Apple GCC 4.2 and LLVM-GCC swap positions, with GCC now taking
priority. (Maybe LLVM-GCC should just go away.)
* Non-Apple GCC compilers are ranked below GCC 4.2 but above LLVM-GCC
and Apple GCC 4.0.
Diffstat (limited to 'Library/Homebrew/compilers.rb')
| -rw-r--r-- | Library/Homebrew/compilers.rb | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/Library/Homebrew/compilers.rb b/Library/Homebrew/compilers.rb index 3aaaecbc8..8eb6d56fb 100644 --- a/Library/Homebrew/compilers.rb +++ b/Library/Homebrew/compilers.rb @@ -2,16 +2,28 @@ class Compiler < Struct.new(:name, :priority) def build MacOS.send("#{name}_build_version") end + + def version + MacOS.non_apple_gcc_version(name) if name.is_a? String + end end class CompilerFailure - attr_reader :compiler + attr_reader :compiler, :version attr_rw :build, :cause def initialize compiler, &block - @compiler = compiler + # 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] + else + @compiler = compiler + end + instance_eval(&block) if block_given? - @build = (@build || 9999).to_i + @build = (@build || 9999).to_i unless compiler.is_a? Hash end end @@ -43,6 +55,14 @@ class CompilerSelector @compilers << Compiler.new(cc, priority_for(cc)) end end + + # non-Apple GCC 4.x + SharedEnvExtension::GNU_GCC_VERSIONS.each do |v| + unless MacOS.non_apple_gcc_version("gcc-4.#{v}").nil? + # priority is based on version, with newest preferred first + @compilers << Compiler.new("gcc-4.#{v}", 1.0 + v/10.0) + end + end end # Attempts to select an appropriate alternate compiler, but @@ -64,9 +84,11 @@ class CompilerSelector def priority_for(cc) case cc when :clang then MacOS.clang_build_version >= 318 ? 3 : 0.5 - when :llvm then 2 - when :gcc then 1 + when :gcc then 2 + when :llvm then 1 when :gcc_4_0 then 0.25 + # non-Apple gcc compilers + else 1.5 end end end |
