OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2013 The Chromium Authors. All rights reserved. | 2 # Copyright 2013 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """ | 6 """ |
7 Removes bundled libraries to make sure they are not used. | 7 Removes bundled libraries to make sure they are not used. |
8 | 8 |
9 See README for more details. | 9 See README for more details. |
10 """ | 10 """ |
(...skipping 29 matching lines...) Expand all Loading... |
40 root_relpath = os.path.relpath(root, source_tree_root) | 40 root_relpath = os.path.relpath(root, source_tree_root) |
41 if 'third_party' not in root_relpath.split(os.sep): | 41 if 'third_party' not in root_relpath.split(os.sep): |
42 continue | 42 continue |
43 | 43 |
44 for f in files: | 44 for f in files: |
45 path = os.path.join(root, f) | 45 path = os.path.join(root, f) |
46 relpath = os.path.relpath(path, source_tree_root) | 46 relpath = os.path.relpath(path, source_tree_root) |
47 | 47 |
48 excluded = False | 48 excluded = False |
49 for exclusion in args: | 49 for exclusion in args: |
| 50 # Require precise exclusions. Find the right-most third_party |
| 51 # in the relative path, and if there is more than one ignore |
| 52 # the exclusion if it's completely contained within the part |
| 53 # before right-most third_party path component. |
| 54 split = relpath.rsplit(os.sep + 'third_party' + os.sep, 1) |
| 55 if len(split) > 1 and split[0].startswith(exclusion): |
| 56 continue |
| 57 |
50 if relpath.startswith(exclusion): | 58 if relpath.startswith(exclusion): |
51 # Multiple exclusions can match the same path. Go through all of them | 59 # Multiple exclusions can match the same path. Go through all of them |
52 # and mark each one as used. | 60 # and mark each one as used. |
53 exclusion_used[exclusion] = True | 61 exclusion_used[exclusion] = True |
54 excluded = True | 62 excluded = True |
55 if excluded: | 63 if excluded: |
56 continue | 64 continue |
57 | 65 |
58 # Deleting gyp files almost always leads to gyp failures. | 66 # Deleting gyp files almost always leads to gyp failures. |
59 # These files come from Chromium project, and can be replaced if needed. | 67 # These files come from Chromium project, and can be replaced if needed. |
(...skipping 25 matching lines...) Expand all Loading... |
85 | 93 |
86 if not options.do_remove: | 94 if not options.do_remove: |
87 print ('To actually remove files printed above, please pass ' + | 95 print ('To actually remove files printed above, please pass ' + |
88 '--do-remove flag.') | 96 '--do-remove flag.') |
89 | 97 |
90 return exit_code | 98 return exit_code |
91 | 99 |
92 | 100 |
93 if __name__ == '__main__': | 101 if __name__ == '__main__': |
94 sys.exit(DoMain(sys.argv[1:])) | 102 sys.exit(DoMain(sys.argv[1:])) |
OLD | NEW |