aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/compat
diff options
context:
space:
mode:
authorJack Nagel2012-03-18 13:58:13 -0500
committerJack Nagel2012-04-01 12:39:59 -0500
commitb36f59dd3c8a3bf95eeb715e3fdd05bce2ccdc75 (patch)
treeba3f6961363bfd11839976ce295b7967a275f208 /Library/Homebrew/compat
parentbe829c72c3255e0d1682a1e796b91cb644109372 (diff)
downloadhomebrew-b36f59dd3c8a3bf95eeb715e3fdd05bce2ccdc75.tar.bz2
New fails_with infrastructure
- Formulae can now declare failures on any compiler. - FailsWithLLVM and associated formula elements have been moved to compat. Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Diffstat (limited to 'Library/Homebrew/compat')
-rw-r--r--Library/Homebrew/compat/compatibility.rb59
1 files changed, 59 insertions, 0 deletions
diff --git a/Library/Homebrew/compat/compatibility.rb b/Library/Homebrew/compat/compatibility.rb
index 3d67de077..acb03a75f 100644
--- a/Library/Homebrew/compat/compatibility.rb
+++ b/Library/Homebrew/compat/compatibility.rb
@@ -76,6 +76,16 @@ class Formula
def fails_with_llvm msg=nil, data=nil
FailsWithLLVM.new(msg, data).handle_failure
end
+
+ def fails_with_llvm?
+ fails_with? :llvm
+ end
+
+ def self.fails_with_llvm msg=nil, data=nil
+ fails_with_llvm_reason = FailsWithLLVM.new(msg, data)
+ @cc_failures ||= CompilerFailures.new
+ @cc_failures << fails_with_llvm_reason
+ end
end
class UnidentifiedFormula < Formula
@@ -94,3 +104,52 @@ module HomebrewEnvExtension extend self
compiler == :llvm
end
end
+
+class FailsWithLLVM
+ attr_reader :compiler, :build, :cause
+
+ def initialize msg=nil, data=nil
+ if msg.nil? or msg.kind_of? Hash
+ @cause = "(No specific reason was given)"
+ data = msg
+ else
+ @cause = msg
+ end
+ @build = (data.delete :build rescue nil).to_i
+ @compiler = :llvm
+ end
+
+ def handle_failure
+ return unless ENV.compiler == :llvm
+
+ # version 2336 is the latest version as of Xcode 4.2, so it is the
+ # latest version we have tested against so we will switch to GCC and
+ # bump this integer when Xcode 4.3 is released. TODO do that!
+ if build.to_i >= 2336
+ if MacOS.xcode_version < "4.2"
+ opoo "Formula will not build with LLVM, using GCC"
+ ENV.gcc
+ else
+ opoo "Formula will not build with LLVM, trying Clang"
+ ENV.clang
+ end
+ return
+ end
+ opoo "Building with LLVM, but this formula is reported to not work with LLVM:"
+ puts
+ puts cause
+ puts
+ puts <<-EOS.undent
+ We are continuing anyway so if the build succeeds, please open a ticket with
+ the following information: #{MacOS.llvm_build_version}-#{MACOS_VERSION}. So
+ that we can update the formula accordingly. Thanks!
+ EOS
+ puts
+ if MacOS.xcode_version < "4.2"
+ puts "If it doesn't work you can: brew install --use-gcc"
+ else
+ puts "If it doesn't work you can try: brew install --use-clang"
+ end
+ puts
+ end
+end