Skip to content
Snippets Groups Projects
Unverified Commit 958c5c7f authored by Markus Reiter's avatar Markus Reiter Committed by GitHub
Browse files

Merge pull request #8349 from reitermarkus/doc-cxxstdlib

Refactor and document `CxxStdlib`.
parents a72c9717 4eff378d
No related branches found
No related tags found
No related merge requests found
......@@ -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
def apple_compiler?
@apple_compiler
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment