| 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 '''Tool to determine inputs and outputs of a grit file. | 6 '''Tool to determine inputs and outputs of a grit file. |
| 7 ''' | 7 ''' |
| 8 | 8 |
| 9 import optparse | 9 import optparse |
| 10 import os | 10 import os |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 if f.endswith('.py') and not f.endswith('_unittest.py')] | 60 if f.endswith('.py') and not f.endswith('_unittest.py')] |
| 61 files.extend(grit_src) | 61 files.extend(grit_src) |
| 62 return sorted(files) | 62 return sorted(files) |
| 63 | 63 |
| 64 | 64 |
| 65 def Inputs(filename, defines, ids_file, target_platform=None): | 65 def Inputs(filename, defines, ids_file, target_platform=None): |
| 66 grd = grd_reader.Parse( | 66 grd = grd_reader.Parse( |
| 67 filename, debug=False, defines=defines, tags_to_ignore=set(['message']), | 67 filename, debug=False, defines=defines, tags_to_ignore=set(['message']), |
| 68 first_ids_file=ids_file, target_platform=target_platform) | 68 first_ids_file=ids_file, target_platform=target_platform) |
| 69 files = set() | 69 files = set() |
| 70 for lang, ctx in grd.GetConfigurations(): | 70 for lang, ctx, fallback in grd.GetConfigurations(): |
| 71 # TODO(tdanderson): Refactor all places which perform the action of setting |
| 72 # output attributes on the root. See crbug.com/503637. |
| 71 grd.SetOutputLanguage(lang or grd.GetSourceLanguage()) | 73 grd.SetOutputLanguage(lang or grd.GetSourceLanguage()) |
| 72 grd.SetOutputContext(ctx) | 74 grd.SetOutputContext(ctx) |
| 75 grd.SetFallbackToDefaultLayout(fallback) |
| 73 for node in grd.ActiveDescendants(): | 76 for node in grd.ActiveDescendants(): |
| 74 with node: | 77 with node: |
| 75 if (node.name == 'structure' or node.name == 'skeleton' or | 78 if (node.name == 'structure' or node.name == 'skeleton' or |
| 76 (node.name == 'file' and node.parent and | 79 (node.name == 'file' and node.parent and |
| 77 node.parent.name == 'translations')): | 80 node.parent.name == 'translations')): |
| 78 files.add(grd.ToRealPath(node.GetInputPath())) | 81 path = node.GetInputPath() |
| 82 if path is not None: |
| 83 files.add(grd.ToRealPath(path)) |
| 84 |
| 79 # If it's a flattened node, grab inlined resources too. | 85 # If it's a flattened node, grab inlined resources too. |
| 80 if node.name == 'structure' and node.attrs['flattenhtml'] == 'true': | 86 if node.name == 'structure' and node.attrs['flattenhtml'] == 'true': |
| 81 node.RunPreSubstitutionGatherer() | 87 node.RunPreSubstitutionGatherer() |
| 82 files.update(node.GetHtmlResourceFilenames()) | 88 files.update(node.GetHtmlResourceFilenames()) |
| 83 elif node.name == 'grit': | 89 elif node.name == 'grit': |
| 84 first_ids_file = node.GetFirstIdsFile() | 90 first_ids_file = node.GetFirstIdsFile() |
| 85 if first_ids_file: | 91 if first_ids_file: |
| 86 files.add(first_ids_file) | 92 files.add(first_ids_file) |
| 87 elif node.name == 'include': | 93 elif node.name == 'include': |
| 88 files.add(grd.ToRealPath(node.GetInputPath())) | 94 files.add(grd.ToRealPath(node.GetInputPath())) |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 except WrongNumberOfArguments, e: | 184 except WrongNumberOfArguments, e: |
| 179 PrintUsage() | 185 PrintUsage() |
| 180 print e | 186 print e |
| 181 return 1 | 187 return 1 |
| 182 print result | 188 print result |
| 183 return 0 | 189 return 0 |
| 184 | 190 |
| 185 | 191 |
| 186 if __name__ == '__main__': | 192 if __name__ == '__main__': |
| 187 sys.exit(main(sys.argv)) | 193 sys.exit(main(sys.argv)) |
| OLD | NEW |