diff --git a/Library/Homebrew/compilers.rb b/Library/Homebrew/compilers.rb index 7080f69e7a..b445213ecf 100644 --- a/Library/Homebrew/compilers.rb +++ b/Library/Homebrew/compilers.rb @@ -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 diff --git a/Library/Homebrew/extend/ENV/shared.rb b/Library/Homebrew/extend/ENV/shared.rb index 2660567514..066266434d 100644 --- a/Library/Homebrew/extend/ENV/shared.rb +++ b/Library/Homebrew/extend/ENV/shared.rb @@ -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 diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 261d3c5a0d..96573b69fa 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -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 diff --git a/Library/Homebrew/software_spec.rb b/Library/Homebrew/software_spec.rb index b2071e119f..4ea2f56c4c 100644 --- a/Library/Homebrew/software_spec.rb +++ b/Library/Homebrew/software_spec.rb @@ -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