From 77b678cea95b762cbeda3f2d69b93c43a3848a15 Mon Sep 17 00:00:00 2001 From: Misty De Meo Date: Sun, 6 Oct 2013 16:59:39 -0700 Subject: CxxStdlib: allow for nil stdlibs A nil stdlib value represents non-C++ code. --- Library/Homebrew/cxxstdlib.rb | 7 +++++-- Library/Homebrew/test/test_stdlib.rb | 5 +++++ 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/cxxstdlib.rb b/Library/Homebrew/cxxstdlib.rb index 4e3bed22e..06668e991 100644 --- a/Library/Homebrew/cxxstdlib.rb +++ b/Library/Homebrew/cxxstdlib.rb @@ -2,11 +2,11 @@ class CxxStdlib attr_accessor :type, :compiler def initialize(type, compiler) - if ![:libstdcxx, :libcxx].include? type + if type && ![:libstdcxx, :libcxx].include?(type) raise ArgumentError, "Invalid C++ stdlib type: #{type}" end - @type = type.to_sym + @type = type.to_sym if type @compiler = compiler.to_sym end @@ -15,6 +15,9 @@ class CxxStdlib end def compatible_with?(other) + # If either package doesn't use C++, all is well + return true if type.nil? || other.type.nil? + # libstdc++ and libc++ aren't ever intercompatible return false unless type == other.type diff --git a/Library/Homebrew/test/test_stdlib.rb b/Library/Homebrew/test/test_stdlib.rb index a5e276746..79af446d7 100644 --- a/Library/Homebrew/test/test_stdlib.rb +++ b/Library/Homebrew/test/test_stdlib.rb @@ -13,6 +13,7 @@ class CxxStdlibTests < Test::Unit::TestCase @gcc48 = CxxStdlib.new(:libstdcxx, 'gcc-4.8') @gcc49 = CxxStdlib.new(:libstdcxx, 'gcc-4.9') @lcxx = CxxStdlib.new(:libcxx, :clang) + @purec = CxxStdlib.new(nil, :clang) end def test_apple_libstdcxx_intercompatibility @@ -59,4 +60,8 @@ class CxxStdlibTests < Test::Unit::TestCase assert_equal stdlib.compiler, :clang assert_equal stdlib.type, :libstdcxx end + + def test_compatibility_for_non_cxx_software + assert @purec.compatible_with?(@clang) + end end -- cgit v1.2.3