diff options
| author | Mike McQuaid | 2014-04-19 09:11:52 +0100 |
|---|---|---|
| committer | Mike McQuaid | 2014-04-23 08:10:48 +0100 |
| commit | 55d277c33592f922f506aa2e07c0f81c6d33fd74 (patch) | |
| tree | 2532a1a7e82160152444b104913e60b057d3bc64 | |
| parent | 593702c70bed6d26d54684745b4b2f42e2f98899 (diff) | |
| download | brew-55d277c33592f922f506aa2e07c0f81c6d33fd74.tar.bz2 | |
Support core GCC formula as a GCC compiler.
It is activated by the same mechanism as the Homebrew/versions compilers
which now check if the GCC formula uses the same, correct version.
References Homebrew/homebrew#28418.
| -rw-r--r-- | Library/Homebrew/extend/ENV/shared.rb | 24 | ||||
| -rw-r--r-- | Library/Homebrew/extend/ENV/std.rb | 5 | ||||
| -rw-r--r-- | Library/Homebrew/extend/ENV/super.rb | 5 | ||||
| -rw-r--r-- | Library/Homebrew/os/mac.rb | 14 | ||||
| -rw-r--r-- | Library/Homebrew/test/test_stdlib.rb | 5 |
5 files changed, 37 insertions, 16 deletions
diff --git a/Library/Homebrew/extend/ENV/shared.rb b/Library/Homebrew/extend/ENV/shared.rb index 924ac77ca..2964fbd16 100644 --- a/Library/Homebrew/extend/ENV/shared.rb +++ b/Library/Homebrew/extend/ENV/shared.rb @@ -185,11 +185,29 @@ module SharedEnvExtension append "LDFLAGS", "-B#{ld64.bin}/" end + def gcc_version_formula(version) + gcc_formula = Formulary.factory("gcc") + return gcc_formula if gcc_formula.version.to_s.include?(version) + + gcc_name = 'gcc' + version.delete('.') + Formulary.factory(gcc_name) + end + def warn_about_non_apple_gcc(gcc) + gcc_name = 'gcc' + gcc.delete('.') + begin - gcc_name = 'gcc' + gcc.delete('.') - gcc = Formulary.factory(gcc_name) - if !gcc.opt_prefix.exist? + gcc_formula = gcc_version_formula(gcc) + if gcc_formula.name == "gcc" + return if gcc_formula.opt_prefix.exist? + raise <<-EOS.undent + The Homebrew GCC was not installed. + You must: + brew install gcc + EOS + end + + if !gcc_formula.opt_prefix.exist? raise <<-EOS.undent The requested Homebrew GCC, #{gcc_name}, was not installed. You must: diff --git a/Library/Homebrew/extend/ENV/std.rb b/Library/Homebrew/extend/ENV/std.rb index c8beee949..bbf5d3b03 100644 --- a/Library/Homebrew/extend/ENV/std.rb +++ b/Library/Homebrew/extend/ENV/std.rb @@ -73,9 +73,8 @@ module Stdenv if cc =~ GNU_GCC_REGEXP warn_about_non_apple_gcc($1) - gcc_name = 'gcc' + $1.delete('.') - gcc = Formulary.factory(gcc_name) - self.append_path('PATH', gcc.opt_prefix/'bin') + gcc_formula = gcc_version_formula($1) + self.append_path('PATH', gcc_formula.opt_prefix/'bin') end # Add lib and include etc. from the current macosxsdk to compiler flags: diff --git a/Library/Homebrew/extend/ENV/super.rb b/Library/Homebrew/extend/ENV/super.rb index 14253ff88..138741757 100644 --- a/Library/Homebrew/extend/ENV/super.rb +++ b/Library/Homebrew/extend/ENV/super.rb @@ -135,9 +135,8 @@ module Superenv end if self['HOMEBREW_CC'] =~ GNU_GCC_REGEXP - gcc_name = 'gcc' + $1.delete('.') - gcc = Formulary.factory(gcc_name) - paths << gcc.opt_prefix/'bin' + gcc_formula = gcc_version_formula($1) + paths << gcc_formula.opt_prefix/'bin' end paths.to_path_s diff --git a/Library/Homebrew/os/mac.rb b/Library/Homebrew/os/mac.rb index a64329484..2d06fe7e0 100644 --- a/Library/Homebrew/os/mac.rb +++ b/Library/Homebrew/os/mac.rb @@ -131,8 +131,9 @@ module OS def gcc_42_build_version @gcc_42_build_version ||= begin - gcc = MacOS.locate('gcc-4.2') || Formula.factory('apple-gcc42').opt_prefix/'bin/gcc-4.2' - raise unless gcc.exist? + gcc = MacOS.locate('gcc-4.2') + gcc ||= Formula.factory('apple-gcc42').opt_prefix/'bin/gcc-4.2' rescue nil + raise if gcc.nil? || !gcc.exist? rescue gcc = nil end @@ -167,13 +168,16 @@ module OS end def non_apple_gcc_version(cc) - return unless path = locate(cc) + path = Formula.factory("gcc").opt_prefix/"bin/#{cc}" + path = nil unless path.exist? + + return unless path ||= locate(cc) ivar = "@#{cc.gsub(/(-|\.)/, '')}_version" return instance_variable_get(ivar) if instance_variable_defined?(ivar) - `#{path} --version` =~ /gcc-\d.\d \(GCC\) (\d\.\d\.\d)/ - instance_variable_set(ivar, $1) + `#{path} --version` =~ /gcc(-\d\.\d \(GCC\))? (\d\.\d\.\d)/ + instance_variable_set(ivar, $2) end # See these issues for some history: diff --git a/Library/Homebrew/test/test_stdlib.rb b/Library/Homebrew/test/test_stdlib.rb index 9ccfc2153..7bc0c03d6 100644 --- a/Library/Homebrew/test/test_stdlib.rb +++ b/Library/Homebrew/test/test_stdlib.rb @@ -23,6 +23,7 @@ class CxxStdlibTests < Test::Unit::TestCase end def test_compatibility_same_compilers_and_type + assert @gcc.compatible_with?(@gcc) assert @gcc48.compatible_with?(@gcc48) assert @clang.compatible_with?(@clang) end @@ -33,8 +34,8 @@ class CxxStdlibTests < Test::Unit::TestCase end def test_gnu_cross_version_incompatibility - assert !@clang.compatible_with?(@gcc48) - assert !@gcc48.compatible_with?(@clang) + assert !@gcc48.compatible_with?(@gcc49) + assert !@gcc49.compatible_with?(@gcc48) end def test_libstdcxx_libcxx_incompatibility |
