OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2015 The Chromium Authors. All rights reserved. | 2 # Copyright 2015 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 # This script accepts the output of version 2 of the mojom parser and uses that | 6 # This script accepts the output of version 2 of the mojom parser and uses that |
7 # data to invoke the code generators. | 7 # data to invoke the code generators. |
8 # | 8 # |
9 # This script is not related mojom_bindings_generator.py (which is part of v1 | 9 # This script is not related mojom_bindings_generator.py (which is part of v1 |
10 # of the mojom parser pipeline). | 10 # of the mojom parser pipeline). |
(...skipping 21 matching lines...) Expand all Loading... |
32 default=None, | 32 default=None, |
33 help='Location of the compiled python bindings') | 33 help='Location of the compiled python bindings') |
34 parser.add_argument("-o", "--output-dir", dest="output_dir", default=".", | 34 parser.add_argument("-o", "--output-dir", dest="output_dir", default=".", |
35 help="output directory for generated files") | 35 help="output directory for generated files") |
36 parser.add_argument("-g", "--generators", dest="generators_string", | 36 parser.add_argument("-g", "--generators", dest="generators_string", |
37 metavar="GENERATORS", | 37 metavar="GENERATORS", |
38 default="c++,dart,go,javascript,java,python", | 38 default="c++,dart,go,javascript,java,python", |
39 help="comma-separated list of generators") | 39 help="comma-separated list of generators") |
40 parser.add_argument("-d", "--depth", dest="depth", default=".", | 40 parser.add_argument("-d", "--depth", dest="depth", default=".", |
41 help="relative path to the root of the source tree.") | 41 help="relative path to the root of the source tree.") |
| 42 parser.add_argument("--generate-type-info", dest="generate_type_info", |
| 43 action="store_true", |
| 44 help="generate mojom type descriptors") |
| 45 parser.add_argument("--no-generate-type-info", dest="generate_type_info", |
| 46 action="store_false", |
| 47 help="do not generate mojom type descriptors") |
| 48 parser.set_defaults(generate_type_info=True) |
42 | 49 |
43 return parser.parse_known_args() | 50 return parser.parse_known_args() |
44 | 51 |
45 | 52 |
46 def _FixPath(): | 53 def _FixPath(): |
47 # We need to parse command line args before imports so we can find out where | 54 # We need to parse command line args before imports so we can find out where |
48 # the python bindings are located and add them to sys.path. | 55 # the python bindings are located and add them to sys.path. |
49 args, _ = _ParseCLIArgs() | 56 args, _ = _ParseCLIArgs() |
50 py_bindings_dir = args.py_bindings_dir | 57 py_bindings_dir = args.py_bindings_dir |
51 if not py_bindings_dir: | 58 if not py_bindings_dir: |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 FixModulePath(module, os.path.abspath(args.depth)) | 162 FixModulePath(module, os.path.abspath(args.depth)) |
156 for generator_module in generator_modules: | 163 for generator_module in generator_modules: |
157 generator = generator_module.Generator(module, args.output_dir) | 164 generator = generator_module.Generator(module, args.output_dir) |
158 | 165 |
159 # Look at unparsed args for generator-specific args. | 166 # Look at unparsed args for generator-specific args. |
160 filtered_args = [] | 167 filtered_args = [] |
161 if hasattr(generator_module, 'GENERATOR_PREFIX'): | 168 if hasattr(generator_module, 'GENERATOR_PREFIX'): |
162 prefix = '--' + generator_module.GENERATOR_PREFIX + '_' | 169 prefix = '--' + generator_module.GENERATOR_PREFIX + '_' |
163 filtered_args = [arg for arg in remaining_args | 170 filtered_args = [arg for arg in remaining_args |
164 if arg.startswith(prefix)] | 171 if arg.startswith(prefix)] |
| 172 if args.generate_type_info: |
| 173 filtered_args.append("--generate_type_info") |
165 | 174 |
166 generator.GenerateFiles(filtered_args) | 175 generator.GenerateFiles(filtered_args) |
167 | 176 |
168 | 177 |
169 if __name__ == "__main__": | 178 if __name__ == "__main__": |
170 sys.exit(main()) | 179 sys.exit(main()) |
OLD | NEW |