diff options
| -rw-r--r-- | Library/Homebrew/cxxstdlib.rb | 23 | ||||
| -rw-r--r-- | Library/Homebrew/test/test_stdlib.rb | 4 |
2 files changed, 16 insertions, 11 deletions
diff --git a/Library/Homebrew/cxxstdlib.rb b/Library/Homebrew/cxxstdlib.rb index 06599e7db..34ce92d99 100644 --- a/Library/Homebrew/cxxstdlib.rb +++ b/Library/Homebrew/cxxstdlib.rb @@ -23,7 +23,18 @@ class CxxStdlib # libstdc++ is compatible across Apple compilers, but # not between Apple and GNU compilers, or between GNU compiler versions def compatible_with?(other) - type.nil? || other.type.nil? || type == other.type + return true if type.nil? || other.type.nil? + + return false unless type == other.type + + if apple_compiler? + return false unless other.apple_compiler? + else + return false if other.apple_compiler? + return false unless compiler.to_s[4..6] == other.compiler.to_s[4..6] + end + + true end def check_dependencies(formula, deps) @@ -50,21 +61,11 @@ class CxxStdlib def apple_compiler? true end - - def compatible_with?(other) - super && other.apple_compiler? - end end class GnuStdlib < CxxStdlib def apple_compiler? false end - - def compatible_with?(other) - super && - !other.apple_compiler? && - compiler.to_s[4..6] == other.compiler.to_s[4..6] - end end end diff --git a/Library/Homebrew/test/test_stdlib.rb b/Library/Homebrew/test/test_stdlib.rb index 55b10641c..50594465c 100644 --- a/Library/Homebrew/test/test_stdlib.rb +++ b/Library/Homebrew/test/test_stdlib.rb @@ -57,5 +57,9 @@ class CxxStdlibTests < Homebrew::TestCase def test_compatibility_for_non_cxx_software assert @purec.compatible_with?(@clang) + assert @clang.compatible_with?(@purec) + assert @purec.compatible_with?(@purec) + assert @purec.compatible_with?(@gcc48) + assert @gcc48.compatible_with?(@purec) end end |
