Remove fails_with? from the formula instance

This commit is contained in:
Jack Nagel 2014-09-18 15:50:54 -05:00
parent 84352d2728
commit ae88549797
4 changed files with 14 additions and 21 deletions

View File

@ -99,8 +99,11 @@ class CompilerQueue
end end
class CompilerSelector class CompilerSelector
def initialize(f, versions=MacOS) attr_reader :formula
@f = f
def initialize(formula, versions=MacOS)
@formula = formula
@failures = formula.compiler_failures
@versions = versions @versions = versions
@compilers = CompilerQueue.new @compilers = CompilerQueue.new
%w{clang llvm gcc gcc_4_0}.map(&:to_sym).each do |cc| %w{clang llvm gcc gcc_4_0}.map(&:to_sym).each do |cc|
@ -125,13 +128,17 @@ class CompilerSelector
# if none can be found raises CompilerError instead # if none can be found raises CompilerError instead
def compiler def compiler
while cc = @compilers.pop while cc = @compilers.pop
return cc.name unless @f.fails_with?(cc) return cc.name unless fails_with?(cc)
end end
raise CompilerSelectionError.new(@f) raise CompilerSelectionError.new(formula)
end end
private private
def fails_with?(compiler)
@failures.any? { |failure| failure === compiler }
end
def priority_for(cc) def priority_for(cc)
case cc case cc
when :clang then @versions.clang_build_version >= 318 ? 3 : 0.5 when :clang then @versions.clang_build_version >= 318 ? 3 : 0.5

View File

@ -131,18 +131,8 @@ module SharedEnvExtension
# an alternate compiler, altering the value of environment variables. # an alternate compiler, altering the value of environment variables.
# If no valid compiler is found, raises an exception. # If no valid compiler is found, raises an exception.
def validate_cc!(formula) def validate_cc!(formula)
# FIXME
# The compiler object we pass to fails_with? has no version information
# attached to it. This means that if we pass Compiler.new(:clang), the
# selector will be invoked if the formula fails with any version of clang.
# I think we can safely remove this conditional and always invoke the
# selector.
# The compiler priority logic in compilers.rb and default_compiler logic in
# os/mac.rb need to be unified somehow.
if formula.fails_with? Compiler.new(compiler)
send CompilerSelector.new(formula).compiler send CompilerSelector.new(formula).compiler
end end
end
# Snow Leopard defines an NCURSES value the opposite of most distros # Snow Leopard defines an NCURSES value the opposite of most distros
# See: http://bugs.python.org/issue6848 # See: http://bugs.python.org/issue6848

View File

@ -110,8 +110,8 @@ class Formula
active_spec.option_defined?(name) active_spec.option_defined?(name)
end end
def fails_with?(compiler) def compiler_failures
active_spec.fails_with?(compiler) active_spec.compiler_failures
end end
# if the dir is there, but it's empty we consider it not installed # if the dir is there, but it's empty we consider it not installed

View File

@ -116,10 +116,6 @@ class SoftwareSpec
patches << Patch.create(strip, src, &block) patches << Patch.create(strip, src, &block)
end end
def fails_with? compiler
compiler_failures.any? { |failure| failure === compiler }
end
def fails_with compiler, &block def fails_with compiler, &block
compiler_failures << CompilerFailure.create(compiler, &block) compiler_failures << CompilerFailure.create(compiler, &block)
end end