OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/env python |
2 | 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
3 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | |
4 # 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 |
5 # found in the LICENSE file. | 4 # found in the LICENSE file. |
6 | 5 |
7 """Without any args, this simply loads the IDs out of a bunch of the Chrome GRD | 6 """Without any args, this simply loads the IDs out of a bunch of the Chrome GRD |
8 files, and then checks the subset of the code that loads the strings to try | 7 files, and then checks the subset of the code that loads the strings to try |
9 and figure out what isn't in use any more. | 8 and figure out what isn't in use any more. |
10 You can give paths to GRD files and source directories to control what is | 9 You can give paths to GRD files and source directories to control what is |
11 check instead. | 10 check instead. |
12 """ | 11 """ |
13 | 12 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 print 'The following ids are in GRD files, but *appear* to be unused:' | 103 print 'The following ids are in GRD files, but *appear* to be unused:' |
105 for file_path, file_ids in file_id_map.iteritems(): | 104 for file_path, file_ids in file_id_map.iteritems(): |
106 missing = ids_left.intersection(file_ids) | 105 missing = ids_left.intersection(file_ids) |
107 if len(missing) > 0: | 106 if len(missing) > 0: |
108 print ' %s:' % (file_path) | 107 print ' %s:' % (file_path) |
109 print '\n'.join(' %s' % (x) for x in sorted(missing)) | 108 print '\n'.join(' %s' % (x) for x in sorted(missing)) |
110 | 109 |
111 return 0 | 110 return 0 |
112 | 111 |
113 | 112 |
114 if __name__ == '__main__': | 113 def main(): |
115 # script lives in src/chrome/tools | 114 # script lives in src/chrome/tools |
116 chrome_tools_dir = os.path.dirname(os.path.abspath(sys.argv[0])) | 115 chrome_tools_dir = os.path.dirname(os.path.abspath(sys.argv[0])) |
117 src_dir = os.path.dirname(os.path.dirname(chrome_tools_dir)) | 116 src_dir = os.path.dirname(os.path.dirname(chrome_tools_dir)) |
118 | 117 |
119 # Collect the args into the right buckets | 118 # Collect the args into the right buckets |
120 src_dirs = [] | 119 src_dirs = [] |
121 grd_files = [] | 120 grd_files = [] |
122 for arg in sys.argv[1:]: | 121 for arg in sys.argv[1:]: |
123 if arg.lower().endswith('.grd'): | 122 if arg.lower().endswith('.grd'): |
124 grd_files.append(arg) | 123 grd_files.append(arg) |
(...skipping 30 matching lines...) Expand all Loading... |
155 src_dirs = [ | 154 src_dirs = [ |
156 os.path.join(src_dir, 'app'), | 155 os.path.join(src_dir, 'app'), |
157 os.path.join(src_dir, 'content'), | 156 os.path.join(src_dir, 'content'), |
158 os.path.join(src_dir, 'chrome'), | 157 os.path.join(src_dir, 'chrome'), |
159 os.path.join(src_dir, 'ui'), | 158 os.path.join(src_dir, 'ui'), |
160 os.path.join(src_dir, 'views'), | 159 os.path.join(src_dir, 'views'), |
161 # nsNSSCertHelper.cpp has a bunch of ids | 160 # nsNSSCertHelper.cpp has a bunch of ids |
162 os.path.join(src_dir, 'third_party', 'mozilla_security_manager'), | 161 os.path.join(src_dir, 'third_party', 'mozilla_security_manager'), |
163 ] | 162 ] |
164 | 163 |
165 sys.exit(CheckForUnusedGrdIDsInSources(grd_files, src_dirs)) | 164 return CheckForUnusedGrdIDsInSources(grd_files, src_dirs) |
| 165 |
| 166 |
| 167 if __name__ == '__main__': |
| 168 sys.exit(main()) |
OLD | NEW |