diff options
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 |
