| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 """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 |
| 7 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 |
| 8 and figure out what isn't in use any more. | 8 and figure out what isn't in use any more. |
| 9 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 |
| 10 check instead. | 10 check instead. |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 for file_path, file_ids in file_id_map.iteritems(): | 104 for file_path, file_ids in file_id_map.iteritems(): |
| 105 missing = ids_left.intersection(file_ids) | 105 missing = ids_left.intersection(file_ids) |
| 106 if len(missing) > 0: | 106 if len(missing) > 0: |
| 107 print ' %s:' % (file_path) | 107 print ' %s:' % (file_path) |
| 108 print '\n'.join(' %s' % (x) for x in sorted(missing)) | 108 print '\n'.join(' %s' % (x) for x in sorted(missing)) |
| 109 | 109 |
| 110 return 0 | 110 return 0 |
| 111 | 111 |
| 112 | 112 |
| 113 def main(): | 113 def main(): |
| 114 # script lives in src/chrome/tools | 114 # script lives in src/tools |
| 115 chrome_tools_dir = os.path.dirname(os.path.abspath(sys.argv[0])) | 115 tools_dir = os.path.dirname(os.path.abspath(sys.argv[0])) |
| 116 src_dir = os.path.dirname(os.path.dirname(chrome_tools_dir)) | 116 src_dir = os.path.dirname(tools_dir) |
| 117 chrome_dir = os.path.join(src_dir, 'chrome') | |
| 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) |
| 125 else: | 124 else: |
| 126 src_dirs.append(arg) | 125 src_dirs.append(arg) |
| 127 | 126 |
| 128 # If no GRD files were given, default them: | 127 # If no GRD files were given, default them: |
| 129 if len(grd_files) == 0: | 128 if len(grd_files) == 0: |
| 130 ash_base_dir = os.path.join(src_dir, 'ash') | 129 ash_base_dir = os.path.join(src_dir, 'ash') |
| 130 chrome_dir = os.path.join(src_dir, 'chrome') |
| 131 chrome_app_dir = os.path.join(chrome_dir, 'app') | 131 chrome_app_dir = os.path.join(chrome_dir, 'app') |
| 132 chrome_app_res_dir = os.path.join(chrome_app_dir, 'resources') | 132 chrome_app_res_dir = os.path.join(chrome_app_dir, 'resources') |
| 133 device_base_dir = os.path.join(src_dir, 'device') | 133 device_base_dir = os.path.join(src_dir, 'device') |
| 134 ui_dir = os.path.join(src_dir, 'ui') | 134 ui_dir = os.path.join(src_dir, 'ui') |
| 135 ui_strings_dir = os.path.join(ui_dir, 'strings') | 135 ui_strings_dir = os.path.join(ui_dir, 'strings') |
| 136 ui_chromeos_dir = os.path.join(ui_dir, 'chromeos') | 136 ui_chromeos_dir = os.path.join(ui_dir, 'chromeos') |
| 137 grd_files = [ | 137 grd_files = [ |
| 138 os.path.join(ash_base_dir, 'ash_strings.grd'), | 138 os.path.join(ash_base_dir, 'ash_strings.grd'), |
| 139 os.path.join(ash_base_dir, 'resources', 'ash_resources.grd'), | 139 os.path.join(ash_base_dir, 'resources', 'ash_resources.grd'), |
| 140 os.path.join(chrome_app_dir, 'chromium_strings.grd'), | 140 os.path.join(chrome_app_dir, 'chromium_strings.grd'), |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 # nsNSSCertHelper.cpp has a bunch of ids | 174 # nsNSSCertHelper.cpp has a bunch of ids |
| 175 os.path.join(src_dir, 'third_party', 'mozilla_security_manager'), | 175 os.path.join(src_dir, 'third_party', 'mozilla_security_manager'), |
| 176 os.path.join(chrome_dir, 'installer'), | 176 os.path.join(chrome_dir, 'installer'), |
| 177 ] | 177 ] |
| 178 | 178 |
| 179 return CheckForUnusedGrdIDsInSources(grd_files, src_dirs) | 179 return CheckForUnusedGrdIDsInSources(grd_files, src_dirs) |
| 180 | 180 |
| 181 | 181 |
| 182 if __name__ == '__main__': | 182 if __name__ == '__main__': |
| 183 sys.exit(main()) | 183 sys.exit(main()) |
| OLD | NEW |