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.
This commit is contained in:
parent
2c54aa3262
commit
9af3917ebf
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user