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

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: Address comments 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') | 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 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 11 matching lines...) Expand all
31 # TODO(vsm): Maybe Store these renames in the IDLs. 32 # TODO(vsm): Maybe Store these renames in the IDLs.
32 'ApplicationCache': 'DOMApplicationCache', 33 'ApplicationCache': 'DOMApplicationCache',
33 'BarProp': 'BarInfo', 34 'BarProp': 'BarInfo',
34 'DedicatedWorkerGlobalScope': 'DedicatedWorkerContext', 35 'DedicatedWorkerGlobalScope': 'DedicatedWorkerContext',
35 'FormData': 'DOMFormData', 36 'FormData': 'DOMFormData',
36 'Selection': 'DOMSelection', 37 'Selection': 'DOMSelection',
37 'SharedWorkerGlobalScope': 'SharedWorkerContext', 38 'SharedWorkerGlobalScope': 'SharedWorkerContext',
38 'Window': 'DOMWindow', 39 'Window': 'DOMWindow',
39 'WorkerGlobalScope': 'WorkerContext'} 40 'WorkerGlobalScope': 'WorkerContext'}
40 41
42 # TODO(vsm): Remove once we fix Dartium to pass in the database directly.
41 def Generate(database_dir, use_database_cache, dart2js_output_dir=None, 43 def Generate(database_dir, use_database_cache, dart2js_output_dir=None,
42 dartium_output_dir=None): 44 dartium_output_dir=None):
45 database = LoadDatabase(database_dir, use_database_cache)
46 GenerateFromDatabase(database, dart2js_output_dir, dartium_output_dir)
47
48 def LoadDatabase(database_dir, use_database_cache):
49 common_database = database.Database(database_dir)
50 if use_database_cache:
51 common_database.LoadFromCache()
52 else:
53 common_database.Load()
54 return common_database
55
56 def GenerateFromDatabase(common_database, dart2js_output_dir,
57 dartium_output_dir):
43 current_dir = os.path.dirname(__file__) 58 current_dir = os.path.dirname(__file__)
44 auxiliary_dir = os.path.join(current_dir, '..', 'src') 59 auxiliary_dir = os.path.join(current_dir, '..', 'src')
45 template_dir = os.path.join(current_dir, '..', 'templates') 60 template_dir = os.path.join(current_dir, '..', 'templates')
46 61
47 generator = dartgenerator.DartGenerator() 62 generator = dartgenerator.DartGenerator()
48 generator.LoadAuxiliary(auxiliary_dir) 63 generator.LoadAuxiliary(auxiliary_dir)
49 64
50 common_database = database.Database(database_dir)
51 if use_database_cache:
52 common_database.LoadFromCache()
53 else:
54 common_database.Load()
55
56 generator.FilterMembersWithUnidentifiedTypes(common_database) 65 generator.FilterMembersWithUnidentifiedTypes(common_database)
57 webkit_database = common_database.Clone() 66 webkit_database = common_database.Clone()
58 67
59 # Generate Dart interfaces for the WebKit DOM. 68 # Generate Dart interfaces for the WebKit DOM.
60 generator.FilterInterfaces(database = webkit_database, 69 generator.FilterInterfaces(database = webkit_database,
61 or_annotations = ['WebKit', 'Dart'], 70 or_annotations = ['WebKit', 'Dart'],
62 exclude_displaced = ['WebKit'], 71 exclude_displaced = ['WebKit'],
63 exclude_suppressed = ['WebKit', 'Dart']) 72 exclude_suppressed = ['WebKit', 'Dart'])
64 generator.RenameTypes(webkit_database, _webkit_renames, True) 73 generator.RenameTypes(webkit_database, _webkit_renames, True)
65 generator.FixEventTargets(webkit_database) 74 generator.FixEventTargets(webkit_database)
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 library_dir = os.path.dirname(library_path) 138 library_dir = os.path.dirname(library_path)
130 library_filename = os.path.basename(library_path) 139 library_filename = os.path.basename(library_path)
131 copy_dart_script = os.path.relpath('../../../tools/copy_dart.py', library_dir) 140 copy_dart_script = os.path.relpath('../../../tools/copy_dart.py', library_dir)
132 output_dir = os.path.relpath(output_dir, library_dir) 141 output_dir = os.path.relpath(output_dir, library_dir)
133 command = ' '.join(['cd', library_dir, ';', 142 command = ' '.join(['cd', library_dir, ';',
134 copy_dart_script, output_dir, library_filename]) 143 copy_dart_script, output_dir, library_filename])
135 subprocess.call([command], shell=True) 144 subprocess.call([command], shell=True)
136 145
137 def main(): 146 def main():
138 parser = optparse.OptionParser() 147 parser = optparse.OptionParser()
148 parser.add_option('--rebuild', dest='rebuild',
149 action='store_true', default=False,
150 help='Rebuild the database from IDL using fremontcut.')
139 parser.add_option('--systems', dest='systems', 151 parser.add_option('--systems', dest='systems',
140 action='store', type='string', 152 action='store', type='string',
141 default='htmldart2js,htmldartium', 153 default='htmldart2js,htmldartium',
142 help='Systems to generate (htmldart2js, htmldartium)') 154 help='Systems to generate (htmldart2js, htmldartium)')
143 parser.add_option('--output-dir', dest='output_dir', 155 parser.add_option('--output-dir', dest='output_dir',
144 action='store', type='string', 156 action='store', type='string',
145 default=None, 157 default=None,
146 help='Directory to put the generated files') 158 help='Directory to put the generated files')
147 parser.add_option('--use-database-cache', dest='use_database_cache', 159 parser.add_option('--use-database-cache', dest='use_database_cache',
148 action='store_true', 160 action='store_true',
149 default=False, 161 default=False,
150 help='''Use the cached database from the previous run to 162 help='''Use the cached database from the previous run to
151 improve startup performance''') 163 improve startup performance''')
152 (options, args) = parser.parse_args() 164 (options, args) = parser.parse_args()
153 165
154 current_dir = os.path.dirname(__file__) 166 current_dir = os.path.dirname(__file__)
155 database_dir = os.path.join(current_dir, '..', 'database') 167 database_dir = os.path.join(current_dir, '..', 'database')
156 logging.config.fileConfig(os.path.join(current_dir, 'logging.conf')) 168 logging.config.fileConfig(os.path.join(current_dir, 'logging.conf'))
157 systems = options.systems.split(',') 169 systems = options.systems.split(',')
158 170
159 output_dir = options.output_dir or os.path.join(current_dir, '../generated') 171 output_dir = options.output_dir or os.path.join(current_dir, '../generated')
160 dart2js_output_dir = None 172 dart2js_output_dir = None
161 if 'htmldart2js' in systems: 173 if 'htmldart2js' in systems:
162 dart2js_output_dir = os.path.join(output_dir, 'dart2js') 174 dart2js_output_dir = os.path.join(output_dir, 'dart2js')
163 dartium_output_dir = None 175 dartium_output_dir = None
164 if 'htmldartium' in systems: 176 if 'htmldartium' in systems:
165 dartium_output_dir = os.path.join(output_dir, 'dartium') 177 dartium_output_dir = os.path.join(output_dir, 'dartium')
166 178
167 Generate(database_dir, options.use_database_cache, dart2js_output_dir, 179 if options.rebuild:
168 dartium_output_dir) 180 # Parse the IDL and create the database.
181 database = fremontcutbuilder.main()
182 else:
183 # Load the previously generated database.
184 database = LoadDatabase(database_dir, options.use_database_cache)
185 GenerateFromDatabase(database, dart2js_output_dir, dartium_output_dir)
169 186
170 if 'htmldart2js' in systems: 187 if 'htmldart2js' in systems:
171 _logger.info('Copy html_dart2js to dart2js/') 188 _logger.info('Copy html_dart2js to dart2js/')
172 GenerateSingleFile(os.path.join(dart2js_output_dir, 'html_dart2js.dart'), 189 GenerateSingleFile(os.path.join(dart2js_output_dir, 'html_dart2js.dart'),
173 '../dart2js') 190 '../dart2js')
174 if 'htmldartium' in systems: 191 if 'htmldartium' in systems:
175 _logger.info('Copy html_dartium to dartium/') 192 _logger.info('Copy html_dartium to dartium/')
176 GenerateSingleFile(os.path.join(dartium_output_dir, 'html_dartium.dart'), 193 GenerateSingleFile(os.path.join(dartium_output_dir, 'html_dartium.dart'),
177 '../dartium') 194 '../dartium')
178 195
179 if __name__ == '__main__': 196 if __name__ == '__main__':
180 sys.exit(main()) 197 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | lib/html/scripts/databasebuilder.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698