File deps.py changed (mode: 100755) (index 46cb5cb..6483943) |
... |
... |
symbols = {} |
17 |
17 |
objects = [] |
objects = [] |
18 |
18 |
|
|
19 |
19 |
class objModule: |
class objModule: |
20 |
|
def __init__(self, fileName): |
|
|
20 |
|
def __init__(self, fileName, name = None): |
21 |
21 |
self._fileName = fileName |
self._fileName = fileName |
22 |
|
self._name = os.path.basename(fileName) |
|
|
22 |
|
self._name = os.path.basename(fileName) if name is None else name |
23 |
23 |
self._importTable = [] |
self._importTable = [] |
24 |
24 |
self._exportTable = [] |
self._exportTable = [] |
25 |
25 |
def addImport(self, entry): |
def addImport(self, entry): |
|
... |
... |
class function: |
83 |
83 |
self._importCounter += 1 |
self._importCounter += 1 |
84 |
84 |
self.importedBy += [mod] |
self.importedBy += [mod] |
85 |
85 |
def addExport(self, mod): |
def addExport(self, mod): |
86 |
|
assert self._mod is None |
|
|
86 |
|
assert self._mod is None, ("%s: %s & %s" % |
|
87 |
|
(self.name, self._mod.getName(), mod.getName())) |
87 |
88 |
self._exportCounter = 1 |
self._exportCounter = 1 |
88 |
89 |
self._mod = mod; |
self._mod = mod; |
89 |
90 |
def isUsers(self): |
def isUsers(self): |
|
... |
... |
def listUserFuncs(): |
253 |
254 |
print '%s %s %s (%s)' % (func.name, func.getMod(), len(func.importedBy), |
print '%s %s %s (%s)' % (func.name, func.getMod(), len(func.importedBy), |
254 |
255 |
lst) |
lst) |
255 |
256 |
|
|
|
257 |
|
def dirGroupName(path, root): |
|
258 |
|
if not root: |
|
259 |
|
return os.path.dirname(path) |
|
260 |
|
return os.path.relpath(os.path.dirname(path), root) |
|
261 |
|
|
256 |
262 |
def main(): |
def main(): |
257 |
263 |
parser = argparse.ArgumentParser(description='Object file analyzer') |
parser = argparse.ArgumentParser(description='Object file analyzer') |
258 |
264 |
parser.add_argument('--moddeps', dest='moddeps', action='store_true', |
parser.add_argument('--moddeps', dest='moddeps', action='store_true', |
|
... |
... |
def main(): |
275 |
281 |
help='List table of exported user symbols') |
help='List table of exported user symbols') |
276 |
282 |
parser.add_argument('--unused', dest='unused', action='store_true', |
parser.add_argument('--unused', dest='unused', action='store_true', |
277 |
283 |
help='List exported, but unused symbols') |
help='List exported, but unused symbols') |
|
284 |
|
parser.add_argument('--group-dirs', dest='group_dirs', action='store_true', |
|
285 |
|
help='Group files inside directories into units') |
|
286 |
|
parser.add_argument('--root', dest='root', |
|
287 |
|
help='Group files inside directories into units') |
278 |
288 |
parser.add_argument('obj', nargs='+', |
parser.add_argument('obj', nargs='+', |
279 |
289 |
help='Object file to get information from') |
help='Object file to get information from') |
280 |
290 |
args = parser.parse_args() |
args = parser.parse_args() |
|
... |
... |
def main(): |
291 |
301 |
for mod in modulesList: |
for mod in modulesList: |
292 |
302 |
objModules[mod.getName()] = mod |
objModules[mod.getName()] = mod |
293 |
303 |
|
|
|
304 |
|
if args.group_dirs: |
|
305 |
|
newObjModules = {} |
|
306 |
|
newSymbols = {} |
|
307 |
|
for mod in modulesList: |
|
308 |
|
dirName = dirGroupName(mod.getFileName(), args.root) |
|
309 |
|
newObjModules[dirName] = objModule(dirName, dirName + "/*") |
|
310 |
|
for modA in modulesList: |
|
311 |
|
modAdirName = dirGroupName(modA.getFileName(), args.root) |
|
312 |
|
for export in modA.getAllExports(): |
|
313 |
|
name = export.name |
|
314 |
|
if newSymbols.has_key(name): |
|
315 |
|
func = newSymbols[name] |
|
316 |
|
else: |
|
317 |
|
func = function(name) |
|
318 |
|
newSymbols[name] = func |
|
319 |
|
newObjModules[modAdirName].addExport(func) |
|
320 |
|
|
|
321 |
|
for modB in export.importedBy: |
|
322 |
|
modBdirName = dirGroupName(modB.getFileName(), args.root) |
|
323 |
|
newObjModules[modBdirName].addImport(func) |
|
324 |
|
|
|
325 |
|
global symbols |
|
326 |
|
global objects |
|
327 |
|
symbols = newSymbols |
|
328 |
|
objects = [] |
|
329 |
|
|
|
330 |
|
objModules = newObjModules |
|
331 |
|
|
294 |
332 |
# add special system module |
# add special system module |
295 |
333 |
sysMod = objModule('system') |
sysMod = objModule('system') |
296 |
334 |
objModules['system'] = sysMod |
objModules['system'] = sysMod |