Skip to content

Commit

Permalink
Add --cc= syntax for selecting compilers
Browse files Browse the repository at this point in the history
  • Loading branch information
mistydemeo committed Aug 30, 2013
1 parent 3b0fa87 commit 4834418
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
4 changes: 4 additions & 0 deletions Library/Homebrew/extend/ARGV.rb
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ def filter_for_dependencies
replace(old_args)
end

def cc
value 'cc'
end

private

def downcased_unique_named
Expand Down
2 changes: 2 additions & 0 deletions Library/Homebrew/extend/ENV/shared.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ 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']

def remove_cc_etc
keys = %w{CC CXX OBJC OBJCXX LD CPP CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS LDFLAGS CPPFLAGS}
removed = Hash[*keys.map{ |key| [key, self[key]] }.flatten]
Expand Down
4 changes: 3 additions & 1 deletion Library/Homebrew/extend/ENV/std.rb
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,9 @@ def compiler
# test for --flags first so that installs can be overridden on a per
# install basis. Then test for ENVs in inverse order to flags, this is
# sensible, trust me
@compiler ||= if ARGV.include? '--use-gcc'
@compiler ||= if (cc = ARGV.cc)
COMPILERS.grep(cc).pop ? cc : raise("Invalid value for --cc: #{cc}")
elsif ARGV.include? '--use-gcc'
:gcc
elsif ARGV.include? '--use-llvm'
:llvm
Expand Down
4 changes: 3 additions & 1 deletion Library/Homebrew/extend/ENV/super.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ def m32
private

def determine_cc
if ARGV.include? '--use-gcc'
if (cc = ARGV.cc)
COMPILERS.grep(cc).pop ? cc : raise("Invalid value for --cc: #{cc}")
elsif ARGV.include? '--use-gcc'
gcc_installed = Formula.factory('apple-gcc42').installed? rescue false
# fall back to something else on systems without Apple gcc
if MacOS.locate('gcc-4.2') || gcc_installed
Expand Down

0 comments on commit 4834418

Please sign in to comment.