| 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 module.path = os.path.relpath(os.path.abspath(filename), | 136 module.path = os.path.relpath(os.path.abspath(filename), |
| 137 os.path.abspath(args.depth)) | 137 os.path.abspath(args.depth)) |
| 138 | 138 |
| 139 # Normalize to unix-style path here to keep the generators simpler. | 139 # Normalize to unix-style path here to keep the generators simpler. |
| 140 module.path = module.path.replace('\\', '/') | 140 module.path = module.path.replace('\\', '/') |
| 141 | 141 |
| 142 if self._should_generate(filename): | 142 if self._should_generate(filename): |
| 143 for language, generator_module in generator_modules.iteritems(): | 143 for language, generator_module in generator_modules.iteritems(): |
| 144 generator = generator_module.Generator( | 144 generator = generator_module.Generator( |
| 145 module, args.output_dir, typemap=self._typemap.get(language, {}), | 145 module, args.output_dir, typemap=self._typemap.get(language, {}), |
| 146 variant=args.variant, bytecode_path=args.bytecode_path) | 146 variant=args.variant, bytecode_path=args.bytecode_path, |
| 147 dll_export_declaration=args.dll_export_declaration, |
| 148 dll_export_include=args.dll_export_include) |
| 147 filtered_args = [] | 149 filtered_args = [] |
| 148 if hasattr(generator_module, 'GENERATOR_PREFIX'): | 150 if hasattr(generator_module, 'GENERATOR_PREFIX'): |
| 149 prefix = '--' + generator_module.GENERATOR_PREFIX + '_' | 151 prefix = '--' + generator_module.GENERATOR_PREFIX + '_' |
| 150 filtered_args = [arg for arg in remaining_args | 152 filtered_args = [arg for arg in remaining_args |
| 151 if arg.startswith(prefix)] | 153 if arg.startswith(prefix)] |
| 152 generator.GenerateFiles(filtered_args) | 154 generator.GenerateFiles(filtered_args) |
| 153 | 155 |
| 154 # Save result. | 156 # Save result. |
| 155 self._processed_files[filename] = module | 157 self._processed_files[filename] = module |
| 156 return module | 158 return module |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 generate_parser.add_argument("--typemap", action="append", metavar="TYPEMAP", | 247 generate_parser.add_argument("--typemap", action="append", metavar="TYPEMAP", |
| 246 default=[], dest="typemaps", | 248 default=[], dest="typemaps", |
| 247 help="apply TYPEMAP to generated output") | 249 help="apply TYPEMAP to generated output") |
| 248 generate_parser.add_argument("--variant", dest="variant", default=None, | 250 generate_parser.add_argument("--variant", dest="variant", default=None, |
| 249 help="output a named variant of the bindings") | 251 help="output a named variant of the bindings") |
| 250 generate_parser.add_argument( | 252 generate_parser.add_argument( |
| 251 "--bytecode_path", type=str, required=True, help=( | 253 "--bytecode_path", type=str, required=True, help=( |
| 252 "the path from which to load template bytecode; to generate template " | 254 "the path from which to load template bytecode; to generate template " |
| 253 "bytecode, run %s precompile BYTECODE_PATH" % os.path.basename( | 255 "bytecode, run %s precompile BYTECODE_PATH" % os.path.basename( |
| 254 sys.argv[0]))) | 256 sys.argv[0]))) |
| 257 generate_parser.add_argument( |
| 258 "--dll_export_declaration", type=str, |
| 259 help="TODO(yzshen)") |
| 260 generate_parser.add_argument( |
| 261 "--dll_export_include", type=str, |
| 262 help="TODO(yzshen)") |
| 255 generate_parser.set_defaults(func=_Generate) | 263 generate_parser.set_defaults(func=_Generate) |
| 256 | 264 |
| 257 precompile_parser = subparsers.add_parser("precompile", | 265 precompile_parser = subparsers.add_parser("precompile", |
| 258 description="Precompile templates for the mojom bindings generator.") | 266 description="Precompile templates for the mojom bindings generator.") |
| 259 precompile_parser.add_argument( | 267 precompile_parser.add_argument( |
| 260 "-o", "--output_dir", dest="output_dir", default=".", | 268 "-o", "--output_dir", dest="output_dir", default=".", |
| 261 help="output directory for precompiled templates") | 269 help="output directory for precompiled templates") |
| 262 precompile_parser.set_defaults(func=_Precompile) | 270 precompile_parser.set_defaults(func=_Precompile) |
| 263 | 271 |
| 264 args, remaining_args = parser.parse_known_args() | 272 args, remaining_args = parser.parse_known_args() |
| 265 return args.func(args, remaining_args) | 273 return args.func(args, remaining_args) |
| 266 | 274 |
| 267 | 275 |
| 268 if __name__ == "__main__": | 276 if __name__ == "__main__": |
| 269 sys.exit(main()) | 277 sys.exit(main()) |
| OLD | NEW |