67 def _getLibs(self, lib):
68 """Get direct dependencies of shared library"""
69
70
71 cachedlib = Cache.files.get(lib)
72 if cachedlib: return cachedlib.deplibs
73
74
75
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
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=":")