| 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 if first_ids_file: | 89 if first_ids_file: |
| 90 files.append(first_ids_file) | 90 files.append(first_ids_file) |
| 91 elif node.name == 'include': | 91 elif node.name == 'include': |
| 92 # Only include files that we actually plan on using. | 92 # Only include files that we actually plan on using. |
| 93 if node.SatisfiesOutputCondition(): | 93 if node.SatisfiesOutputCondition(): |
| 94 files.append(node.FilenameToOpen()) | 94 files.append(node.FilenameToOpen()) |
| 95 # If it's a flattened node, grab inlined resources too. | 95 # If it's a flattened node, grab inlined resources too. |
| 96 if node.attrs['flattenhtml'] == 'true': | 96 if node.attrs['flattenhtml'] == 'true': |
| 97 files.extend(node.GetHtmlResourceFilenames()) | 97 files.extend(node.GetHtmlResourceFilenames()) |
| 98 | 98 |
| 99 return files | 99 cwd = os.getcwd() |
| 100 return [os.path.relpath(f, cwd) for f in files] |
| 100 | 101 |
| 101 | 102 |
| 102 def PrintUsage(): | 103 def PrintUsage(): |
| 103 print 'USAGE: ./grit_info.py --inputs [-D foo] <grd-file>' | 104 print 'USAGE: ./grit_info.py --inputs [-D foo] <grd-file>' |
| 104 print ' ./grit_info.py --outputs [-D foo] <out-prefix> <grd-file>' | 105 print ' ./grit_info.py --outputs [-D foo] <out-prefix> <grd-file>' |
| 105 | 106 |
| 106 | 107 |
| 107 def DoMain(argv): | 108 def DoMain(argv): |
| 108 parser = optparse.OptionParser() | 109 parser = optparse.OptionParser() |
| 109 parser.add_option("--inputs", action="store_true", dest="inputs") | 110 parser.add_option("--inputs", action="store_true", dest="inputs") |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 except WrongNumberOfArguments, e: | 162 except WrongNumberOfArguments, e: |
| 162 PrintUsage() | 163 PrintUsage() |
| 163 print e | 164 print e |
| 164 return 1 | 165 return 1 |
| 165 print result | 166 print result |
| 166 return 0 | 167 return 0 |
| 167 | 168 |
| 168 | 169 |
| 169 if __name__ == '__main__': | 170 if __name__ == '__main__': |
| 170 sys.exit(main(sys.argv)) | 171 sys.exit(main(sys.argv)) |
| OLD | NEW |