Merge pull request #8349 from reitermarkus/doc-cxxstdlib
Refactor and document `CxxStdlib`.
This commit is contained in:
commit
958c5c7f9e
@ -2,9 +2,11 @@
|
||||
|
||||
require "compilers"
|
||||
|
||||
# Combination of C++ standard library and compiler.
|
||||
class CxxStdlib
|
||||
include CompilerConstants
|
||||
|
||||
# Error for when a formula's dependency was built with a different C++ standard library.
|
||||
class CompatibilityError < StandardError
|
||||
def initialize(formula, dep, stdlib)
|
||||
super <<~EOS
|
||||
@ -17,8 +19,8 @@ class CxxStdlib
|
||||
def self.create(type, compiler)
|
||||
raise ArgumentError, "Invalid C++ stdlib type: #{type}" if type && ![:libstdcxx, :libcxx].include?(type)
|
||||
|
||||
klass = (compiler.to_s =~ GNU_GCC_REGEXP) ? GnuStdlib : AppleStdlib
|
||||
klass.new(type, compiler)
|
||||
apple_compiler = compiler.to_s.match?(GNU_GCC_REGEXP) ? false : true
|
||||
CxxStdlib.new(type, compiler, apple_compiler)
|
||||
end
|
||||
|
||||
def self.check_compatibility(formula, deps, keg, compiler)
|
||||
@ -35,9 +37,10 @@ class CxxStdlib
|
||||
|
||||
attr_reader :type, :compiler
|
||||
|
||||
def initialize(type, compiler)
|
||||
def initialize(type, compiler, apple_compiler)
|
||||
@type = type
|
||||
@compiler = compiler.to_sym
|
||||
@apple_compiler = apple_compiler
|
||||
end
|
||||
|
||||
# If either package doesn't use C++, all is well.
|
||||
@ -72,15 +75,7 @@ class CxxStdlib
|
||||
"#<#{self.class.name}: #{compiler} #{type}>"
|
||||
end
|
||||
|
||||
class AppleStdlib < CxxStdlib
|
||||
def apple_compiler?
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
class GnuStdlib < CxxStdlib
|
||||
def apple_compiler?
|
||||
false
|
||||
end
|
||||
@apple_compiler
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user