Changeset 324

Show
Ignore:
Timestamp:
Fri Nov 16 12:26:17 2007
Author:
danielevarrazzo
Message:

- Added getImports implementation using otool (available on darwin platform)

Covers the update [294] in /branches/mac.
[295] should not be required anymore.
- Using explicit names for implementation-dependant import functions.

Files:

Legend:

Unmodified
Added
Removed
Modified
  • trunk/bindepend.py

    r247 r324  
    71 71       'GLUB32.DLL':1,  
    72 72       '/usr/lib':1,  
    73         '/lib':1,}  
      73       '/lib':1,  
      74       '/System/Library/Frameworks':1,}  
    74 75  
    75 76 def getfullnameof(mod, xtrapath = None):  
     
    92 93   return ''  
    93 94  
    94   def getImports1(pth):  
      95 def _getImports_dumpbin(pth):  
    94 95     """Find the binary dependencies of PTH.  
    95 96  
     
    111 112     return rslt  
    112 113  
    113   def getImports2x(pth):  
      114 def _getImports_pe_x(pth):  
    113 114     """Find the binary dependencies of PTH.  
    114 115  
     
    176 177     return rslt  
    177 178  
    178   def getImports2(path):  
      179 def _getImports_pe(path):  
    178 179     """Find the binary dependencies of PTH.  
    179 180  
     
    276 277   return lTOC  
    277 278  
    278   def getImports3(pth):  
      279 def _getImports_ldd(pth):  
    278 279     """Find the binary dependencies of PTH.  
    279 280  
     
    297 298     return rslt  
    298 299  
      300 def _getImports_otool(pth):  
      301     """Find the binary dependencies of PTH.  
      302  
      303         This implementation is for otool platforms"""  
      304     rslt = []  
      305     for line in os.popen('otool -L "%s"' % pth).readlines():  
      306         m = re.search(r"\s+(.*?)\s+\(.*\)", line)  
      307         if m:  
      308             lib = m.group(1)  
      309             if os.path.exists(lib):  
      310                 rslt.append(lib)  
      311             else:  
      312                 print 'E: cannot find path %s (needed by %s)' % \  
      313                       (lib, pth)  
      314  
      315     return rslt  
      316  
    299 317 def getImports(pth):  
    300       """Forwards to either getImports2 or getImports3  
      318     """Forwards to the correct getImports implementation for the platform.  
    300 318     """  
    301 319     if sys.platform[:3] == 'win' or sys.platform == 'cygwin':  
    302           return getImports2(pth)  
    303       return getImports3(pth)  
      320         return _getImports_pe(pth)  
      321     elif sys.platform == 'darwin':  
      322         return _getImports_otool(pth)  
      323     else:  
      324         return _getImports_ldd(pth)  
    304 325  
    305 326 def getWindowsPath():