Class: CxxStdlib
- Inherits:
-
Object
- Object
- CxxStdlib
- Includes:
- CompilerConstants
- Defined in:
- Library/Homebrew/cxxstdlib.rb
Direct Known Subclasses
Defined Under Namespace
Classes: AppleStdlib, CompatibilityError, GnuStdlib
Constant Summary
Constants included from CompilerConstants
CompilerConstants::COMPILERS, CompilerConstants::COMPILER_SYMBOL_MAP, CompilerConstants::GNU_GCC_REGEXP, CompilerConstants::GNU_GCC_VERSIONS
Instance Attribute Summary collapse
-
#compiler ⇒ Object
readonly
Returns the value of attribute compiler.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
- #check_dependencies(formula, deps) ⇒ Object
-
#compatible_with?(other) ⇒ Boolean
If either package doesn't use C++, all is well libstdc++ and libc++ aren't ever intercompatible libstdc++ is compatible across Apple compilers, but not between Apple and GNU compilers, or between GNU compiler versions.
-
#initialize(type, compiler) ⇒ CxxStdlib
constructor
A new instance of CxxStdlib.
- #inspect ⇒ Object
- #type_string ⇒ Object
Constructor Details
#initialize(type, compiler) ⇒ CxxStdlib
Returns a new instance of CxxStdlib
37 38 39 40 |
# File 'Library/Homebrew/cxxstdlib.rb', line 37 def initialize(type, compiler) @type = type @compiler = compiler.to_sym end |
Instance Attribute Details
#compiler ⇒ Object (readonly)
Returns the value of attribute compiler
35 36 37 |
# File 'Library/Homebrew/cxxstdlib.rb', line 35 def compiler @compiler end |
#type ⇒ Object (readonly)
Returns the value of attribute type
35 36 37 |
# File 'Library/Homebrew/cxxstdlib.rb', line 35 def type @type end |
Class Method Details
.check_compatibility(formula, deps, keg, compiler) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'Library/Homebrew/cxxstdlib.rb', line 23 def self.check_compatibility(formula, deps, keg, compiler) return if formula.skip_cxxstdlib_check? stdlib = create(keg.detect_cxx_stdlibs.first, compiler) begin stdlib.check_dependencies(formula, deps) rescue CompatibilityError => e opoo e. end end |
.create(type, compiler) ⇒ Object
15 16 17 18 19 20 21 |
# File 'Library/Homebrew/cxxstdlib.rb', line 15 def self.create(type, compiler) if type && ![:libstdcxx, :libcxx].include?(type) raise ArgumentError, "Invalid C++ stdlib type: #{type}" end klass = (compiler.to_s =~ GNU_GCC_REGEXP) ? GnuStdlib : AppleStdlib klass.new(type, compiler) end |
Instance Method Details
#check_dependencies(formula, deps) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'Library/Homebrew/cxxstdlib.rb', line 55 def check_dependencies(formula, deps) deps.each do |dep| # Software is unlikely to link against libraries from build-time deps, so # it doesn't matter if they link against different C++ stdlibs. next if dep.build? dep_stdlib = Tab.for_formula(dep.to_formula).cxxstdlib unless compatible_with? dep_stdlib raise CompatibilityError.new(formula, dep, dep_stdlib) end end end |
#compatible_with?(other) ⇒ Boolean
If either package doesn't use C++, all is well libstdc++ and libc++ aren't ever intercompatible libstdc++ is compatible across Apple compilers, but not between Apple and GNU compilers, or between GNU compiler versions
46 47 48 49 50 51 52 53 |
# File 'Library/Homebrew/cxxstdlib.rb', line 46 def compatible_with?(other) return true if type.nil? || other.type.nil? return false unless type == other.type apple_compiler? && other.apple_compiler? || !other.apple_compiler? && compiler.to_s[4..6] == other.compiler.to_s[4..6] end |
#inspect ⇒ Object
72 73 74 |
# File 'Library/Homebrew/cxxstdlib.rb', line 72 def inspect "#<#{self.class.name}: #{compiler} #{type}>" end |
#type_string ⇒ Object
68 69 70 |
# File 'Library/Homebrew/cxxstdlib.rb', line 68 def type_string type.to_s.gsub(/cxx$/, "c++") end |