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

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

Issue 11280103: Splitting out the Audio library. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Incorporating review feedback. Created 8 years 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
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.config 11 import logging.config
12 import multiemitter 12 import multiemitter
13 import optparse 13 import optparse
14 import os 14 import os
15 import shutil 15 import shutil
16 import subprocess 16 import subprocess
17 import sys 17 import sys
18 from generator import TypeRegistry 18 from generator import TypeRegistry
19 from htmleventgenerator import HtmlEventGenerator 19 from htmleventgenerator import HtmlEventGenerator
20 from htmlrenamer import HtmlRenamer 20 from htmlrenamer import HtmlRenamer
21 from systemhtml import DartLibraryEmitter, Dart2JSBackend,\ 21 from systemhtml import DartLibraryEmitter, Dart2JSBackend,\
22 HtmlDartInterfaceGenerator, DartLibrary, DartLibraries 22 HtmlDartInterfaceGenerator, DartLibrary, DartLibraries
23 from systemnative import CPPLibraryEmitter, DartiumBackend 23 from systemnative import CPPLibraryEmitter, DartiumBackend
24 from templateloader import TemplateLoader 24 from templateloader import TemplateLoader
25 25
26 _logger = logging.getLogger('dartdomgenerator') 26 _logger = logging.getLogger('dartdomgenerator')
27 27
28 _libraries = ['html', 'svg', 'web_audio']
29
28 class GeneratorOptions(object): 30 class GeneratorOptions(object):
29 def __init__(self, templates, database, type_registry, renamer): 31 def __init__(self, templates, database, type_registry, renamer):
30 self.templates = templates 32 self.templates = templates
31 self.database = database 33 self.database = database
32 self.type_registry = type_registry 34 self.type_registry = type_registry
33 self.renamer = renamer 35 self.renamer = renamer
34 36
35 # TODO(vsm): Remove once we fix Dartium to pass in the database directly. 37 # TODO(vsm): Remove once we fix Dartium to pass in the database directly.
36 def Generate(database_dir, use_database_cache, dart2js_output_dir=None, 38 def Generate(database_dir, use_database_cache, dart2js_output_dir=None,
37 dartium_output_dir=None): 39 dartium_output_dir=None):
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 template_loader = TemplateLoader(template_dir, 94 template_loader = TemplateLoader(template_dir,
93 template_paths, 95 template_paths,
94 {'DARTIUM': False, 'DART2JS': True}) 96 {'DARTIUM': False, 'DART2JS': True})
95 backend_options = GeneratorOptions( 97 backend_options = GeneratorOptions(
96 template_loader, webkit_database, type_registry, renamer) 98 template_loader, webkit_database, type_registry, renamer)
97 backend_factory = lambda interface:\ 99 backend_factory = lambda interface:\
98 Dart2JSBackend(interface, backend_options) 100 Dart2JSBackend(interface, backend_options)
99 101
100 dart_output_dir = os.path.join(dart2js_output_dir, 'dart') 102 dart_output_dir = os.path.join(dart2js_output_dir, 'dart')
101 dart_libraries = DartLibraries( 103 dart_libraries = DartLibraries(
102 template_loader, 'dart2js', dart2js_output_dir) 104 _libraries, template_loader, 'dart2js', dart2js_output_dir)
103 105
104 RunGenerator(dart_libraries, dart_output_dir, 106 RunGenerator(dart_libraries, dart_output_dir,
105 template_loader, backend_factory) 107 template_loader, backend_factory)
106 108
107 if dartium_output_dir: 109 if dartium_output_dir:
108 template_paths = ['html/dartium', 'html/impl', 'html/interface', ''] 110 template_paths = ['html/dartium', 'html/impl', 'html/interface', '']
109 template_loader = TemplateLoader(template_dir, 111 template_loader = TemplateLoader(template_dir,
110 template_paths, 112 template_paths,
111 {'DARTIUM': True, 'DART2JS': False}) 113 {'DARTIUM': True, 'DART2JS': False})
112 backend_options = GeneratorOptions( 114 backend_options = GeneratorOptions(
113 template_loader, webkit_database, type_registry, renamer) 115 template_loader, webkit_database, type_registry, renamer)
114 cpp_output_dir = os.path.join(dartium_output_dir, 'cpp') 116 cpp_output_dir = os.path.join(dartium_output_dir, 'cpp')
115 cpp_library_emitter = CPPLibraryEmitter(emitters, cpp_output_dir) 117 cpp_library_emitter = CPPLibraryEmitter(emitters, cpp_output_dir)
116 backend_factory = lambda interface:\ 118 backend_factory = lambda interface:\
117 DartiumBackend(interface, cpp_library_emitter, backend_options) 119 DartiumBackend(interface, cpp_library_emitter, backend_options)
118 120
119 dart_output_dir = os.path.join(dartium_output_dir, 'dart') 121 dart_output_dir = os.path.join(dartium_output_dir, 'dart')
120 dart_libraries = DartLibraries( 122 dart_libraries = DartLibraries(
121 template_loader, 'dartium', dartium_output_dir) 123 _libraries, template_loader, 'dartium', dartium_output_dir)
122 124
123 RunGenerator(dart_libraries, dart_output_dir, 125 RunGenerator(dart_libraries, dart_output_dir,
124 template_loader, backend_factory) 126 template_loader, backend_factory)
125 cpp_library_emitter.EmitDerivedSources( 127 cpp_library_emitter.EmitDerivedSources(
126 template_loader.Load('cpp_derived_sources.template'), 128 template_loader.Load('cpp_derived_sources.template'),
127 dartium_output_dir) 129 dartium_output_dir)
128 cpp_library_emitter.EmitResolver( 130 cpp_library_emitter.EmitResolver(
129 template_loader.Load('cpp_resolver.template'), dartium_output_dir) 131 template_loader.Load('cpp_resolver.template'), dartium_output_dir)
130 132
131 _logger.info('Flush...') 133 _logger.info('Flush...')
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 if options.rebuild: 182 if options.rebuild:
181 # Parse the IDL and create the database. 183 # Parse the IDL and create the database.
182 database = fremontcutbuilder.main(options.parallel) 184 database = fremontcutbuilder.main(options.parallel)
183 else: 185 else:
184 # Load the previously generated database. 186 # Load the previously generated database.
185 database = LoadDatabase(database_dir, options.use_database_cache) 187 database = LoadDatabase(database_dir, options.use_database_cache)
186 GenerateFromDatabase(database, dart2js_output_dir, dartium_output_dir) 188 GenerateFromDatabase(database, dart2js_output_dir, dartium_output_dir)
187 189
188 if 'htmldart2js' in systems: 190 if 'htmldart2js' in systems:
189 _logger.info('Generating dart2js single files.') 191 _logger.info('Generating dart2js single files.')
190 GenerateSingleFile(os.path.join(dart2js_output_dir, 'html_dart2js.dart'), 192 for library_name in _libraries:
191 '../dart2js') 193 GenerateSingleFile(
192 GenerateSingleFile(os.path.join(dart2js_output_dir, 'svg_dart2js.dart'), 194 os.path.join(dart2js_output_dir, '%s_dart2js.dart' % library_name),
193 '../../svg/dart2js') 195 '../../%s/dart2js' % library_name)
194 if 'htmldartium' in systems: 196 if 'htmldartium' in systems:
195 _logger.info('Generating dartium single files.') 197 _logger.info('Generating dartium single files.')
196 GenerateSingleFile(os.path.join(dartium_output_dir, 'html_dartium.dart'), 198 for library_name in _libraries:
197 '../dartium') 199 GenerateSingleFile(
198 GenerateSingleFile(os.path.join(dartium_output_dir, 'svg_dartium.dart'), 200 os.path.join(dartium_output_dir, '%s_dartium.dart' % library_name),
199 '../../svg/dartium') 201 '../../%s/dartium' % library_name)
200 202
201 if __name__ == '__main__': 203 if __name__ == '__main__':
202 sys.exit(main()) 204 sys.exit(main())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698