From ef1d9c0cd04c21b5b19cae17e83bbdc6ef28d712 Mon Sep 17 00:00:00 2001 From: Misty De Meo Date: Fri, 28 Jun 2013 01:38:09 -0500 Subject: 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. --- Library/Homebrew/extend/ENV/std.rb | 10 ++++++++++ Library/Homebrew/extend/ENV/super.rb | 7 +++++++ 2 files changed, 17 insertions(+) (limited to 'Library/Homebrew/extend') diff --git a/Library/Homebrew/extend/ENV/std.rb b/Library/Homebrew/extend/ENV/std.rb index 67ab85952..e931b33ba 100644 --- a/Library/Homebrew/extend/ENV/std.rb +++ b/Library/Homebrew/extend/ENV/std.rb @@ -167,6 +167,16 @@ module Stdenv end alias_method :gcc_4_2, :gcc + GNU_GCC_VERSIONS.each do |n| + define_method(:"gcc-4.#{n}") do + gcc = "gcc-4.#{n}" + self.cc = self['OBJC'] = gcc + self.cxx = self['OBJCXX'] = gcc.gsub('c', '+') + set_cpu_cflags + @compiler = gcc + end + end + def llvm self.cc = MacOS.locate("llvm-gcc") self.cxx = MacOS.locate("llvm-g++") diff --git a/Library/Homebrew/extend/ENV/super.rb b/Library/Homebrew/extend/ENV/super.rb index 2b3957209..9ca88750c 100644 --- a/Library/Homebrew/extend/ENV/super.rb +++ b/Library/Homebrew/extend/ENV/super.rb @@ -266,6 +266,13 @@ module Superenv self.cc = self['HOMEBREW_CC'] = "clang" self.cxx = "clang++" end + GNU_GCC_VERSIONS.each do |n| + define_method(:"gcc-4.#{n}") do + gcc = "gcc-4.#{n}" + self.cc = self['HOMEBREW_CC'] = gcc + self.cxx = gcc.gsub('c', '+') + end + end def make_jobs self['MAKEFLAGS'] =~ /-\w*j(\d)+/ [$1.to_i, 1].max -- cgit v1.2.3