OLD | NEW |
---|---|
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (C) 2013 Google Inc. All rights reserved. | 2 # Copyright (C) 2013 Google Inc. All rights reserved. |
3 # | 3 # |
4 # Redistribution and use in source and binary forms, with or without | 4 # Redistribution and use in source and binary forms, with or without |
5 # modification, are permitted provided that the following conditions are | 5 # modification, are permitted provided that the following conditions are |
6 # met: | 6 # met: |
7 # | 7 # |
8 # * Redistributions of source code must retain the above copyright | 8 # * Redistributions of source code must retain the above copyright |
9 # notice, this list of conditions and the following disclaimer. | 9 # notice, this list of conditions and the following disclaimer. |
10 # * Redistributions in binary form must reproduce the above | 10 # * Redistributions in binary form must reproduce the above |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
48 from utilities import read_idl_files_list_from_file | 48 from utilities import read_idl_files_list_from_file |
49 from utilities import write_file | 49 from utilities import write_file |
50 | 50 |
51 | 51 |
52 def parse_options(): | 52 def parse_options(): |
53 parser = OptionParser() | 53 parser = OptionParser() |
54 parser.add_option('--cache-directory', | 54 parser.add_option('--cache-directory', |
55 help='cache directory, defaults to output directory') | 55 help='cache directory, defaults to output directory') |
56 parser.add_option('--generate-impl', | 56 parser.add_option('--generate-impl', |
57 action="store_true", default=False) | 57 action="store_true", default=False) |
58 parser.add_option('--read-idl-list-from-file', | |
peria
2017/03/03 07:45:07
(optional) '....-list' is consistent with other ge
bashi
2017/03/03 07:59:13
Yeah, but I thought it's a bit redundant.
| |
59 action="store_true", default=False) | |
58 parser.add_option('--output-directory') | 60 parser.add_option('--output-directory') |
59 parser.add_option('--impl-output-directory') | 61 parser.add_option('--impl-output-directory') |
60 parser.add_option('--info-dir') | 62 parser.add_option('--info-dir') |
61 # FIXME: We should always explicitly specify --target-component and | 63 # FIXME: We should always explicitly specify --target-component and |
62 # remove the default behavior. | 64 # remove the default behavior. |
63 parser.add_option('--target-component', | 65 parser.add_option('--target-component', |
64 type='choice', | 66 type='choice', |
65 choices=['core', 'modules'], | 67 choices=['core', 'modules'], |
66 help='target component to generate code, defaults to ' | 68 help='target component to generate code, defaults to ' |
67 'component of input idl file') | 69 'component of input idl file') |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
174 options.target_component) | 176 options.target_component) |
175 output_code_list = generator.generate_code() | 177 output_code_list = generator.generate_code() |
176 for output_path, output_code in output_code_list: | 178 for output_path, output_code in output_code_list: |
177 write_file(output_code, output_path) | 179 write_file(output_code, output_path) |
178 | 180 |
179 | 181 |
180 def main(): | 182 def main(): |
181 options, input_filename = parse_options() | 183 options, input_filename = parse_options() |
182 info_provider = create_component_info_provider( | 184 info_provider = create_component_info_provider( |
183 options.info_dir, options.target_component) | 185 options.info_dir, options.target_component) |
184 if options.generate_impl: | 186 if options.generate_impl or options.read_idl_list_from_file: |
185 if not info_provider.interfaces_info: | |
186 raise Exception('Interfaces info is required to generate ' | |
187 'union types containers') | |
188 # |input_filename| should be a file which contains a list of IDL | 187 # |input_filename| should be a file which contains a list of IDL |
189 # dictionary paths. | 188 # dictionary paths. |
190 input_filenames = read_idl_files_list_from_file(input_filename, | 189 input_filenames = read_idl_files_list_from_file(input_filename, |
191 is_gyp_format=True) | 190 is_gyp_format=True) |
191 else: | |
192 input_filenames = [input_filename] | |
193 | |
194 if options.generate_impl: | |
195 if not info_provider.interfaces_info: | |
196 raise Exception('Interfaces info is required to generate ' | |
197 'impl classes') | |
192 generate_dictionary_impl(CodeGeneratorDictionaryImpl, info_provider, | 198 generate_dictionary_impl(CodeGeneratorDictionaryImpl, info_provider, |
193 options, input_filenames) | 199 options, input_filenames) |
194 generate_union_type_containers(CodeGeneratorUnionType, info_provider, | 200 generate_union_type_containers(CodeGeneratorUnionType, info_provider, |
195 options) | 201 options) |
196 generate_callback_function_impl(CodeGeneratorCallbackFunction, | 202 generate_callback_function_impl(CodeGeneratorCallbackFunction, |
197 info_provider, options) | 203 info_provider, options) |
198 else: | 204 else: |
199 # |input_filename| should be a path of an IDL file. | |
200 generate_bindings(CodeGeneratorV8, info_provider, options, | 205 generate_bindings(CodeGeneratorV8, info_provider, options, |
201 [input_filename]) | 206 input_filenames) |
202 | 207 |
203 | 208 |
204 if __name__ == '__main__': | 209 if __name__ == '__main__': |
205 sys.exit(main()) | 210 sys.exit(main()) |
OLD | NEW |