| OLD | NEW |
| 1 # Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 # Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 # for details. All rights reserved. Use of this source code is governed by a | 2 # for details. All rights reserved. Use of this source code is governed by a |
| 3 # BSD-style license that can be found in the LICENSE file. | 3 # BSD-style license that can be found in the LICENSE file. |
| 4 # | 4 # |
| 5 # This python script creates string literals in a C++ source file from a C++ | 5 # This python script creates string literals in a C++ source file from a C++ |
| 6 # source template and one or more resource files. | 6 # source template and one or more resource files. |
| 7 | 7 |
| 8 import os | 8 import os |
| 9 import sys | 9 import sys |
| 10 from os.path import join | 10 from os.path import join |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 parser.add_option("--outer_namespace", | 95 parser.add_option("--outer_namespace", |
| 96 action="store", type="string", | 96 action="store", type="string", |
| 97 help="outer C++ namespace", | 97 help="outer C++ namespace", |
| 98 default="dart") | 98 default="dart") |
| 99 parser.add_option("--inner_namespace", | 99 parser.add_option("--inner_namespace", |
| 100 action="store", type="string", | 100 action="store", type="string", |
| 101 help="inner C++ namespace") | 101 help="inner C++ namespace") |
| 102 parser.add_option("--table_name", | 102 parser.add_option("--table_name", |
| 103 action="store", type="string", | 103 action="store", type="string", |
| 104 help="name of table") | 104 help="name of table") |
| 105 parser.add_option("--client_root", |
| 106 action="store", type="string", |
| 107 help="root directory client resources") |
| 105 (options, args) = parser.parse_args() | 108 (options, args) = parser.parse_args() |
| 106 if not options.output: | 109 if not options.output: |
| 107 sys.stderr.write('--output not specified\n') | 110 sys.stderr.write('--output not specified\n') |
| 108 return -1 | 111 return -1 |
| 109 if not options.table_name: | 112 if not options.table_name: |
| 110 sys.stderr.write('--table_name not specified\n') | 113 sys.stderr.write('--table_name not specified\n') |
| 111 return -1 | 114 return -1 |
| 112 if len(args) == 0: | 115 if len(args) == 0: |
| 113 sys.stderr.write('No input files specified\n') | 116 sys.stderr.write('No input files specified\n') |
| 114 return -1 | 117 return -1 |
| 115 | 118 |
| 116 files = [ ] | 119 files = [ ] |
| 120 |
| 121 if options.client_root != None: |
| 122 for dirname, dirnames, filenames in os.walk(options.client_root): |
| 123 # strip out all dot files. |
| 124 filenames = [f for f in filenames if not f[0] == '.'] |
| 125 dirnames[:] = [d for d in dirnames if not d[0] == '.'] |
| 126 for f in filenames: |
| 127 src_path = os.path.join(dirname, f) |
| 128 if (os.path.isdir(src_path)): |
| 129 continue |
| 130 files.append(src_path) |
| 131 |
| 117 for arg in args: | 132 for arg in args: |
| 118 files.append(arg) | 133 files.append(arg) |
| 119 | 134 |
| 120 if not makeFile(options.output, options.root_prefix, files, | 135 if not makeFile(options.output, options.root_prefix, files, |
| 121 options.outer_namespace, options.inner_namespace, | 136 options.outer_namespace, options.inner_namespace, |
| 122 options.table_name): | 137 options.table_name): |
| 123 return -1 | 138 return -1 |
| 124 | 139 |
| 125 return 0 | 140 return 0 |
| 126 except Exception, inst: | 141 except Exception, inst: |
| 127 sys.stderr.write('create_resources.py exception\n') | 142 sys.stderr.write('create_resources.py exception\n') |
| 128 sys.stderr.write(str(inst)) | 143 sys.stderr.write(str(inst)) |
| 129 sys.stderr.write('\n') | 144 sys.stderr.write('\n') |
| 130 return -1 | 145 return -1 |
| 131 | 146 |
| 132 if __name__ == '__main__': | 147 if __name__ == '__main__': |
| 133 sys.exit(main(sys.argv)) | 148 sys.exit(main(sys.argv)) |
| OLD | NEW |