| 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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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, | 167 export_attribute=args.export_attribute, |
| 168 export_header=args.export_header) | 168 export_header=args.export_header, |
| 169 generate_non_variant_code=args.generate_non_variant_code) |
| 169 filtered_args = [] | 170 filtered_args = [] |
| 170 if hasattr(generator_module, 'GENERATOR_PREFIX'): | 171 if hasattr(generator_module, 'GENERATOR_PREFIX'): |
| 171 prefix = '--' + generator_module.GENERATOR_PREFIX + '_' | 172 prefix = '--' + generator_module.GENERATOR_PREFIX + '_' |
| 172 filtered_args = [arg for arg in remaining_args | 173 filtered_args = [arg for arg in remaining_args |
| 173 if arg.startswith(prefix)] | 174 if arg.startswith(prefix)] |
| 174 generator.GenerateFiles(filtered_args) | 175 generator.GenerateFiles(filtered_args) |
| 175 | 176 |
| 176 # Save result. | 177 # Save result. |
| 177 self._processed_files[rel_filename.path] = module | 178 self._processed_files[rel_filename.path] = module |
| 178 return module | 179 return module |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 help="Map mojom array/map/string to STL (for chromium variant) or WTF " | 293 help="Map mojom array/map/string to STL (for chromium variant) or WTF " |
| 293 "(for blink variant) types directly.") | 294 "(for blink variant) types directly.") |
| 294 generate_parser.add_argument( | 295 generate_parser.add_argument( |
| 295 "--export_attribute", type=str, default="", | 296 "--export_attribute", type=str, default="", |
| 296 help="Optional attribute to specify on class declaration to export it " | 297 help="Optional attribute to specify on class declaration to export it " |
| 297 "for the component build.") | 298 "for the component build.") |
| 298 generate_parser.add_argument( | 299 generate_parser.add_argument( |
| 299 "--export_header", type=str, default="", | 300 "--export_header", type=str, default="", |
| 300 help="Optional header to include in the generated headers to support the " | 301 help="Optional header to include in the generated headers to support the " |
| 301 "component build.") | 302 "component build.") |
| 303 generate_parser.add_argument( |
| 304 "--generate_non_variant_code", action="store_true", |
| 305 help="Generate code that is shared by different variants.") |
| 302 generate_parser.set_defaults(func=_Generate) | 306 generate_parser.set_defaults(func=_Generate) |
| 303 | 307 |
| 304 precompile_parser = subparsers.add_parser("precompile", | 308 precompile_parser = subparsers.add_parser("precompile", |
| 305 description="Precompile templates for the mojom bindings generator.") | 309 description="Precompile templates for the mojom bindings generator.") |
| 306 precompile_parser.add_argument( | 310 precompile_parser.add_argument( |
| 307 "-o", "--output_dir", dest="output_dir", default=".", | 311 "-o", "--output_dir", dest="output_dir", default=".", |
| 308 help="output directory for precompiled templates") | 312 help="output directory for precompiled templates") |
| 309 precompile_parser.set_defaults(func=_Precompile) | 313 precompile_parser.set_defaults(func=_Precompile) |
| 310 | 314 |
| 311 args, remaining_args = parser.parse_known_args() | 315 args, remaining_args = parser.parse_known_args() |
| 312 return args.func(args, remaining_args) | 316 return args.func(args, remaining_args) |
| 313 | 317 |
| 314 | 318 |
| 315 if __name__ == "__main__": | 319 if __name__ == "__main__": |
| 316 sys.exit(main()) | 320 sys.exit(main()) |
| OLD | NEW |