ATLAS Offline Software
Loading...
Searching...
No Matches
dlldep.SharedLib Class Reference
Collaboration diagram for dlldep.SharedLib:

Public Member Functions

 __init__ (self, distance, lib)

Public Attributes

 lib = lib
 distance = distance
 deplibs = self._getLibs(lib)

Protected Member Functions

 _getLibs (self, lib)

Detailed Description

Represent a shared library with name, dependencies and other stats

Definition at line 52 of file dlldep.py.

Constructor & Destructor Documentation

◆ __init__()

dlldep.SharedLib.__init__ ( self,
distance,
lib )

Definition at line 55 of file dlldep.py.

55 def __init__(self, distance, lib):
56 import os.path as osp
57 lib = osp.expanduser(osp.expandvars(lib))
58 if not osp.exists(lib):
59 l = Dso.find_library(lib)
60 if l:
61 lib = l
62 assert osp.exists(lib), "no such path [%s]" % (lib,)
63 self.lib = lib # path of library
64 self.distance = distance # distance from root lib
65 self.deplibs = self._getLibs(lib) # direct dependencies
66

Member Function Documentation

◆ _getLibs()

dlldep.SharedLib._getLibs ( self,
lib )
protected
Get direct dependencies of shared library

Definition at line 67 of file dlldep.py.

67 def _getLibs(self, lib):
68 """Get direct dependencies of shared library"""
69
70 # First check if already in global cache
71 cachedlib = Cache.files.get(lib)
72 if cachedlib: return cachedlib.deplibs
73
74 # Run readelf to find direct dependencies
75 # Note: ldd itself does recursions so we cannot use it here
76 encargs = {'encoding' : 'utf-8'}
77 p = sp.Popen(["readelf","-d",lib], stdout=sp.PIPE, **encargs)
78 output = p.communicate()[0]
79 if p.returncode != 0:
80 print ("Cannot run 'readelf' on",lib)
81 return []
82
83 libs = []
84 for l in output.split("\n"):
85 if l.find("NEEDED")==-1: continue
86 libs += [l.split()[-1].strip("[]")]
87
88 # Run ldd to find full path of libraries
89 p = sp.Popen(["ldd",lib], stdout=sp.PIPE, **encargs)
90 output = p.communicate()[0]
91 if p.returncode != 0:
92 print ("Cannot run 'ldd' on",lib)
93 return []
94
95 libpaths = []
96 for l in output.split("\n"):
97 fields = l.strip().split()
98 if len(fields)!=4: continue
99 path = fields[2]
100 if (fields[0] in libs) and len(path)>0:
101 libpaths += [path]
102
103 return libpaths
104
105
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:177

Member Data Documentation

◆ deplibs

dlldep.SharedLib.deplibs = self._getLibs(lib)

Definition at line 65 of file dlldep.py.

◆ distance

dlldep.SharedLib.distance = distance

Definition at line 64 of file dlldep.py.

◆ lib

dlldep.SharedLib.lib = lib

Definition at line 63 of file dlldep.py.


The documentation for this class was generated from the following file: