From 105db77fc08df7a8dc85dcef626ec82998207117 Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Sat, 9 Aug 2014 17:47:10 -0500 Subject: [PATCH] Extract build-time stdlib check to a method --- Library/Homebrew/build.rb | 48 ++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/Library/Homebrew/build.rb b/Library/Homebrew/build.rb index ef7c2c45d9..ff35b797a0 100644 --- a/Library/Homebrew/build.rb +++ b/Library/Homebrew/build.rb @@ -163,29 +163,7 @@ class Build begin f.install - - keg = Keg.new(f.prefix) - # This first test includes executables because we still - # want to record the stdlib for something that installs no - # dylibs. - stdlibs = keg.detect_cxx_stdlibs - # This currently only tracks a single C++ stdlib per dep, - # though it's possible for different libs/executables in - # a given formula to link to different ones. - stdlib_in_use = CxxStdlib.create(stdlibs.first, ENV.compiler) - begin - stdlib_in_use.check_dependencies(f, deps) - rescue IncompatibleCxxStdlibs => e - opoo e.message - end - - # This second check is recorded for checking dependencies, - # so executable are irrelevant at this point. If a piece - # of software installs an executable that links against libstdc++ - # and dylibs against libc++, libc++-only dependencies can safely - # link against it. - stdlibs = keg.detect_cxx_stdlibs :skip_executables => true - + stdlibs = detect_stdlibs Tab.create(f, ENV.compiler, stdlibs.first, f.build).write rescue Exception => e if ARGV.debug? @@ -201,6 +179,30 @@ class Build end end + def detect_stdlibs + keg = Keg.new(f.prefix) + # This first test includes executables because we still + # want to record the stdlib for something that installs no + # dylibs. + stdlibs = keg.detect_cxx_stdlibs + # This currently only tracks a single C++ stdlib per dep, + # though it's possible for different libs/executables in + # a given formula to link to different ones. + stdlib_in_use = CxxStdlib.create(stdlibs.first, ENV.compiler) + begin + stdlib_in_use.check_dependencies(f, deps) + rescue IncompatibleCxxStdlibs => e + opoo e.message + end + + # This second check is recorded for checking dependencies, + # so executable are irrelevant at this point. If a piece + # of software installs an executable that links against libstdc++ + # and dylibs against libc++, libc++-only dependencies can safely + # link against it. + stdlibs = keg.detect_cxx_stdlibs :skip_executables => true + end + def fixopt f path = if f.linked_keg.directory? and f.linked_keg.symlink? f.linked_keg.resolved_path