Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: third_party/WebKit/Source/bindings/scripts/idl_compiler.py

Issue 2458203002: Bindings tests should run the same code as prod code. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Tools/Scripts/webkitpy/bindings/bindings_tests.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 target_definitions = definitions[self.target_component] 115 target_definitions = definitions[self.target_component]
116 output_code_list = self.code_generator.generate_code( 116 output_code_list = self.code_generator.generate_code(
117 target_definitions, interface_name) 117 target_definitions, interface_name)
118 for output_path, output_code in output_code_list: 118 for output_path, output_code in output_code_list:
119 write_file(output_code, output_path) 119 write_file(output_code, output_path)
120 120
121 def compile_file(self, idl_filename): 121 def compile_file(self, idl_filename):
122 self.compile_and_write(idl_filename) 122 self.compile_and_write(idl_filename)
123 123
124 124
125 def generate_bindings(code_generator_class, options, input_filename): 125 def generate_bindings(code_generator_class, info_provider, options,
126 info_provider = create_component_info_provider( 126 input_filenames):
127 options.info_dir, options.target_component)
128 idl_compiler = IdlCompiler( 127 idl_compiler = IdlCompiler(
129 output_directory=options.output_directory, 128 output_directory=options.output_directory,
130 cache_directory=options.cache_directory, 129 cache_directory=options.cache_directory,
131 code_generator_class=code_generator_class, 130 code_generator_class=code_generator_class,
132 info_provider=info_provider, 131 info_provider=info_provider,
133 target_component=options.target_component) 132 target_component=options.target_component)
134 idl_compiler.compile_file(input_filename) 133
134 for idl_filename in input_filenames:
135 idl_compiler.compile_file(idl_filename)
135 136
136 137
137 def generate_dictionary_impl(code_generator_class, options, input_filename): 138 def generate_dictionary_impl(code_generator_class, info_provider, options,
138 info_provider = create_component_info_provider( 139 input_filenames):
139 options.info_dir, options.target_component)
140 idl_compiler = IdlCompiler( 140 idl_compiler = IdlCompiler(
141 output_directory=options.impl_output_directory, 141 output_directory=options.impl_output_directory,
142 cache_directory=options.cache_directory, 142 cache_directory=options.cache_directory,
143 code_generator_class=code_generator_class, 143 code_generator_class=code_generator_class,
144 info_provider=info_provider, 144 info_provider=info_provider,
145 target_component=options.target_component) 145 target_component=options.target_component)
146 146
147 idl_filenames = read_idl_files_list_from_file(input_filename, 147 for idl_filename in input_filenames:
148 is_gyp_format=True)
149 for idl_filename in idl_filenames:
150 idl_compiler.compile_file(idl_filename) 148 idl_compiler.compile_file(idl_filename)
151 149
152 150
153 def generate_union_type_containers(code_generator_class, options): 151 def generate_union_type_containers(code_generator_class, info_provider,
154 info_provider = create_component_info_provider( 152 options):
155 options.info_dir, options.target_component)
156 if not info_provider.interfaces_info:
157 raise Exception('Interfaces info is required to generate '
158 'union types containers')
159 generator = code_generator_class( 153 generator = code_generator_class(
160 info_provider, 154 info_provider,
161 options.cache_directory, 155 options.cache_directory,
162 options.output_directory, 156 options.output_directory,
163 options.target_component) 157 options.target_component)
164 output_code_list = generator.generate_code() 158 output_code_list = generator.generate_code()
165 for output_path, output_code in output_code_list: 159 for output_path, output_code in output_code_list:
166 write_file(output_code, output_path) 160 write_file(output_code, output_path)
167 161
168 162
169 def generate_callback_function_impl(code_generator_class, options): 163 def generate_callback_function_impl(code_generator_class, info_provider,
170 info_provider = create_component_info_provider( 164 options):
171 options.info_dir, options.target_component)
172 generator = code_generator_class( 165 generator = code_generator_class(
173 info_provider, 166 info_provider,
174 options.cache_directory, 167 options.cache_directory,
175 options.output_directory, 168 options.output_directory,
176 options.target_component) 169 options.target_component)
177 output_code_list = generator.generate_code() 170 output_code_list = generator.generate_code()
178 for output_path, output_code in output_code_list: 171 for output_path, output_code in output_code_list:
179 write_file(output_code, output_path) 172 write_file(output_code, output_path)
180 173
181 174
182 def main(): 175 def main():
183 options, input_filename = parse_options() 176 options, input_filename = parse_options()
177 info_provider = create_component_info_provider(
178 options.info_dir, options.target_component)
184 if options.generate_impl: 179 if options.generate_impl:
180 if not info_provider.interfaces_info:
181 raise Exception('Interfaces info is required to generate '
182 'union types containers')
185 # |input_filename| should be a file which contains a list of IDL 183 # |input_filename| should be a file which contains a list of IDL
186 # dictionary paths. 184 # dictionary paths.
187 generate_dictionary_impl(CodeGeneratorDictionaryImpl, options, 185 input_filenames = read_idl_files_list_from_file(input_filename,
188 input_filename) 186 is_gyp_format=True)
189 generate_union_type_containers(CodeGeneratorUnionType, options) 187 generate_dictionary_impl(CodeGeneratorDictionaryImpl, info_provider,
190 generate_callback_function_impl(CodeGeneratorCallbackFunction, options) 188 options, input_filenames)
189 generate_union_type_containers(CodeGeneratorUnionType, info_provider,
190 options)
191 generate_callback_function_impl(CodeGeneratorCallbackFunction,
192 info_provider, options)
191 else: 193 else:
192 # |input_filename| should be a path of an IDL file. 194 # |input_filename| should be a path of an IDL file.
193 generate_bindings(CodeGeneratorV8, options, input_filename) 195 generate_bindings(CodeGeneratorV8, info_provider, options,
196 [input_filename])
194 197
195 198
196 if __name__ == '__main__': 199 if __name__ == '__main__':
197 sys.exit(main()) 200 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Tools/Scripts/webkitpy/bindings/bindings_tests.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698