OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2013 The Chromium Authors. All rights reserved. | 2 # Copyright 2013 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 """The frontend for the Mojo bindings system.""" | 6 """The frontend for the Mojo bindings system.""" |
7 | 7 |
8 | 8 |
9 import argparse | 9 import argparse |
10 import imp | 10 import imp |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 module.path = os.path.relpath(os.path.abspath(filename), | 131 module.path = os.path.relpath(os.path.abspath(filename), |
132 os.path.abspath(args.depth)) | 132 os.path.abspath(args.depth)) |
133 | 133 |
134 # Normalize to unix-style path here to keep the generators simpler. | 134 # Normalize to unix-style path here to keep the generators simpler. |
135 module.path = module.path.replace('\\', '/') | 135 module.path = module.path.replace('\\', '/') |
136 | 136 |
137 if self._should_generate(filename): | 137 if self._should_generate(filename): |
138 for generator_module in generator_modules: | 138 for generator_module in generator_modules: |
139 generator = generator_module.Generator(module, args.output_dir) | 139 generator = generator_module.Generator(module, args.output_dir) |
140 filtered_args = [] | 140 filtered_args = [] |
| 141 |
141 if hasattr(generator_module, 'GENERATOR_PREFIX'): | 142 if hasattr(generator_module, 'GENERATOR_PREFIX'): |
142 prefix = '--' + generator_module.GENERATOR_PREFIX + '_' | 143 prefix = '--' + generator_module.GENERATOR_PREFIX + '_' |
143 filtered_args = [arg for arg in remaining_args | 144 filtered_args = [arg for arg in remaining_args |
144 if arg.startswith(prefix)] | 145 if arg.startswith(prefix)] |
145 generator.GenerateFiles(filtered_args) | 146 generator.GenerateFiles(filtered_args) |
146 | 147 |
147 # Save result. | 148 # Save result. |
148 self._processed_files[filename] = module | 149 self._processed_files[filename] = module |
149 return module | 150 return module |
150 | 151 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 help="comma-separated list of generators") | 200 help="comma-separated list of generators") |
200 parser.add_argument("--debug_print_intermediate", action="store_true", | 201 parser.add_argument("--debug_print_intermediate", action="store_true", |
201 help="print the intermediate representation") | 202 help="print the intermediate representation") |
202 parser.add_argument("-I", dest="import_directories", action="append", | 203 parser.add_argument("-I", dest="import_directories", action="append", |
203 metavar="directory", default=[], | 204 metavar="directory", default=[], |
204 help="add a directory to be searched for import files") | 205 help="add a directory to be searched for import files") |
205 parser.add_argument("--use_bundled_pylibs", action="store_true", | 206 parser.add_argument("--use_bundled_pylibs", action="store_true", |
206 help="use Python modules bundled in the SDK") | 207 help="use Python modules bundled in the SDK") |
207 (args, remaining_args) = parser.parse_known_args(argv) | 208 (args, remaining_args) = parser.parse_known_args(argv) |
208 | 209 |
| 210 # These flags are added to ensure that tests requiring type information pass. |
| 211 # TODO(afandria): The caller of this script should be the one passing these |
| 212 # flags in. https://github.com/domokit/mojo/issues/558 |
| 213 remaining_args.append("--dart_gen_types") |
| 214 remaining_args.append("--go_gen_types") |
| 215 |
209 generator_modules = LoadGenerators(args.generators_string) | 216 generator_modules = LoadGenerators(args.generators_string) |
210 | 217 |
211 fileutil.EnsureDirectoryExists(args.output_dir) | 218 fileutil.EnsureDirectoryExists(args.output_dir) |
212 | 219 |
213 processor = MojomProcessor(lambda filename: filename in args.filename) | 220 processor = MojomProcessor(lambda filename: filename in args.filename) |
214 for filename in args.filename: | 221 for filename in args.filename: |
215 processor.ProcessFile(args, remaining_args, generator_modules, filename) | 222 processor.ProcessFile(args, remaining_args, generator_modules, filename) |
216 | 223 |
217 return 0 | 224 return 0 |
218 | 225 |
219 | 226 |
220 if __name__ == "__main__": | 227 if __name__ == "__main__": |
221 sys.exit(main(sys.argv[1:])) | 228 sys.exit(main(sys.argv[1:])) |
OLD | NEW |