| 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 | 156 |
| 157 # Normalize to unix-style path here to keep the generators simpler. | 157 # Normalize to unix-style path here to keep the generators simpler. |
| 158 module.path = module.path.replace('\\', '/') | 158 module.path = module.path.replace('\\', '/') |
| 159 | 159 |
| 160 if self._should_generate(rel_filename.path): | 160 if self._should_generate(rel_filename.path): |
| 161 for language, generator_module in generator_modules.iteritems(): | 161 for language, generator_module in generator_modules.iteritems(): |
| 162 generator = generator_module.Generator( | 162 generator = generator_module.Generator( |
| 163 module, args.output_dir, typemap=self._typemap.get(language, {}), | 163 module, args.output_dir, typemap=self._typemap.get(language, {}), |
| 164 variant=args.variant, bytecode_path=args.bytecode_path, | 164 variant=args.variant, bytecode_path=args.bytecode_path, |
| 165 for_blink=args.for_blink, | 165 for_blink=args.for_blink, |
| 166 use_new_wrapper_types=args.use_new_wrapper_types) | 166 use_new_wrapper_types=args.use_new_wrapper_types, |
| 167 export_attribute=args.export_attribute, |
| 168 export_header=args.export_header) |
| 167 filtered_args = [] | 169 filtered_args = [] |
| 168 if hasattr(generator_module, 'GENERATOR_PREFIX'): | 170 if hasattr(generator_module, 'GENERATOR_PREFIX'): |
| 169 prefix = '--' + generator_module.GENERATOR_PREFIX + '_' | 171 prefix = '--' + generator_module.GENERATOR_PREFIX + '_' |
| 170 filtered_args = [arg for arg in remaining_args | 172 filtered_args = [arg for arg in remaining_args |
| 171 if arg.startswith(prefix)] | 173 if arg.startswith(prefix)] |
| 172 generator.GenerateFiles(filtered_args) | 174 generator.GenerateFiles(filtered_args) |
| 173 | 175 |
| 174 # Save result. | 176 # Save result. |
| 175 self._processed_files[rel_filename.path] = module | 177 self._processed_files[rel_filename.path] = module |
| 176 return module | 178 return module |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 "the path from which to load template bytecode; to generate template " | 284 "the path from which to load template bytecode; to generate template " |
| 283 "bytecode, run %s precompile BYTECODE_PATH" % os.path.basename( | 285 "bytecode, run %s precompile BYTECODE_PATH" % os.path.basename( |
| 284 sys.argv[0]))) | 286 sys.argv[0]))) |
| 285 generate_parser.add_argument("--for_blink", action="store_true", | 287 generate_parser.add_argument("--for_blink", action="store_true", |
| 286 help="Use WTF types as generated types for mojo " | 288 help="Use WTF types as generated types for mojo " |
| 287 "string/array/map.") | 289 "string/array/map.") |
| 288 generate_parser.add_argument( | 290 generate_parser.add_argument( |
| 289 "--use_new_wrapper_types", action="store_true", | 291 "--use_new_wrapper_types", action="store_true", |
| 290 help="Map mojom array/map/string to STL (for chromium variant) or WTF " | 292 help="Map mojom array/map/string to STL (for chromium variant) or WTF " |
| 291 "(for blink variant) types directly.") | 293 "(for blink variant) types directly.") |
| 294 generate_parser.add_argument( |
| 295 "--export_attribute", type=str, default="", |
| 296 help="Optional attribute to specify on class declaration to export it " |
| 297 "for the component build.") |
| 298 generate_parser.add_argument( |
| 299 "--export_header", type=str, default="", |
| 300 help="Optional header to include in the generated headers to support the " |
| 301 "component build.") |
| 292 generate_parser.set_defaults(func=_Generate) | 302 generate_parser.set_defaults(func=_Generate) |
| 293 | 303 |
| 294 precompile_parser = subparsers.add_parser("precompile", | 304 precompile_parser = subparsers.add_parser("precompile", |
| 295 description="Precompile templates for the mojom bindings generator.") | 305 description="Precompile templates for the mojom bindings generator.") |
| 296 precompile_parser.add_argument( | 306 precompile_parser.add_argument( |
| 297 "-o", "--output_dir", dest="output_dir", default=".", | 307 "-o", "--output_dir", dest="output_dir", default=".", |
| 298 help="output directory for precompiled templates") | 308 help="output directory for precompiled templates") |
| 299 precompile_parser.set_defaults(func=_Precompile) | 309 precompile_parser.set_defaults(func=_Precompile) |
| 300 | 310 |
| 301 args, remaining_args = parser.parse_known_args() | 311 args, remaining_args = parser.parse_known_args() |
| 302 return args.func(args, remaining_args) | 312 return args.func(args, remaining_args) |
| 303 | 313 |
| 304 | 314 |
| 305 if __name__ == "__main__": | 315 if __name__ == "__main__": |
| 306 sys.exit(main()) | 316 sys.exit(main()) |
| OLD | NEW |