diff options
| author | Jack Nagel | 2014-09-18 15:50:54 -0500 | 
|---|---|---|
| committer | Jack Nagel | 2014-09-18 15:50:54 -0500 | 
| commit | c5f2f6b539247a00d446a6895883c2389a82f0d3 (patch) | |
| tree | a1575a4d2f73236d0f2abe3f6323c6bde2d84779 /Library/Homebrew | |
| parent | 04dae13ae7f014acf3a3300536546c7e12845884 (diff) | |
| download | brew-c5f2f6b539247a00d446a6895883c2389a82f0d3.tar.bz2 | |
Make --cc override the compiler selector
Diffstat (limited to 'Library/Homebrew')
| -rw-r--r-- | Library/Homebrew/compilers.rb | 7 | ||||
| -rw-r--r-- | Library/Homebrew/extend/ENV/shared.rb | 44 | ||||
| -rw-r--r-- | Library/Homebrew/extend/ENV/std.rb | 3 | ||||
| -rw-r--r-- | Library/Homebrew/extend/ENV/super.rb | 7 | 
4 files changed, 37 insertions, 24 deletions
| diff --git a/Library/Homebrew/compilers.rb b/Library/Homebrew/compilers.rb index d841e18d0..c3908adec 100644 --- a/Library/Homebrew/compilers.rb +++ b/Library/Homebrew/compilers.rb @@ -80,11 +80,14 @@ class CompilerSelector      :gcc_4_0 => [:gcc_4_0, :gcc, :llvm, :gnu, :clang],    } -  def self.select_for(formula) -    compilers = COMPILER_PRIORITY.fetch(MacOS.default_compiler) +  def self.select_for(formula, compilers=self.compilers)      new(formula, MacOS, compilers).compiler    end +  def self.compilers +    COMPILER_PRIORITY.fetch(MacOS.default_compiler) +  end +    attr_reader :formula, :failures, :versions, :compilers    def initialize(formula, versions, compilers) 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 diff --git a/Library/Homebrew/extend/ENV/std.rb b/Library/Homebrew/extend/ENV/std.rb index 89542fb68..e15012775 100644 --- a/Library/Homebrew/extend/ENV/std.rb +++ b/Library/Homebrew/extend/ENV/std.rb @@ -16,6 +16,7 @@ module Stdenv    end    def setup_build_environment(formula=nil) +    super      reset      if MacOS.version >= :mountain_lion @@ -55,10 +56,8 @@ module Stdenv      append 'LDFLAGS', '-Wl,-headerpad_max_install_names'      send(compiler) -    validate_cc!(formula) unless formula.nil?      if cc =~ GNU_GCC_REGEXP -      warn_about_non_apple_gcc($1)        gcc_formula = gcc_version_formula($1)        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 34137729f..702114cea 100644 --- a/Library/Homebrew/extend/ENV/super.rb +++ b/Library/Homebrew/extend/ENV/super.rb @@ -34,11 +34,10 @@ module Superenv    end    def setup_build_environment(formula=nil) +    super      reset +    send(compiler) -    self.cc  = determine_cc -    self.cxx = determine_cxx -    validate_cc!(formula) unless formula.nil?      self['MAKEFLAGS'] ||= "-j#{determine_make_jobs}"      self['PATH'] = determine_path      self['PKG_CONFIG_PATH'] = determine_pkg_config_path @@ -85,8 +84,6 @@ module Superenv      # On 10.8 and newer, these flags will also be present:      # s - apply fix for sed's Unicode support      # a - apply fix for apr-1-config path - -    warn_about_non_apple_gcc($1) if homebrew_cc =~ GNU_GCC_REGEXP    end    private | 
