diff options
Diffstat (limited to 'Library/Homebrew/extend/ENV/shared.rb')
| -rw-r--r-- | Library/Homebrew/extend/ENV/shared.rb | 44 |
1 files changed, 29 insertions, 15 deletions
diff --git a/Library/Homebrew/extend/ENV/shared.rb b/Library/Homebrew/extend/ENV/shared.rb index 9ef512b92..87347a89e 100644 --- a/Library/Homebrew/extend/ENV/shared.rb +++ b/Library/Homebrew/extend/ENV/shared.rb @@ -27,6 +27,10 @@ module SharedEnvExtension GOBIN ] + def setup_build_environment(formula=nil) + @formula = formula + end + def reset SANITIZED_VARS.each { |k| delete(k) } end @@ -101,15 +105,21 @@ module SharedEnvExtension def fcflags; self['FCFLAGS']; end def compiler - @compiler ||= if (cc = ARGV.cc || homebrew_cc) - COMPILER_SYMBOL_MAP.fetch(cc) do |other| - case other - when GNU_GCC_REGEXP - other - else - raise "Invalid value for --cc: #{other}" - end + @compiler ||= if (cc = ARGV.cc) + warn_about_non_apple_gcc($1) if cc =~ GNU_GCC_REGEXP + fetch_compiler(cc, "--cc") + elsif (cc = homebrew_cc) + warn_about_non_apple_gcc($1) if cc =~ GNU_GCC_REGEXP + compiler = fetch_compiler(cc, "HOMEBREW_CC") + + if @formula + compilers = [compiler] + CompilerSelector.compilers + compiler = CompilerSelector.select_for(@formula, compilers) end + + compiler + elsif @formula + CompilerSelector.select_for(@formula) else MacOS.default_compiler end @@ -127,13 +137,6 @@ module SharedEnvExtension end end - # If the given compiler isn't compatible, will try to select - # an alternate compiler, altering the value of environment variables. - # If no valid compiler is found, raises an exception. - def validate_cc!(formula) - send CompilerSelector.select_for(formula) - end - # Snow Leopard defines an NCURSES value the opposite of most distros # See: http://bugs.python.org/issue6848 # Currently only used by aalib in core @@ -260,4 +263,15 @@ module SharedEnvExtension def homebrew_cc self["HOMEBREW_CC"] end + + def fetch_compiler(value, source) + COMPILER_SYMBOL_MAP.fetch(value) do |other| + case other + when GNU_GCC_REGEXP + other + else + raise "Invalid value for #{source}: #{other}" + end + end + end end |
