OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 elif node.name == 'include': | 59 elif node.name == 'include': |
60 # Only include files that we actually plan on using. | 60 # Only include files that we actually plan on using. |
61 if node.SatisfiesOutputCondition(): | 61 if node.SatisfiesOutputCondition(): |
62 files.append(node.FilenameToOpen()) | 62 files.append(node.FilenameToOpen()) |
63 # If it's a flattened node, grab inlined resources too. | 63 # If it's a flattened node, grab inlined resources too. |
64 if node.attrs['flattenhtml'] == 'true': | 64 if node.attrs['flattenhtml'] == 'true': |
65 files.extend(node.GetHtmlResourceFilenames()) | 65 files.extend(node.GetHtmlResourceFilenames()) |
66 | 66 |
67 # Add in the grit source files. If one of these change, we want to re-run | 67 # Add in the grit source files. If one of these change, we want to re-run |
68 # grit. | 68 # grit. |
69 grit_root_dir = os.path.relpath(os.path.dirname(__file__), os.getcwd()) | 69 grit_root_dir = os.path.dirname(__file__) |
70 for root, dirs, filenames in os.walk(grit_root_dir): | 70 for root, dirs, filenames in os.walk(grit_root_dir): |
71 grit_src = [os.path.join(root, f) for f in filenames | 71 grit_src = [os.path.join(root, f) for f in filenames |
72 if f.endswith('.py') or f == 'resource_ids'] | 72 if f.endswith('.py') or f == 'resource_ids'] |
73 files.extend(grit_src) | 73 files.extend(grit_src) |
74 | 74 |
75 return [f.replace('\\', '/') for f in files] | 75 return [f.replace('\\', '/') for f in files] |
76 | 76 |
77 | 77 |
78 def PrintUsage(): | 78 def PrintUsage(): |
79 print 'USAGE: ./grit_info.py --inputs [-D foo] <grd-files>..' | 79 print 'USAGE: ./grit_info.py --inputs [-D foo] <grd-files>..' |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 result = DoMain(argv[1:]) | 122 result = DoMain(argv[1:]) |
123 if result == None: | 123 if result == None: |
124 PrintUsage() | 124 PrintUsage() |
125 return 1 | 125 return 1 |
126 print result | 126 print result |
127 return 0 | 127 return 0 |
128 | 128 |
129 | 129 |
130 if __name__ == '__main__': | 130 if __name__ == '__main__': |
131 sys.exit(main(sys.argv)) | 131 sys.exit(main(sys.argv)) |
OLD | NEW |