Reduce footprint of fails_with_llvm compat code

This commit is contained in:
Jack Nagel 2013-03-18 13:10:03 -05:00
parent 581e766809
commit 456386c9b1

View File

@ -76,18 +76,18 @@ class Formula
# up in the DSL section.
def fails_with_llvm msg=nil, data=nil
opoo "Calling fails_with_llvm in the install method is deprecated"
puts "Use the fails_with DSL instead."
FailsWithLLVM.new(msg, data).handle_failure
puts "Use the fails_with DSL instead"
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)
def self.fails_with_llvm msg=nil, data={}
case msg when Hash then data = msg end
failure = CompilerFailure.new(:llvm) { build(data.delete(:build).to_i) }
@cc_failures ||= Set.new
@cc_failures << fails_with_llvm_reason
@cc_failures << failure
end
def std_cmake_parameters
@ -133,55 +133,6 @@ module HomebrewEnvExtension extend self
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
# TODO eventually some of these should print deprecation warnings
module MacOS extend self
def xcode_folder