Chromium Code Reviews| Index: build/linux/unbundle/remove_bundled_libraries.py |
| diff --git a/build/linux/unbundle/remove_bundled_libraries.py b/build/linux/unbundle/remove_bundled_libraries.py |
| new file mode 100755 |
| index 0000000000000000000000000000000000000000..69b2a49f30fd136b43ce288f59d0a22bceee25b9 |
| --- /dev/null |
| +++ b/build/linux/unbundle/remove_bundled_libraries.py |
| @@ -0,0 +1,66 @@ |
| +#!/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. |
| + |
| +""" |
| +Removes bundled libraries to make sure they are not used. |
| +""" |
| + |
| + |
| +import os.path |
| +import sys |
| + |
| + |
| +def DoMain(argv): |
| + my_dirname = os.path.dirname(__file__) |
| + source_tree_root = os.path.abspath( |
|
Lei Zhang
2013/08/21 01:27:03
Please add some sanity checks to prevent this scri
|
| + os.path.join(my_dirname, '..', '..', '..')) |
| + |
| + exclusion_used = {} |
| + for exclusion in argv: |
| + exclusion_used[exclusion] = False |
| + |
| + for root, dirs, files in os.walk(source_tree_root, topdown=False): |
| + # Only look at paths which contain a "third_party" component |
| + # (note that e.g. third_party.png doesn't count). |
| + root_relpath = os.path.relpath(root, source_tree_root) |
| + if 'third_party' not in root_relpath.split(os.sep): |
| + continue |
| + |
| + for f in files: |
| + path = os.path.join(root, f) |
| + relpath = os.path.relpath(path, source_tree_root) |
| + |
| + excluded = False |
| + for exclusion in argv: |
| + if relpath.startswith(exclusion): |
| + # Multiple exclusions can match the same path. Go through all of them |
| + # and mark each one as used. |
| + exclusion_used[exclusion] = True |
| + excluded = True |
| + if excluded: |
| + continue |
| + |
| + # Deleting gyp files almost always leads to gyp failures. |
| + # These files come from Chromium project, and can be replaced if needed. |
| + if f.endswith('.gyp') or f.endswith('.gypi'): |
| + continue |
| + |
| + # Delete the file - best way to ensure it's not used during build. |
| + os.remove(path) |
| + |
| + exit_code = 0 |
| + |
| + # Fail if exclusion list contains stale entries - this helps keep it |
| + # up to date. |
| + for exclusion, used in exclusion_used.iteritems(): |
| + if not used: |
| + print '%s does not exist' % exclusion |
| + exit_code = 1 |
| + |
| + return exit_code |
| + |
| + |
| +if __name__ == '__main__': |
| + sys.exit(DoMain(sys.argv[1:])) |