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

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

Issue 259773004: Generate dart:blink in the SDK (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Adding dart:blink to SDK Created 6 years, 8 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 | « sdk/lib/web_sql/dartium/web_sql_dartium.dart ('k') | tools/dom/scripts/go.sh » ('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 fremontcutbuilder
11 import logging 11 import logging
12 import monitored 12 import monitored
13 import multiemitter 13 import multiemitter
14 import optparse 14 import optparse
15 import os 15 import os
16 import shutil 16 import shutil
17 import subprocess 17 import subprocess
18 import sys 18 import sys
19 from dartmetadata import DartMetadata 19 from dartmetadata import DartMetadata
20 from generator import TypeRegistry 20 from generator import TypeRegistry
21 from htmleventgenerator import HtmlEventGenerator 21 from htmleventgenerator import HtmlEventGenerator
22 from htmlrenamer import HtmlRenamer 22 from htmlrenamer import HtmlRenamer
23 from systemhtml import DartLibraryEmitter, Dart2JSBackend,\ 23 from systemhtml import DartLibraryEmitter, Dart2JSBackend,\
24 HtmlDartInterfaceGenerator, DartLibrary, DartLibraries,\ 24 HtmlDartInterfaceGenerator, DartLibrary, DartLibraries,\
25 HTML_LIBRARY_NAMES 25 HTML_LIBRARY_NAMES
26 from systemnative import CPPLibraryEmitter, DartiumBackend, \ 26 from systemnative import CPPLibraryEmitter, DartiumBackend, \
27 GetNativeLibraryEmitter, dart_use_blink 27 GetNativeLibraryEmitter
28 from templateloader import TemplateLoader 28 from templateloader import TemplateLoader
29 29
30 sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..')) 30 sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..'))
31 import utils 31 import utils
32 32
33 _logger = logging.getLogger('dartdomgenerator') 33 _logger = logging.getLogger('dartdomgenerator')
34 34
35 class GeneratorOptions(object): 35 class GeneratorOptions(object):
36 def __init__(self, templates, database, type_registry, renamer, 36 def __init__(self, templates, database, type_registry, renamer,
37 metadata): 37 metadata):
38 self.templates = templates 38 self.templates = templates
39 self.database = database 39 self.database = database
40 self.type_registry = type_registry 40 self.type_registry = type_registry
41 self.renamer = renamer 41 self.renamer = renamer
42 self.metadata = metadata; 42 self.metadata = metadata;
43 43
44 def LoadDatabase(database_dir, use_database_cache): 44 def LoadDatabase(database_dir, use_database_cache):
45 common_database = database.Database(database_dir) 45 common_database = database.Database(database_dir)
46 if use_database_cache: 46 if use_database_cache:
47 common_database.LoadFromCache() 47 common_database.LoadFromCache()
48 else: 48 else:
49 common_database.Load() 49 common_database.Load()
50 return common_database 50 return common_database
51 51
52 def GenerateFromDatabase(common_database, dart2js_output_dir, 52 def GenerateFromDatabase(common_database, dart2js_output_dir,
53 dartium_output_dir, update_dom_metadata=False): 53 dartium_output_dir, update_dom_metadata=False,
54 dart_use_blink=False):
54 current_dir = os.path.dirname(__file__) 55 current_dir = os.path.dirname(__file__)
55 auxiliary_dir = os.path.join(current_dir, '..', 'src') 56 auxiliary_dir = os.path.join(current_dir, '..', 'src')
56 template_dir = os.path.join(current_dir, '..', 'templates') 57 template_dir = os.path.join(current_dir, '..', 'templates')
57 58
58 generator = dartgenerator.DartGenerator() 59 generator = dartgenerator.DartGenerator()
59 generator.LoadAuxiliary(auxiliary_dir) 60 generator.LoadAuxiliary(auxiliary_dir)
60 61
61 generator.FilterMembersWithUnidentifiedTypes(common_database) 62 generator.FilterMembersWithUnidentifiedTypes(common_database)
62 webkit_database = common_database.Clone() 63 webkit_database = common_database.Clone()
63 64
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 metadata) 126 metadata)
126 cpp_output_dir = os.path.join(dartium_output_dir, 'cpp') 127 cpp_output_dir = os.path.join(dartium_output_dir, 'cpp')
127 cpp_library_emitter = CPPLibraryEmitter(emitters, cpp_output_dir) 128 cpp_library_emitter = CPPLibraryEmitter(emitters, cpp_output_dir)
128 dart_output_dir = os.path.join(dartium_output_dir, 'dart') 129 dart_output_dir = os.path.join(dartium_output_dir, 'dart')
129 native_library_emitter = \ 130 native_library_emitter = \
130 GetNativeLibraryEmitter(emitters, template_loader, 131 GetNativeLibraryEmitter(emitters, template_loader,
131 dartium_output_dir, dart_output_dir, 132 dartium_output_dir, dart_output_dir,
132 auxiliary_dir) 133 auxiliary_dir)
133 backend_factory = lambda interface:\ 134 backend_factory = lambda interface:\
134 DartiumBackend(interface, native_library_emitter, 135 DartiumBackend(interface, native_library_emitter,
135 cpp_library_emitter, backend_options) 136 cpp_library_emitter, backend_options, dart_use_blink)
136 dart_libraries = DartLibraries( 137 dart_libraries = DartLibraries(
137 HTML_LIBRARY_NAMES, template_loader, 'dartium', dartium_output_dir) 138 HTML_LIBRARY_NAMES, template_loader, 'dartium', dartium_output_dir)
138 RunGenerator(dart_libraries, dart_output_dir, 139 RunGenerator(dart_libraries, dart_output_dir,
139 template_loader, backend_factory) 140 template_loader, backend_factory)
140 cpp_library_emitter.EmitDerivedSources( 141 cpp_library_emitter.EmitDerivedSources(
141 template_loader.Load('cpp_derived_sources.template'), 142 template_loader.Load('cpp_derived_sources.template'),
142 dartium_output_dir) 143 dartium_output_dir)
143 cpp_library_emitter.EmitResolver( 144 cpp_library_emitter.EmitResolver(
144 template_loader.Load('cpp_resolver.template'), dartium_output_dir) 145 template_loader.Load('cpp_resolver.template'), dartium_output_dir)
145 cpp_library_emitter.EmitClassIdTable( 146 cpp_library_emitter.EmitClassIdTable(
(...skipping 24 matching lines...) Expand all
170 action='store_true', default=False, 171 action='store_true', default=False,
171 help='Rebuild the database from IDL using fremontcut.') 172 help='Rebuild the database from IDL using fremontcut.')
172 parser.add_option('--systems', dest='systems', 173 parser.add_option('--systems', dest='systems',
173 action='store', type='string', 174 action='store', type='string',
174 default='htmldart2js,htmldartium', 175 default='htmldart2js,htmldartium',
175 help='Systems to generate (htmldart2js, htmldartium)') 176 help='Systems to generate (htmldart2js, htmldartium)')
176 parser.add_option('--output-dir', dest='output_dir', 177 parser.add_option('--output-dir', dest='output_dir',
177 action='store', type='string', 178 action='store', type='string',
178 default=None, 179 default=None,
179 help='Directory to put the generated files') 180 help='Directory to put the generated files')
181 parser.add_option('--use-blink', dest='dart_use_blink',
182 action='store_true',
183 default=False,
184 help='''Delegate all native calls to dart:blink''')
180 parser.add_option('--use-database-cache', dest='use_database_cache', 185 parser.add_option('--use-database-cache', dest='use_database_cache',
181 action='store_true', 186 action='store_true',
182 default=False, 187 default=False,
183 help='''Use the cached database from the previous run to 188 help='''Use the cached database from the previous run to
184 improve startup performance''') 189 improve startup performance''')
185 parser.add_option('--update-dom-metadata', dest='update_dom_metadata', 190 parser.add_option('--update-dom-metadata', dest='update_dom_metadata',
186 action='store_true', 191 action='store_true',
187 default=False, 192 default=False,
188 help='''Update the metadata list of DOM APIs''') 193 help='''Update the metadata list of DOM APIs''')
189 (options, args) = parser.parse_args() 194 (options, args) = parser.parse_args()
(...skipping 14 matching lines...) Expand all
204 if 'htmldartium' in systems: 209 if 'htmldartium' in systems:
205 dartium_output_dir = os.path.join(output_dir, 'dartium') 210 dartium_output_dir = os.path.join(output_dir, 'dartium')
206 211
207 if options.rebuild: 212 if options.rebuild:
208 # Parse the IDL and create the database. 213 # Parse the IDL and create the database.
209 database = fremontcutbuilder.main(options.parallel) 214 database = fremontcutbuilder.main(options.parallel)
210 else: 215 else:
211 # Load the previously generated database. 216 # Load the previously generated database.
212 database = LoadDatabase(database_dir, options.use_database_cache) 217 database = LoadDatabase(database_dir, options.use_database_cache)
213 GenerateFromDatabase(database, dart2js_output_dir, dartium_output_dir, 218 GenerateFromDatabase(database, dart2js_output_dir, dartium_output_dir,
214 options.update_dom_metadata) 219 options.update_dom_metadata, options.dart_use_blink)
215 220
216 if 'htmldart2js' in systems: 221 if 'htmldart2js' in systems:
217 _logger.info('Generating dart2js single files.') 222 _logger.info('Generating dart2js single files.')
218 for library_name in HTML_LIBRARY_NAMES: 223 for library_name in HTML_LIBRARY_NAMES:
219 GenerateSingleFile( 224 GenerateSingleFile(
220 os.path.join(dart2js_output_dir, '%s_dart2js.dart' % library_name), 225 os.path.join(dart2js_output_dir, '%s_dart2js.dart' % library_name),
221 os.path.join('..', '..', '..', 'sdk', 'lib', library_name, 'dart2js')) 226 os.path.join('..', '..', '..', 'sdk', 'lib', library_name, 'dart2js'))
222 if 'htmldartium' in systems: 227 if 'htmldartium' in systems:
223 _logger.info('Generating dartium single files.') 228 _logger.info('Generating dartium single files.')
224 for library_name in HTML_LIBRARY_NAMES: 229 for library_name in HTML_LIBRARY_NAMES:
225 GenerateSingleFile( 230 GenerateSingleFile(
226 os.path.join(dartium_output_dir, '%s_dartium.dart' % library_name), 231 os.path.join(dartium_output_dir, '%s_dartium.dart' % library_name),
227 os.path.join('..', '..', '..', 'sdk', 'lib', library_name, 'dartium')) 232 os.path.join('..', '..', '..', 'sdk', 'lib', library_name, 'dartium'))
233 GenerateSingleFile(
234 os.path.join(dartium_output_dir, 'blink_dartium.dart'),
235 os.path.join('..', '..', '..', 'sdk', 'lib', 'blink', 'dartium'))
228 236
229 if __name__ == '__main__': 237 if __name__ == '__main__':
230 sys.exit(main()) 238 sys.exit(main())
OLDNEW
« no previous file with comments | « sdk/lib/web_sql/dartium/web_sql_dartium.dart ('k') | tools/dom/scripts/go.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698