From 1bba5fd88af811064d7f66dda57ac3127bdda05c Mon Sep 17 00:00:00 2001 From: Jack Nagel <jacknagel@gmail.com> Date: Sun, 21 Jun 2015 21:18:23 -0400 Subject: [PATCH] Pass full match to warn_about_non_apple_gcc --- Library/Homebrew/extend/ENV/shared.rb | 25 ++++++++++++------------- Library/Homebrew/extend/ENV/std.rb | 2 +- Library/Homebrew/extend/ENV/super.rb | 2 +- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/Library/Homebrew/extend/ENV/shared.rb b/Library/Homebrew/extend/ENV/shared.rb index 414facd4db..bbed75bee0 100644 --- a/Library/Homebrew/extend/ENV/shared.rb +++ b/Library/Homebrew/extend/ENV/shared.rb @@ -98,10 +98,10 @@ module SharedEnvExtension def compiler @compiler ||= if (cc = ARGV.cc) - warn_about_non_apple_gcc($1) if cc =~ GNU_GCC_REGEXP + warn_about_non_apple_gcc($&) if cc =~ GNU_GCC_REGEXP fetch_compiler(cc, "--cc") elsif (cc = homebrew_cc) - warn_about_non_apple_gcc($1) if cc =~ GNU_GCC_REGEXP + warn_about_non_apple_gcc($&) if cc =~ GNU_GCC_REGEXP compiler = fetch_compiler(cc, "HOMEBREW_CC") if @formula @@ -188,14 +188,13 @@ module SharedEnvExtension append "LDFLAGS", "-B#{ld64.bin}/" end - def gcc_version_formula(version) - gcc_name = "gcc-#{version}" + def gcc_version_formula(name) + version = name[GNU_GCC_REGEXP, 1] gcc_version_name = "gcc#{version.delete('.')}" - gcc_path = HOMEBREW_PREFIX.join "opt/gcc/bin/#{gcc_name}" + gcc_path = HOMEBREW_PREFIX.join("opt", "gcc", "bin", name) gcc_formula = Formulary.factory "gcc" - gcc_versions_path = \ - HOMEBREW_PREFIX.join "opt/#{gcc_version_name}/bin/#{gcc_name}" + gcc_versions_path = HOMEBREW_PREFIX.join("opt", gcc_version_name, "bin", name) if gcc_path.exist? gcc_formula @@ -210,11 +209,11 @@ module SharedEnvExtension end end - def warn_about_non_apple_gcc(gcc) - gcc_name = 'gcc' + gcc.delete('.') + def warn_about_non_apple_gcc(name) + gcc_version_name = name.delete(".-") begin - gcc_formula = gcc_version_formula(gcc) + gcc_formula = gcc_version_formula(name) if gcc_formula.name == "gcc" return if gcc_formula.opt_prefix.exist? raise <<-EOS.undent @@ -226,15 +225,15 @@ module SharedEnvExtension if !gcc_formula.opt_prefix.exist? raise <<-EOS.undent - The requested Homebrew GCC, #{gcc_name}, was not installed. + The requested Homebrew GCC, #{gcc_version_name}, was not installed. You must: brew tap homebrew/versions - brew install #{gcc_name} + brew install #{gcc_version_name} EOS end rescue FormulaUnavailableError raise <<-EOS.undent - Homebrew GCC requested, but formula #{gcc_name} not found! + Homebrew GCC requested, but formula #{gcc_version_name} not found! You may need to: brew tap homebrew/versions EOS end diff --git a/Library/Homebrew/extend/ENV/std.rb b/Library/Homebrew/extend/ENV/std.rb index bc165c667b..56ac68a87f 100644 --- a/Library/Homebrew/extend/ENV/std.rb +++ b/Library/Homebrew/extend/ENV/std.rb @@ -56,7 +56,7 @@ module Stdenv send(compiler) if cc =~ GNU_GCC_REGEXP - gcc_formula = gcc_version_formula($1) + gcc_formula = gcc_version_formula($&) append_path "PATH", gcc_formula.opt_bin.to_s end diff --git a/Library/Homebrew/extend/ENV/super.rb b/Library/Homebrew/extend/ENV/super.rb index 7341fa69e0..cc187434b6 100644 --- a/Library/Homebrew/extend/ENV/super.rb +++ b/Library/Homebrew/extend/ENV/super.rb @@ -125,7 +125,7 @@ module Superenv end paths << apple_gcc42.opt_bin.to_s if apple_gcc42 when GNU_GCC_REGEXP - gcc_formula = gcc_version_formula($1) + gcc_formula = gcc_version_formula($&) paths << gcc_formula.opt_bin.to_s end -- GitLab