diff options
| author | Max Howell | 2011-08-26 14:21:37 +0100 |
|---|---|---|
| committer | Max Howell | 2011-08-26 14:21:37 +0100 |
| commit | 93f03aa278c9260b9dda7bb32206c0edf6b4ebd4 (patch) | |
| tree | 4fbaf04d22c5cdc65b7175ca442d79a71e01b5c9 /Library/Homebrew/extend | |
| parent | 03ce188ec57b12780c15204ed01d993dab782a14 (diff) | |
| download | homebrew-93f03aa278c9260b9dda7bb32206c0edf6b4ebd4.tar.bz2 | |
Some more sanity with ENV.compiler
Deprecated use_clang? etc. since the logic was such that multiple states could be set, when in reality only one compiler can be set.
Changed fails_with_llvm handling so if HOMEBREW_USE_LLVM is set then it tries to build even if the formula has fails_with_llvm set. Rationale: mostly they will no longer fail and we need to catch these cases.
Diffstat (limited to 'Library/Homebrew/extend')
| -rw-r--r-- | Library/Homebrew/extend/ENV.rb | 58 |
1 files changed, 44 insertions, 14 deletions
diff --git a/Library/Homebrew/extend/ENV.rb b/Library/Homebrew/extend/ENV.rb index 019b8ae86..38852b817 100644 --- a/Library/Homebrew/extend/ENV.rb +++ b/Library/Homebrew/extend/ENV.rb @@ -25,14 +25,10 @@ module HomebrewEnvExtension self['CC'] = '/usr/bin/cc' self['CXX'] = '/usr/bin/c++' - if MACOS_VERSION >= 10.6 - if self.use_clang? - self.clang - elsif self.use_llvm? - self.llvm - elsif self.use_gcc? - self.gcc - end + case self.compiler + when :clang then self.clang + when :llvm then self.llvm + when :gcc then self.gcc end # In rare cases this may break your builds, as the tool for some reason wants @@ -141,7 +137,9 @@ module HomebrewEnvExtension alias_method :gcc_4_2, :gcc def llvm - if MacOS.xcode_version < '4.1' + if MacOS.xcode_version < '4' + self.gcc + elsif MacOS.xcode_version < '4.1' self['CC'] = "#{MacOS.xcode_prefix}/usr/bin/llvm-gcc" self['CXX'] = "#{MacOS.xcode_prefix}/usr/bin/llvm-g++" else @@ -151,8 +149,12 @@ module HomebrewEnvExtension end def clang - self['CC'] = "#{MacOS.xcode_prefix}/usr/bin/clang" - self['CXX'] = "#{MacOS.xcode_prefix}/usr/bin/clang++" + if MacOS.xcode_version > '4' + self['CC'] = "#{MacOS.xcode_prefix}/usr/bin/clang" + self['CXX'] = "#{MacOS.xcode_prefix}/usr/bin/clang++" + else + self.gcc + end end def fortran @@ -310,14 +312,42 @@ Please take one of the following actions: remove 'CXXFLAGS', f end + def compiler + # TODO seems that ENV.clang in a Formula.install should warn when called + # if the user has set something that is tested here + + # test for --flags first so that installs can be overridden on a per + # install basis + if ARGV.include? '--use-gcc' + :gcc + elsif ARGV.include? '--use-llvm' + :llvm + elsif ARGV.include? '--use-clang' + :clang + end + + # test for ENVs in inverse order to flags, this is sensible, trust me + if self['HOMEBREW_USE_CLANG'] + :clang + elsif self['HOMEBREW_USE_LLVM'] + :llvm + elsif self['HOMEBREW_USE_GCC'] + :gcc + else + :gcc + end + end + + # don't use in new code + # don't remove though, but do add to compatibility.rb def use_clang? - self['HOMEBREW_USE_CLANG'] or ARGV.include? '--use-clang' + compiler == :clang end def use_gcc? - self['HOMEBREW_USE_GCC'] or ARGV.include? '--use-gcc' + compiler == :gcc end def use_llvm? - self['HOMEBREW_USE_LLVM'] or ARGV.include? '--use-llvm' + compiler == :llvm end def make_jobs |
