aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew
diff options
context:
space:
mode:
authorMisty De Meo2014-04-04 21:16:09 -0700
committerMisty De Meo2014-04-12 10:36:00 -0700
commit9af3917ebf9fcfdad05f5a810815cba9a7df377a (patch)
tree767678fac9a7ba9f4197051317163998f9ea4f0d /Library/Homebrew
parent2c54aa32629ef96cb558cd5d004ce34990dcf99f (diff)
downloadbrew-9af3917ebf9fcfdad05f5a810815cba9a7df377a.tar.bz2
Formula: provide compiler failure collections
`needs` allows formulae to specify dependencies on cross-compiler dependencies, allowing multiple failures to be specified in a single statement. For instance, `needs :cxx11` adds seven compiler failures. Closes Homebrew/homebrew#22912.
Diffstat (limited to 'Library/Homebrew')
-rw-r--r--Library/Homebrew/compilers.rb29
-rw-r--r--Library/Homebrew/formula.rb7
2 files changed, 36 insertions, 0 deletions
diff --git a/Library/Homebrew/compilers.rb b/Library/Homebrew/compilers.rb
index bd3fde698..7473f12a7 100644
--- a/Library/Homebrew/compilers.rb
+++ b/Library/Homebrew/compilers.rb
@@ -28,6 +28,35 @@ class CompilerFailure
attr_reader :compiler, :major_version
attr_rw :cause, :version
+ MESSAGES = {
+ :cxx11 => 'This compiler does not support C++11'
+ }
+
+ COLLECTIONS = {
+ :cxx11 => [
+ [:gcc_4_0, proc { cause MESSAGES[:cxx11] }],
+ [:gcc, proc { cause MESSAGES[:cxx11] }],
+ [:clang, proc { build 425; cause MESSAGES[:cxx11] }],
+ [{:gcc => '4.3'}, proc { cause MESSAGES[:cxx11] }],
+ [{:gcc => '4.4'}, proc { cause MESSAGES[:cxx11] }],
+ [{:gcc => '4.5'}, proc { cause MESSAGES[:cxx11] }],
+ [{:gcc => '4.6'}, proc { cause MESSAGES[:cxx11] }]
+ ],
+ :openmp => [
+ [:clang, proc { cause 'clang does not support OpenMP' }]
+ ]
+ }
+
+ def self.for_standard standard
+ failures = COLLECTIONS.fetch(standard) do
+ raise ArgumentError, "\"#{standard}\" is not a recognized standard"
+ end
+
+ failures.map do |compiler, block|
+ CompilerFailure.new(compiler, &block)
+ end
+ end
+
def initialize compiler, &block
# Non-Apple compilers are in the format fails_with compiler => version
if compiler.is_a? Hash
diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb
index 49271b76d..2fe485909 100644
--- a/Library/Homebrew/formula.rb
+++ b/Library/Homebrew/formula.rb
@@ -761,6 +761,13 @@ class Formula
@cc_failures << CompilerFailure.new(compiler, &block)
end
+ def needs *standards
+ @cc_failures ||= Set.new
+ standards.each do |standard|
+ @cc_failures.merge CompilerFailure.for_standard standard
+ end
+ end
+
def require_universal_deps
specs.each { |spec| spec.build.universal = true }
end