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

Side by Side Diff: tools/dom/scripts/dartdomgenerator.py

Issue 1682783002: Dartium 45 roll (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: removed Created 4 years, 10 months 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 | « tools/dom/new_scripts/dependency.py ('k') | tools/dom/scripts/dartgenerator.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) 2011, the Dart project authors. Please see the AUTHORS file 2 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
3 # for details. All rights reserved. Use of this source code is governed by a 3 # for details. All rights reserved. Use of this source code is governed by a
4 # BSD-style license that can be found in the LICENSE file. 4 # BSD-style license that can be found in the LICENSE file.
5 5
6 """This is the entry point to create Dart APIs from the IDL database.""" 6 """This is the entry point to create Dart APIs from the IDL database."""
7 7
8 import css_code_generator 8 import css_code_generator
9 import os 9 import os
10 import sys 10 import sys
(...skipping 27 matching lines...) Expand all
38 import fremontcutbuilder 38 import fremontcutbuilder
39 import logging 39 import logging
40 import monitored 40 import monitored
41 import multiemitter 41 import multiemitter
42 import optparse 42 import optparse
43 import shutil 43 import shutil
44 import subprocess 44 import subprocess
45 import time 45 import time
46 from dartmetadata import DartMetadata 46 from dartmetadata import DartMetadata
47 from generator import TypeRegistry 47 from generator import TypeRegistry
48 from generate_blink_file import Generate_Blink
48 from htmleventgenerator import HtmlEventGenerator 49 from htmleventgenerator import HtmlEventGenerator
49 from htmlrenamer import HtmlRenamer 50 from htmlrenamer import HtmlRenamer
50 from systemhtml import DartLibraryEmitter, Dart2JSBackend,\ 51 from systemhtml import DartLibraryEmitter, Dart2JSBackend,\
51 HtmlDartInterfaceGenerator, DartLibrary, DartLibraries,\ 52 HtmlDartInterfaceGenerator, DartLibrary, DartLibraries,\
52 HTML_LIBRARY_NAMES 53 HTML_LIBRARY_NAMES
53 from systemnative import CPPLibraryEmitter, DartiumBackend 54 from systemnative import CPPLibraryEmitter, DartiumBackend
54 from templateloader import TemplateLoader 55 from templateloader import TemplateLoader
55 56
56 sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..')) 57 sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..'))
57 58
(...skipping 13 matching lines...) Expand all
71 self.dart_js_interop = dart_js_interop 72 self.dart_js_interop = dart_js_interop
72 73
73 def LoadDatabase(database_dir, use_database_cache): 74 def LoadDatabase(database_dir, use_database_cache):
74 common_database = database.Database(database_dir) 75 common_database = database.Database(database_dir)
75 if use_database_cache: 76 if use_database_cache:
76 common_database.LoadFromCache() 77 common_database.LoadFromCache()
77 else: 78 else:
78 common_database.Load() 79 common_database.Load()
79 return common_database 80 return common_database
80 81
81 def GenerateFromDatabase(common_database, dart2js_output_dir, 82 def GenerateFromDatabase(common_database,
82 dartium_output_dir, update_dom_metadata=False, 83 dart2js_output_dir, dartium_output_dir, blink_output_di r,
84 update_dom_metadata=False,
83 logging_level=logging.WARNING, dart_js_interop=False): 85 logging_level=logging.WARNING, dart_js_interop=False):
84 print '\n ----- Accessing DOM using %s -----\n' % ('dart:js' if dart_js_intero p else 'C++') 86 print '\n ----- Accessing DOM using %s -----\n' % ('dart:js' if dart_js_intero p else 'C++')
85 87
86 start_time = time.time() 88 start_time = time.time()
87 89
88 current_dir = os.path.dirname(__file__) 90 current_dir = os.path.dirname(__file__)
89 auxiliary_dir = os.path.join(current_dir, '..', 'src') 91 auxiliary_dir = os.path.join(current_dir, '..', 'src')
90 template_dir = os.path.join(current_dir, '..', 'templates') 92 template_dir = os.path.join(current_dir, '..', 'templates')
91 93
92 _logger.setLevel(logging_level) 94 _logger.setLevel(logging_level)
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 189
188 cpp_library_emitter.EmitDerivedSources( 190 cpp_library_emitter.EmitDerivedSources(
189 template_loader.Load('cpp_derived_sources.template'), 191 template_loader.Load('cpp_derived_sources.template'),
190 dartium_output_dir) 192 dartium_output_dir)
191 cpp_library_emitter.EmitResolver( 193 cpp_library_emitter.EmitResolver(
192 template_loader.Load('cpp_resolver.template'), dartium_output_dir) 194 template_loader.Load('cpp_resolver.template'), dartium_output_dir)
193 cpp_library_emitter.EmitClassIdTable( 195 cpp_library_emitter.EmitClassIdTable(
194 webkit_database, dartium_output_dir, type_registry, renamer) 196 webkit_database, dartium_output_dir, type_registry, renamer)
195 emitters.Flush() 197 emitters.Flush()
196 198
199 if blink_output_dir:
200 print '\nGenerating _blink:\n'
201 start_time = time.time()
202
203 Generate_Blink(blink_output_dir, webkit_database, type_registry)
204
205 print 'Generated _blink in %s seconds' % round(time.time() - start_time, 2)
206
197 if update_dom_metadata: 207 if update_dom_metadata:
198 metadata.Flush() 208 metadata.Flush()
199 209
200 monitored.FinishMonitoring(dart2js_output_dir, _logger) 210 monitored.FinishMonitoring(dart2js_output_dir, _logger)
201 211
202 def GenerateSingleFile(library_path, output_dir, generated_output_dir=None): 212 def GenerateSingleFile(library_path, output_dir, generated_output_dir=None):
203 library_dir = os.path.dirname(library_path) 213 library_dir = os.path.dirname(library_path)
204 library_filename = os.path.basename(library_path) 214 library_filename = os.path.basename(library_path)
205 copy_dart_script = os.path.relpath('../../copy_dart.py', 215 copy_dart_script = os.path.relpath('../../copy_dart.py',
206 library_dir) 216 library_dir)
207 output_dir = os.path.relpath(output_dir, library_dir) 217 output_dir = os.path.relpath(output_dir, library_dir)
208 command = ' '.join(['cd', library_dir, ';', 218 command = ' '.join(['cd', library_dir, ';',
209 copy_dart_script, output_dir, library_filename]) 219 copy_dart_script, output_dir, library_filename])
210 subprocess.call([command], shell=True) 220 subprocess.call([command], shell=True)
211 221
212 def UpdateCssProperties(): 222 def UpdateCssProperties():
213 """Regenerate the CssStyleDeclaration template file with the current CSS 223 """Regenerate the CssStyleDeclaration template file with the current CSS
214 properties.""" 224 properties."""
215 _logger.info('Updating Css Properties.') 225 _logger.info('Updating Css Properties.')
216 css_code_generator.GenerateCssTemplateFile() 226 css_code_generator.GenerateCssTemplateFile()
217 227
218 def main(): 228 def main():
219 parser = optparse.OptionParser() 229 parser = optparse.OptionParser()
220 parser.add_option('--parallel', dest='parallel', 230 parser.add_option('--parallel', dest='parallel',
221 action='store_true', default=False, 231 action='store_true', default=False,
222 help='Use fremontcut in parallel mode.') 232 help='Use fremontcut in parallel mode.')
223 parser.add_option('--systems', dest='systems', 233 parser.add_option('--systems', dest='systems',
224 action='store', type='string', 234 action='store', type='string',
225 default='htmldart2js,htmldartium', 235 default='htmldart2js,htmldartium,_blink',
226 help='Systems to generate (htmldart2js, htmldartium)') 236 help='Systems to generate (htmldart2js, htmldartium, _blink) ')
227 parser.add_option('--output-dir', dest='output_dir', 237 parser.add_option('--output-dir', dest='output_dir',
228 action='store', type='string', 238 action='store', type='string',
229 default=None, 239 default=None,
230 help='Directory to put the generated files') 240 help='Directory to put the generated files')
231 parser.add_option('--use-database-cache', dest='use_database_cache', 241 parser.add_option('--use-database-cache', dest='use_database_cache',
232 action='store_true', 242 action='store_true',
233 default=False, 243 default=False,
234 help='''Use the cached database from the previous run to 244 help='''Use the cached database from the previous run to
235 improve startup performance''') 245 improve startup performance''')
236 parser.add_option('--update-dom-metadata', dest='update_dom_metadata', 246 parser.add_option('--update-dom-metadata', dest='update_dom_metadata',
(...skipping 23 matching lines...) Expand all
260 output_dir = options.output_dir or os.path.join( 270 output_dir = options.output_dir or os.path.join(
261 current_dir, '..', '..', utils.GetBuildDir(utils.GuessOS()), 271 current_dir, '..', '..', utils.GetBuildDir(utils.GuessOS()),
262 'generated') 272 'generated')
263 273
264 dart2js_output_dir = None 274 dart2js_output_dir = None
265 if 'htmldart2js' in systems: 275 if 'htmldart2js' in systems:
266 dart2js_output_dir = os.path.join(output_dir, 'dart2js') 276 dart2js_output_dir = os.path.join(output_dir, 'dart2js')
267 dartium_output_dir = None 277 dartium_output_dir = None
268 if 'htmldartium' in systems: 278 if 'htmldartium' in systems:
269 dartium_output_dir = os.path.join(output_dir, 'dartium') 279 dartium_output_dir = os.path.join(output_dir, 'dartium')
280 blink_output_dir = None
281 if '_blink' in systems:
282 blink_output_dir = os.path.join(output_dir, 'dartium')
270 283
271 logging_level = options.logging_level \ 284 logging_level = options.logging_level \
272 if options.logging == logging.NOTSET else options.logging 285 if options.logging == logging.NOTSET else options.logging
273 286
274 start_time = time.time() 287 start_time = time.time()
275 288
276 UpdateCssProperties() 289 UpdateCssProperties()
277 290
278 # Parse the IDL and create the database. 291 # Parse the IDL and create the database.
279 database = fremontcutbuilder.main(options.parallel, logging_level=logging_leve l, examine_idls=options.examine_idls) 292 database = fremontcutbuilder.main(options.parallel, logging_level=logging_leve l, examine_idls=options.examine_idls)
280 293
281 GenerateFromDatabase(database, dart2js_output_dir, dartium_output_dir, 294 GenerateFromDatabase(database,
282 options.update_dom_metadata, logging_level, options.dart_js_interop) 295 dart2js_output_dir,
296 dartium_output_dir,
297 blink_output_dir,
298 options.update_dom_metadata,
299 logging_level,
300 options.dart_js_interop)
283 301
284 file_generation_start_time = time.time() 302 file_generation_start_time = time.time()
285 303
286 if 'htmldart2js' in systems: 304 if 'htmldart2js' in systems:
287 _logger.info('Generating dart2js single files.') 305 _logger.info('Generating dart2js single files.')
288 306
289 for library_name in HTML_LIBRARY_NAMES: 307 for library_name in HTML_LIBRARY_NAMES:
290 GenerateSingleFile( 308 GenerateSingleFile(
291 os.path.join(dart2js_output_dir, '%s_dart2js.dart' % library_name), 309 os.path.join(dart2js_output_dir, '%s_dart2js.dart' % library_name),
292 os.path.join('..', '..', '..', 'sdk', 'lib', library_name, 'dart2js')) 310 os.path.join('..', '..', '..', 'sdk', 'lib', library_name, 'dart2js'))
293 311
294 if 'htmldartium' in systems: 312 if 'htmldartium' in systems:
295 _logger.info('Generating dartium single files.') 313 _logger.info('Generating dartium single files.')
296 file_generation_start_time = time.time() 314 file_generation_start_time = time.time()
297 315
298 for library_name in HTML_LIBRARY_NAMES: 316 for library_name in HTML_LIBRARY_NAMES:
299 GenerateSingleFile( 317 GenerateSingleFile(
300 os.path.join(dartium_output_dir, '%s_dartium.dart' % library_name), 318 os.path.join(dartium_output_dir, '%s_dartium.dart' % library_name),
301 os.path.join('..', '..', '..', 'sdk', 'lib', library_name, 'dartium')) 319 os.path.join('..', '..', '..', 'sdk', 'lib', library_name, 'dartium'))
302 320
321 if '_blink' in systems:
322 _logger.info('Generating dartium _blink file.')
323 file_generation_start_time = time.time()
324
325 GenerateSingleFile(
326 os.path.join(dartium_output_dir, '%s_dartium.dart' % '_blink'),
327 os.path.join('..', '..', '..', 'sdk', 'lib', '_blink', 'dartium'))
328
303 print '\nGenerating single file %s seconds' % round(time.time() - file_generat ion_start_time, 2) 329 print '\nGenerating single file %s seconds' % round(time.time() - file_generat ion_start_time, 2)
304 330
305 end_time = time.time() 331 end_time = time.time()
306 332
307 print '\nDone (dartdomgenerator) %s seconds' % round(end_time - start_time, 2) 333 print '\nDone (dartdomgenerator) %s seconds' % round(end_time - start_time, 2)
308 334
309 if __name__ == '__main__': 335 if __name__ == '__main__':
310 sys.exit(main()) 336 sys.exit(main())
OLDNEW
« no previous file with comments | « tools/dom/new_scripts/dependency.py ('k') | tools/dom/scripts/dartgenerator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698