mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Remove fails_with? from the formula instance
This commit is contained in:
parent
84352d2728
commit
ae88549797
@ -99,8 +99,11 @@ class CompilerQueue
|
||||
end
|
||||
|
||||
class CompilerSelector
|
||||
def initialize(f, versions=MacOS)
|
||||
@f = f
|
||||
attr_reader :formula
|
||||
|
||||
def initialize(formula, versions=MacOS)
|
||||
@formula = formula
|
||||
@failures = formula.compiler_failures
|
||||
@versions = versions
|
||||
@compilers = CompilerQueue.new
|
||||
%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
|
||||
def compiler
|
||||
while cc = @compilers.pop
|
||||
return cc.name unless @f.fails_with?(cc)
|
||||
return cc.name unless fails_with?(cc)
|
||||
end
|
||||
raise CompilerSelectionError.new(@f)
|
||||
raise CompilerSelectionError.new(formula)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def fails_with?(compiler)
|
||||
@failures.any? { |failure| failure === compiler }
|
||||
end
|
||||
|
||||
def priority_for(cc)
|
||||
case cc
|
||||
when :clang then @versions.clang_build_version >= 318 ? 3 : 0.5
|
||||
|
@ -131,17 +131,7 @@ module SharedEnvExtension
|
||||
# an alternate compiler, altering the value of environment variables.
|
||||
# If no valid compiler is found, raises an exception.
|
||||
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
|
||||
end
|
||||
send CompilerSelector.new(formula).compiler
|
||||
end
|
||||
|
||||
# Snow Leopard defines an NCURSES value the opposite of most distros
|
||||
|
@ -110,8 +110,8 @@ class Formula
|
||||
active_spec.option_defined?(name)
|
||||
end
|
||||
|
||||
def fails_with?(compiler)
|
||||
active_spec.fails_with?(compiler)
|
||||
def compiler_failures
|
||||
active_spec.compiler_failures
|
||||
end
|
||||
|
||||
# if the dir is there, but it's empty we consider it not installed
|
||||
|
@ -116,10 +116,6 @@ class SoftwareSpec
|
||||
patches << Patch.create(strip, src, &block)
|
||||
end
|
||||
|
||||
def fails_with? compiler
|
||||
compiler_failures.any? { |failure| failure === compiler }
|
||||
end
|
||||
|
||||
def fails_with compiler, &block
|
||||
compiler_failures << CompilerFailure.create(compiler, &block)
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user