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