diff options
| author | Misty De Meo | 2013-10-06 01:51:31 -0700 | 
|---|---|---|
| committer | Misty De Meo | 2013-10-06 19:26:06 -0700 | 
| commit | 52af93123a067aa50e6ba8c23d395875cdcc9871 (patch) | |
| tree | 67fad475905b4bc45cb202ff52c7099ee7647f11 /Library/Homebrew/keg_fix_install_names.rb | |
| parent | d14b2ec7ad18e5f5f945cd47d154af74a48eba60 (diff) | |
| download | homebrew-52af93123a067aa50e6ba8c23d395875cdcc9871.tar.bz2 | |
Only track C++ stdlibs for C++ code
After a formula is built, scan all mach-o files for dynamic links
to see if any of them point to a C++ stdlib (libc++ or libstdc++).
If one of them is linked, record that information in the formula's tab.
This replaces the old behaviour where all files were assumed to be C++
code, and stdlibs were always tracked regardless of whether they were
actually linked against.
This also modifies the way that tabs are written - now tabs are written
with the stdlib field null, and values are only written if an stdlib
is detected.
Diffstat (limited to 'Library/Homebrew/keg_fix_install_names.rb')
| -rw-r--r-- | Library/Homebrew/keg_fix_install_names.rb | 15 | 
1 files changed, 15 insertions, 0 deletions
diff --git a/Library/Homebrew/keg_fix_install_names.rb b/Library/Homebrew/keg_fix_install_names.rb index fdb348608..3b37ccf26 100644 --- a/Library/Homebrew/keg_fix_install_names.rb +++ b/Library/Homebrew/keg_fix_install_names.rb @@ -42,6 +42,21 @@ class Keg      end    end +  # Detects the C++ dynamic libraries in place, scanning the dynamic links +  # of the files within the keg. +  # Note that this doesn't attempt to distinguish between libstdc++ versions, +  # for instance between Apple libstdc++ and GNU libstdc++ +  def detect_cxx_stdlibs +    results = Set.new +    mach_o_files.each do |file| +      dylibs = file.dynamically_linked_libraries +      results << :libcxx unless dylibs.grep(/libc\+\+.+\.dylib/).empty? +      results << :libstdcxx unless dylibs.grep(/libstdc\+\+.+\.dylib/).empty? +    end + +    results.to_a +  end +    private    OTOOL_RX = /\t(.*) \(compatibility version (\d+\.)*\d+, current version (\d+\.)*\d+\)/  | 
