aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew
diff options
context:
space:
mode:
authorJack Nagel2014-09-18 15:50:54 -0500
committerJack Nagel2014-09-18 15:50:54 -0500
commitae88549797c01283e8cb1599863a7614a165016c (patch)
treeb2dec8eec9e30e088ab7aa4b41471399afebf5e3 /Library/Homebrew
parent84352d2728eb90dcb321955424acd088a9702d5d (diff)
downloadbrew-ae88549797c01283e8cb1599863a7614a165016c.tar.bz2
Remove fails_with? from the formula instance
Diffstat (limited to 'Library/Homebrew')
-rw-r--r--Library/Homebrew/compilers.rb15
-rw-r--r--Library/Homebrew/extend/ENV/shared.rb12
-rw-r--r--Library/Homebrew/formula.rb4
-rw-r--r--Library/Homebrew/software_spec.rb4
4 files changed, 14 insertions, 21 deletions
diff --git a/Library/Homebrew/compilers.rb b/Library/Homebrew/compilers.rb
index 7080f69e7..b445213ec 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 266056751..066266434 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 261d3c5a0..96573b69f 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 b2071e119..4ea2f56c4 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