Provide reusable GNU GCC constants in ENV

This commit is contained in:
Misty De Meo 2013-08-22 22:29:49 -07:00
parent 11f8b2f49c
commit 71268b7f16
2 changed files with 11 additions and 4 deletions

View File

@ -2,7 +2,10 @@ module SharedEnvExtension
CC_FLAG_VARS = %w{CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS}
FC_FLAG_VARS = %w{FCFLAGS FFLAGS}
COMPILERS = ['clang', 'gcc-4.0', 'gcc-4.2', 'llvm-gcc', /(gcc-\d\.\d)/]
# Update these every time a new GNU GCC branch is released
GNU_GCC_VERSIONS = (3..9)
GNU_GCC_REGEXP = /gcc-(4\.[3-9])/
COMPLER_ALIASES = {'gcc' => 'gcc-4.2', 'llvm' => 'llvm-gcc'}
COMPILER_SYMBOL_MAP = { 'gcc-4.0' => :gcc_4_0,
'gcc-4.2' => :gcc,
@ -80,8 +83,12 @@ module SharedEnvExtension
def compiler
if (cc = ARGV.cc)
raise("Invalid value for --cc: #{cc}") if COMPILERS.grep(cc).empty?
COMPILER_SYMBOL_MAP.fetch(cc, cc)
COMPILER_SYMBOL_MAP.fetch(cc) do |other|
if other =~ GNU_GCC_REGEXP then other
else
raise "Invalid value for --cc: #{other}"
end
end
elsif ARGV.include? '--use-gcc'
gcc_installed = Formula.factory('apple-gcc42').installed? rescue false
# fall back to something else on systems without Apple gcc

View File

@ -110,7 +110,7 @@ module Superenv
append_path('PATH', apple_gcc42.opt_prefix/'bin') if apple_gcc42
end
if ENV['HOMEBREW_CC'] =~ /gcc-(\d\.\d)/ && $1 != '4.2'
if ENV['HOMEBREW_CC'] =~ GNU_GCC_REGEXP
warn_about_non_apple_gcc($1)
end
end