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

Side by Side Diff: lib/html/scripts/dartdomgenerator.py

Issue 10987042: Speed up fremontcut/dartdomgenerator (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: PReserve old entrypoint Created 8 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | lib/html/scripts/databasebuilder.py » ('j') | lib/html/scripts/databasebuilder.py » ('J')
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 dartgenerator 8 import dartgenerator
9 import database 9 import database
10 import fremontcutbuilder
10 import logging.config 11 import logging.config
11 import multiemitter 12 import multiemitter
12 import optparse 13 import optparse
13 import os 14 import os
14 import shutil 15 import shutil
15 import subprocess 16 import subprocess
16 import sys 17 import sys
17 from generator import TypeRegistry 18 from generator import TypeRegistry
18 from htmlrenamer import HtmlRenamer 19 from htmlrenamer import HtmlRenamer
19 from systembase import GeneratorOptions 20 from systembase import GeneratorOptions
(...skipping 10 matching lines...) Expand all
30 # TODO(vsm): Maybe Store these renames in the IDLs. 31 # TODO(vsm): Maybe Store these renames in the IDLs.
31 'ApplicationCache': 'DOMApplicationCache', 32 'ApplicationCache': 'DOMApplicationCache',
32 'BarProp': 'BarInfo', 33 'BarProp': 'BarInfo',
33 'DedicatedWorkerGlobalScope': 'DedicatedWorkerContext', 34 'DedicatedWorkerGlobalScope': 'DedicatedWorkerContext',
34 'FormData': 'DOMFormData', 35 'FormData': 'DOMFormData',
35 'Selection': 'DOMSelection', 36 'Selection': 'DOMSelection',
36 'SharedWorkerGlobalScope': 'SharedWorkerContext', 37 'SharedWorkerGlobalScope': 'SharedWorkerContext',
37 'Window': 'DOMWindow', 38 'Window': 'DOMWindow',
38 'WorkerGlobalScope': 'WorkerContext'} 39 'WorkerGlobalScope': 'WorkerContext'}
39 40
41 # TODO(vsm): Remove once we fix Dartium to pass in the database directly.
40 def Generate(database_dir, use_database_cache, dart2js_output_dir=None, 42 def Generate(database_dir, use_database_cache, dart2js_output_dir=None,
41 dartium_output_dir=None): 43 dartium_output_dir=None):
44 database = LoadDatabase(database_dir, use_database_cache)
45 GenerateFromDatabase(database, dart2js_output_dir, dartium_output_dir)
46
47 def LoadDatabase(database_dir, use_database_cache):
48 common_database = database.Database(database_dir)
49 if use_database_cache:
50 common_database.LoadFromCache()
51 else:
52 common_database.Load()
53 return common_database
54
55 def GenerateFromDatabase(common_database, dart2js_output_dir,
56 dartium_output_dir):
42 current_dir = os.path.dirname(__file__) 57 current_dir = os.path.dirname(__file__)
43 auxiliary_dir = os.path.join(current_dir, '..', 'src') 58 auxiliary_dir = os.path.join(current_dir, '..', 'src')
44 template_dir = os.path.join(current_dir, '..', 'templates') 59 template_dir = os.path.join(current_dir, '..', 'templates')
45 60
46 generator = dartgenerator.DartGenerator() 61 generator = dartgenerator.DartGenerator()
47 generator.LoadAuxiliary(auxiliary_dir) 62 generator.LoadAuxiliary(auxiliary_dir)
48 63
49 common_database = database.Database(database_dir)
50 if use_database_cache:
51 common_database.LoadFromCache()
52 else:
53 common_database.Load()
54
55 generator.FilterMembersWithUnidentifiedTypes(common_database) 64 generator.FilterMembersWithUnidentifiedTypes(common_database)
56 webkit_database = common_database.Clone() 65 webkit_database = common_database.Clone()
57 66
58 # Generate Dart interfaces for the WebKit DOM. 67 # Generate Dart interfaces for the WebKit DOM.
59 generator.FilterInterfaces(database = webkit_database, 68 generator.FilterInterfaces(database = webkit_database,
60 or_annotations = ['WebKit', 'Dart'], 69 or_annotations = ['WebKit', 'Dart'],
61 exclude_displaced = ['WebKit'], 70 exclude_displaced = ['WebKit'],
62 exclude_suppressed = ['WebKit', 'Dart']) 71 exclude_suppressed = ['WebKit', 'Dart'])
63 generator.RenameTypes(webkit_database, _webkit_renames, True) 72 generator.RenameTypes(webkit_database, _webkit_renames, True)
64 generator.FixEventTargets(webkit_database) 73 generator.FixEventTargets(webkit_database)
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 library_dir = os.path.dirname(library_path) 112 library_dir = os.path.dirname(library_path)
104 library_filename = os.path.basename(library_path) 113 library_filename = os.path.basename(library_path)
105 copy_dart_script = os.path.relpath('../../../tools/copy_dart.py', library_dir) 114 copy_dart_script = os.path.relpath('../../../tools/copy_dart.py', library_dir)
106 output_dir = os.path.relpath(output_dir, library_dir) 115 output_dir = os.path.relpath(output_dir, library_dir)
107 command = ' '.join(['cd', library_dir, ';', 116 command = ' '.join(['cd', library_dir, ';',
108 copy_dart_script, output_dir, library_filename]) 117 copy_dart_script, output_dir, library_filename])
109 subprocess.call([command], shell=True) 118 subprocess.call([command], shell=True)
110 119
111 def main(): 120 def main():
112 parser = optparse.OptionParser() 121 parser = optparse.OptionParser()
122 parser.add_option('--rebuild', dest='rebuild',
123 action='store_true', default=False,
124 help='Rebuild the database from IDL using fremontcut.')
113 parser.add_option('--systems', dest='systems', 125 parser.add_option('--systems', dest='systems',
114 action='store', type='string', 126 action='store', type='string',
115 default='htmldart2js,htmldartium', 127 default='htmldart2js,htmldartium',
116 help='Systems to generate (htmldart2js, htmldartium)') 128 help='Systems to generate (htmldart2js, htmldartium)')
117 parser.add_option('--output-dir', dest='output_dir', 129 parser.add_option('--output-dir', dest='output_dir',
118 action='store', type='string', 130 action='store', type='string',
119 default=None, 131 default=None,
120 help='Directory to put the generated files') 132 help='Directory to put the generated files')
121 parser.add_option('--use-database-cache', dest='use_database_cache', 133 parser.add_option('--use-database-cache', dest='use_database_cache',
122 action='store_true', 134 action='store_true',
123 default=False, 135 default=False,
124 help='''Use the cached database from the previous run to 136 help='''Use the cached database from the previous run to
125 improve startup performance''') 137 improve startup performance''')
126 (options, args) = parser.parse_args() 138 (options, args) = parser.parse_args()
127 139
128 current_dir = os.path.dirname(__file__) 140 current_dir = os.path.dirname(__file__)
129 database_dir = os.path.join(current_dir, '..', 'database') 141 database_dir = os.path.join(current_dir, '..', 'database')
130 logging.config.fileConfig(os.path.join(current_dir, 'logging.conf')) 142 logging.config.fileConfig(os.path.join(current_dir, 'logging.conf'))
131 systems = options.systems.split(',') 143 systems = options.systems.split(',')
132 144
133 output_dir = options.output_dir or os.path.join(current_dir, '../generated') 145 output_dir = options.output_dir or os.path.join(current_dir, '../generated')
134 dart2js_output_dir = None 146 dart2js_output_dir = None
135 if 'htmldart2js' in systems: 147 if 'htmldart2js' in systems:
136 dart2js_output_dir = os.path.join(output_dir, 'dart2js') 148 dart2js_output_dir = os.path.join(output_dir, 'dart2js')
137 dartium_output_dir = None 149 dartium_output_dir = None
138 if 'htmldartium' in systems: 150 if 'htmldartium' in systems:
139 dartium_output_dir = os.path.join(output_dir, 'dartium') 151 dartium_output_dir = os.path.join(output_dir, 'dartium')
140 152
141 Generate(database_dir, options.use_database_cache, dart2js_output_dir, 153 if options.rebuild:
142 dartium_output_dir) 154 # Parse the IDL and create the database.
155 database = fremontcutbuilder.main()
156 else:
157 # Load the previously generated database.
158 database = LoadDatabase(database_dir, options.use_database_cache)
159 GenerateFromDatabase(database, dart2js_output_dir,
160 dartium_output_dir)
143 161
144 if 'htmldart2js' in systems: 162 if 'htmldart2js' in systems:
145 _logger.info('Copy html_dart2js to dart2js/') 163 _logger.info('Copy html_dart2js to dart2js/')
146 GenerateSingleFile(os.path.join(dart2js_output_dir, 'html_dart2js.dart'), 164 GenerateSingleFile(os.path.join(dart2js_output_dir, 'html_dart2js.dart'),
147 '../dart2js') 165 '../dart2js')
148 if 'htmldartium' in systems: 166 if 'htmldartium' in systems:
149 _logger.info('Copy html_dartium to dartium/') 167 _logger.info('Copy html_dartium to dartium/')
150 GenerateSingleFile(os.path.join(dartium_output_dir, 'html_dartium.dart'), 168 GenerateSingleFile(os.path.join(dartium_output_dir, 'html_dartium.dart'),
151 '../dartium') 169 '../dartium')
152 170
153 if __name__ == '__main__': 171 if __name__ == '__main__':
154 sys.exit(main()) 172 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | lib/html/scripts/databasebuilder.py » ('j') | lib/html/scripts/databasebuilder.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698