summaryrefslogtreecommitdiffstats
path: root/tools/check_ecs_deps
diff options
context:
space:
mode:
authorrjkroege@chromium.org <rjkroege@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-13 02:53:07 +0000
committerrjkroege@chromium.org <rjkroege@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-13 02:53:07 +0000
commita31461138d20673f718e0bd9fb4bb7aa9c1ff993 (patch)
treeb243891b3c12557318e2eaa112b625eabbaba387 /tools/check_ecs_deps
parent1c4fbc0b5c4f6bdaf7b0c3bc0e7e3cb5e9662fd5 (diff)
downloadchromium_src-a31461138d20673f718e0bd9fb4bb7aa9c1ff993.zip
chromium_src-a31461138d20673f718e0bd9fb4bb7aa9c1ff993.tar.gz
chromium_src-a31461138d20673f718e0bd9fb4bb7aa9c1ff993.tar.bz2
Add a tool to validate ecs library dependencies.
The embedded content_shell starting point for applications such as the ChromeCast shell must not include dependencies that would increase its memory footprint. This script automatically tests that it does not contain undesired dependencies. BUG=none Review URL: https://codereview.chromium.org/58603003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@234716 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/check_ecs_deps')
-rwxr-xr-xtools/check_ecs_deps/check_ecs_deps.py80
1 files changed, 80 insertions, 0 deletions
diff --git a/tools/check_ecs_deps/check_ecs_deps.py b/tools/check_ecs_deps/check_ecs_deps.py
new file mode 100755
index 0000000..e6a2001
--- /dev/null
+++ b/tools/check_ecs_deps/check_ecs_deps.py
@@ -0,0 +1,80 @@
+#!/usr/bin/env python
+# Copyright 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+''' Verifies that builds of the embedded content_shell do not included
+unnecessary dependencies.'''
+
+import getopt
+import os
+import re
+import string
+import subprocess
+import sys
+import optparse
+
+kUndesiredLibraryList = [
+ 'libcairo',
+ 'libpango',
+ 'libglib',
+]
+
+binary_target = 'content_shell'
+
+def _main():
+ parser = optparse.OptionParser(
+ "usage: %prog -b <dir> --target <Debug|Release>")
+ parser.add_option("-b", "--build-dir",
+ help="the location of the compiler output")
+ parser.add_option("--target", help="Debug or Release")
+
+ options, args = parser.parse_args()
+ # Bake target into build_dir.
+ if options.target and options.build_dir:
+ assert (options.target !=
+ os.path.basename(os.path.dirname(options.build_dir)))
+ options.build_dir = os.path.join(os.path.abspath(options.build_dir),
+ options.target)
+
+ if options.build_dir != None:
+ target = os.path.join(options.build_dir, binary_target)
+ else:
+ target = binary_target
+
+ forbidden_regexp = re.compile(string.join(kUndesiredLibraryList, '|'))
+ success = 0
+
+ p = subprocess.Popen(['ldd', target], stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ out, err = p.communicate()
+
+ if err != '':
+ print "Failed to execute ldd to analyze dependencies for " + target + ':'
+ print ' ' + err
+ print "FAILED\n"
+ return 1
+
+ if out == '':
+ print "No output to scan for forbidden dependencies?\n"
+ print "\nFAILED\n"
+ return 1
+
+ success = 1
+ deps = string.split(out, '\n')
+ for d in deps:
+ if re.search(forbidden_regexp, d) != None:
+ success = 0
+ print "Forbidden library: " + d
+
+ if success == 1:
+ print "\nSUCCESS\n"
+ return 0
+ else:
+ print "\nFAILED\n"
+ return 1
+
+if __name__ == "__main__":
+ # handle arguments...
+ # do something reasonable if not run with one...
+ sys.exit(_main())