| 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 |
| 11 import posixpath | 11 import posixpath |
| 12 import sys | 12 import sys |
| 13 | 13 |
| 14 from grit import grd_reader | 14 from grit import grd_reader |
| 15 from grit import util | 15 from grit import util |
| 16 | 16 |
| 17 class WrongNumberOfArguments(Exception): | 17 class WrongNumberOfArguments(Exception): |
| 18 pass | 18 pass |
| 19 | 19 |
| 20 | 20 |
| 21 def Outputs(filename, defines, ids_file, target_platform): | 21 def Outputs(filename, defines, ids_file, target_platform=None): |
| 22 grd = grd_reader.Parse( | 22 grd = grd_reader.Parse( |
| 23 filename, defines=defines, tags_to_ignore=set(['messages']), | 23 filename, defines=defines, tags_to_ignore=set(['messages']), |
| 24 first_ids_file=ids_file, target_platform=target_platform) | 24 first_ids_file=ids_file, target_platform=target_platform) |
| 25 | 25 |
| 26 target = [] | 26 target = [] |
| 27 lang_folders = {} | 27 lang_folders = {} |
| 28 # Add all explicitly-specified output files | 28 # Add all explicitly-specified output files |
| 29 for output in grd.GetOutputFiles(): | 29 for output in grd.GetOutputFiles(): |
| 30 path = output.GetFilename() | 30 path = output.GetFilename() |
| 31 target.append(path) | 31 target.append(path) |
| (...skipping 23 matching lines...) Expand all Loading... |
| 55 def GritSourceFiles(): | 55 def GritSourceFiles(): |
| 56 files = [] | 56 files = [] |
| 57 grit_root_dir = os.path.relpath(os.path.dirname(__file__), os.getcwd()) | 57 grit_root_dir = os.path.relpath(os.path.dirname(__file__), os.getcwd()) |
| 58 for root, dirs, filenames in os.walk(grit_root_dir): | 58 for root, dirs, filenames in os.walk(grit_root_dir): |
| 59 grit_src = [os.path.join(root, f) for f in filenames | 59 grit_src = [os.path.join(root, f) for f in filenames |
| 60 if f.endswith('.py')] | 60 if f.endswith('.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): | 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 in grd.GetConfigurations(): |
| 71 grd.SetOutputLanguage(lang or grd.GetSourceLanguage()) | 71 grd.SetOutputLanguage(lang or grd.GetSourceLanguage()) |
| 72 grd.SetOutputContext(ctx) | 72 grd.SetOutputContext(ctx) |
| 73 for node in grd.ActiveDescendants(): | 73 for node in grd.ActiveDescendants(): |
| 74 with node: | 74 with node: |
| 75 if (node.name == 'structure' or node.name == 'skeleton' or | 75 if (node.name == 'structure' or node.name == 'skeleton' or |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 except WrongNumberOfArguments, e: | 172 except WrongNumberOfArguments, e: |
| 173 PrintUsage() | 173 PrintUsage() |
| 174 print e | 174 print e |
| 175 return 1 | 175 return 1 |
| 176 print result | 176 print result |
| 177 return 0 | 177 return 0 |
| 178 | 178 |
| 179 | 179 |
| 180 if __name__ == '__main__': | 180 if __name__ == '__main__': |
| 181 sys.exit(main(sys.argv)) | 181 sys.exit(main(sys.argv)) |
| OLD | NEW |