From 3d26b7584721c485d4c9df38fc7e2130c28ef75f Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Fri, 22 Aug 2014 22:18:03 -0500 Subject: Pull common stdlib checking code into a method --- Library/Homebrew/cxxstdlib.rb | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'Library/Homebrew/cxxstdlib.rb') diff --git a/Library/Homebrew/cxxstdlib.rb b/Library/Homebrew/cxxstdlib.rb index 7847552ba..859c1aabb 100644 --- a/Library/Homebrew/cxxstdlib.rb +++ b/Library/Homebrew/cxxstdlib.rb @@ -11,6 +11,18 @@ class CxxStdlib klass.new(type, compiler) end + 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 IncompatibleCxxStdlibs => e + opoo e.message + end + end + attr_reader :type, :compiler def initialize(type, compiler) @@ -32,17 +44,14 @@ class CxxStdlib end def check_dependencies(formula, deps) - unless formula.skip_cxxstdlib_check? - deps.each do |dep| - # Software is unlikely to link against anything from its - # buildtime deps, so it doesn't matter at all if they link - # against different C++ stdlibs - next if dep.build? - - dep_stdlib = Tab.for_formula(dep.to_formula).cxxstdlib - if !compatible_with? dep_stdlib - raise IncompatibleCxxStdlibs.new(formula, dep, dep_stdlib, self) - end + 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 + if !compatible_with? dep_stdlib + raise IncompatibleCxxStdlibs.new(formula, dep, dep_stdlib, self) end end end -- cgit v1.2.3