aboutsummaryrefslogtreecommitdiffstats
path: root/doc/scripts
diff options
context:
space:
mode:
authorlloyd <[email protected]>2009-07-15 14:45:05 +0000
committerlloyd <[email protected]>2009-07-15 14:45:05 +0000
commit11470400cd77cbd20f60247f0a07fcac45772646 (patch)
tree1d61637224d4718b98e5b8d540600617eff81daf /doc/scripts
parentd5ee63b00a11b72442cf7f38a78f262b7728f130 (diff)
Add a script that analyzes the source and prints module dependencies.
Useful for tracking where the big balls of mud are. Fix dependencies in gost_3411 (depends on the gost block cipher), and the TLS PRF (depends on HMAC). Also hide TLS_PRF::P_hash in an anonymous namespace instead of making it a private static function. I don't think this will affect binary compat, since it was statically linked.
Diffstat (limited to 'doc/scripts')
-rwxr-xr-xdoc/scripts/print_deps.py70
1 files changed, 70 insertions, 0 deletions
diff --git a/doc/scripts/print_deps.py b/doc/scripts/print_deps.py
new file mode 100755
index 000000000..b92c43310
--- /dev/null
+++ b/doc/scripts/print_deps.py
@@ -0,0 +1,70 @@
+#!/usr/bin/python
+
+"""
+Analyze the botan source tree and print the module interdependencies
+
+(C) 2009 Jack Lloyd
+Distributed under the terms of the Botan license
+"""
+
+import os
+import os.path
+import sys
+import re
+
+def find_deps_in(filename):
+ # By convention #include's with spaces before them are
+ # always wrapped in #ifdef blocks
+ regexp = re.compile('^#include <botan/(.*)>')
+
+ for line in open(filename).readlines():
+ match = regexp.match(line)
+ if match != None:
+ yield match.group(1)
+
+def get_dependencies(dirname):
+ all_dirdeps = {}
+ file_homes = {}
+
+ is_sourcefile = re.compile('\.(cpp|h|S)$')
+
+ for (dirpath, dirnames, filenames) in os.walk('src'):
+ dirdeps = set()
+ for filename in filenames:
+ if is_sourcefile.search(filename) != None:
+ file_homes[filename] = os.path.basename(dirpath)
+
+ for dep in find_deps_in(os.path.join(dirpath, filename)):
+ if dep not in filenames and dep != 'build.h':
+ dirdeps.add(dep)
+
+ dirdeps = sorted(dirdeps)
+ if dirdeps != []:
+ all_dirdeps[dirpath] = dirdeps
+
+ return (all_dirdeps, file_homes)
+
+def main():
+ (all_dirdeps, file_homes) = get_dependencies('src')
+
+ def interesting_dep_for(dirname):
+ def interesting_dep(dep):
+ if dep == 'utils':
+ return False # everything depends on it
+
+ # block/serpent depends on block, etc
+ if dirname.find('/%s/' % (dep)) > 0:
+ return False
+ return True
+ return interesting_dep
+
+ for dirname in sorted(all_dirdeps.keys()):
+ depdirs = sorted(set(map(lambda x: file_homes[x], all_dirdeps[dirname])))
+
+ depdirs = filter(interesting_dep_for(dirname), depdirs)
+
+ if depdirs != []:
+ print "%s: %s" % (dirname, ' '.join(depdirs))
+
+if __name__ == '__main__':
+ sys.exit(main())