aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorAdam Vandenberg2011-03-21 14:23:28 -0700
committerAdam Vandenberg2011-03-25 23:31:28 -0700
commit966e1822ebd98caeaff10d5877d4e6272b75bec8 (patch)
tree3b4aed152312f9c67d09867b68255a5334d91376 /Library
parent304d9af671748de70671481c307b0b3f1115832e (diff)
downloadhomebrew-966e1822ebd98caeaff10d5877d4e6272b75bec8.tar.bz2
Move 'fails_with_llvm' into formula DSL.
Existing method moved to compatibility layer.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/compatibility.rb7
-rw-r--r--Library/Homebrew/formula.rb47
2 files changed, 43 insertions, 11 deletions
diff --git a/Library/Homebrew/compatibility.rb b/Library/Homebrew/compatibility.rb
index 8e1a028de..5bc76d3ff 100644
--- a/Library/Homebrew/compatibility.rb
+++ b/Library/Homebrew/compatibility.rb
@@ -70,4 +70,11 @@ class Formula
name
end
end
+
+ # This used to be called in "def install", but should now be used
+ # up in the DSL section.
+ def fails_with_llvm msg=nil, data=nil
+ handle_llvm_failure FailsWithLLVM.new(msg, data)
+ end
+
end
diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb
index dd4e03261..fb9542889 100644
--- a/Library/Homebrew/formula.rb
+++ b/Library/Homebrew/formula.rb
@@ -47,7 +47,7 @@ end
# Used to annotate formulae that duplicate OS X provided software
-# :provided_by_osx
+# or cause conflicts when linked in.
class KegOnlyReason
attr_reader :reason, :explanation
@@ -71,6 +71,25 @@ EOS
end
+# Used to annotate formulae that won't build correctly with LLVM.
+class FailsWithLLVM
+ attr_reader :msg, :data, :build
+
+ def initialize msg=nil, data=nil
+ @msg = msg || "(No specific reason was given)"
+ @data = data
+ @build = data.delete :build rescue nil
+ end
+
+ def reason
+ s = @msg
+ s += "Tested with LLVM build #{@build}" unless @build == nil
+ s += "\n"
+ return s
+ end
+end
+
+
# Derive and define at least @url, see Library/Formula for examples
class Formula
include FileUtils
@@ -198,6 +217,10 @@ class Formula
self.class.keg_only_reason || false
end
+ def fails_with_llvm?
+ self.class.fails_with_llvm_reason || false
+ end
+
# sometimes the clean process breaks things
# skip cleaning paths in a formula with a class method like this:
# skip_clean [bin+"foo", lib+"bar"]
@@ -213,6 +236,8 @@ class Formula
validate_variable :name
validate_variable :version
+ handle_llvm_failure(fails_with_llvm?) if fails_with_llvm?
+
stage do
begin
patch
@@ -264,28 +289,24 @@ class Formula
"-DCMAKE_INSTALL_PREFIX='#{prefix}' -DCMAKE_BUILD_TYPE=None -Wno-dev"
end
- def fails_with_llvm msg="", data=nil
+ def handle_llvm_failure llvm
unless (ENV['HOMEBREW_USE_LLVM'] or ARGV.include? '--use-llvm')
ENV.gcc_4_2 if default_cc =~ /llvm/
return
end
- build = data.delete :build rescue nil
- msg = "(No specific reason was given)" if msg.empty?
-
opoo "LLVM was requested, but this formula is reported as not working with LLVM:"
- puts msg
- puts "Tested with LLVM build #{build}" unless build == nil
- puts
+ puts llvm.reason
if ARGV.force?
- puts "Continuing anyway. If this works, let us know so we can update the\n"+
- "formula to remove the warning."
+ puts "Continuing anyway.\n" +
+ "If this works, let us know so we can update the formula to remove the warning."
else
puts "Continuing with GCC 4.2 instead.\n"+
"(Use `brew install --force #{name}` to force use of LLVM.)"
ENV.gcc_4_2
end
+ puts
end
def self.class_s name
@@ -604,7 +625,7 @@ EOF
end
attr_rw :version, :homepage, :specs, :deps, :external_deps
- attr_rw :keg_only_reason, :skip_clean_all
+ attr_rw :keg_only_reason, :fails_with_llvm_reason, :skip_clean_all
attr_rw(*CHECKSUM_TYPES)
def head val=nil, specs=nil
@@ -679,6 +700,10 @@ EOF
def keg_only reason, explanation=nil
@keg_only_reason = KegOnlyReason.new(reason, explanation.to_s.chomp)
end
+
+ def fails_with_llvm msg=nil, data=nil
+ @fails_with_llvm_reason = FailsWithLLVM.new(msg, data)
+ end
end
end