OLD | NEW |
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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 template_loader = TemplateLoader(template_dir, | 95 template_loader = TemplateLoader(template_dir, |
94 template_paths, | 96 template_paths, |
95 {'DARTIUM': False, 'DART2JS': True}) | 97 {'DARTIUM': False, 'DART2JS': True}) |
96 backend_options = GeneratorOptions( | 98 backend_options = GeneratorOptions( |
97 template_loader, webkit_database, type_registry, renamer) | 99 template_loader, webkit_database, type_registry, renamer) |
98 backend_factory = lambda interface:\ | 100 backend_factory = lambda interface:\ |
99 Dart2JSBackend(interface, backend_options) | 101 Dart2JSBackend(interface, backend_options) |
100 | 102 |
101 dart_output_dir = os.path.join(dart2js_output_dir, 'dart') | 103 dart_output_dir = os.path.join(dart2js_output_dir, 'dart') |
102 dart_libraries = DartLibraries( | 104 dart_libraries = DartLibraries( |
103 template_loader, 'dart2js', dart2js_output_dir) | 105 _libraries, template_loader, 'dart2js', dart2js_output_dir) |
104 | 106 |
105 RunGenerator(dart_libraries, dart_output_dir, | 107 RunGenerator(dart_libraries, dart_output_dir, |
106 template_loader, backend_factory) | 108 template_loader, backend_factory) |
107 | 109 |
108 if dartium_output_dir: | 110 if dartium_output_dir: |
109 template_paths = ['html/dartium', 'html/impl', 'html/interface', ''] | 111 template_paths = ['html/dartium', 'html/impl', 'html/interface', ''] |
110 template_loader = TemplateLoader(template_dir, | 112 template_loader = TemplateLoader(template_dir, |
111 template_paths, | 113 template_paths, |
112 {'DARTIUM': True, 'DART2JS': False}) | 114 {'DARTIUM': True, 'DART2JS': False}) |
113 backend_options = GeneratorOptions( | 115 backend_options = GeneratorOptions( |
114 template_loader, webkit_database, type_registry, renamer) | 116 template_loader, webkit_database, type_registry, renamer) |
115 cpp_output_dir = os.path.join(dartium_output_dir, 'cpp') | 117 cpp_output_dir = os.path.join(dartium_output_dir, 'cpp') |
116 cpp_library_emitter = CPPLibraryEmitter(emitters, cpp_output_dir) | 118 cpp_library_emitter = CPPLibraryEmitter(emitters, cpp_output_dir) |
117 backend_factory = lambda interface:\ | 119 backend_factory = lambda interface:\ |
118 DartiumBackend(interface, cpp_library_emitter, backend_options) | 120 DartiumBackend(interface, cpp_library_emitter, backend_options) |
119 | 121 |
120 dart_output_dir = os.path.join(dartium_output_dir, 'dart') | 122 dart_output_dir = os.path.join(dartium_output_dir, 'dart') |
121 dart_libraries = DartLibraries( | 123 dart_libraries = DartLibraries( |
122 template_loader, 'dartium', dartium_output_dir) | 124 _libraries, template_loader, 'dartium', dartium_output_dir) |
123 | 125 |
124 RunGenerator(dart_libraries, dart_output_dir, | 126 RunGenerator(dart_libraries, dart_output_dir, |
125 template_loader, backend_factory) | 127 template_loader, backend_factory) |
126 cpp_library_emitter.EmitDerivedSources( | 128 cpp_library_emitter.EmitDerivedSources( |
127 template_loader.Load('cpp_derived_sources.template'), | 129 template_loader.Load('cpp_derived_sources.template'), |
128 dartium_output_dir) | 130 dartium_output_dir) |
129 cpp_library_emitter.EmitResolver( | 131 cpp_library_emitter.EmitResolver( |
130 template_loader.Load('cpp_resolver.template'), dartium_output_dir) | 132 template_loader.Load('cpp_resolver.template'), dartium_output_dir) |
131 | 133 |
132 _logger.info('Flush...') | 134 _logger.info('Flush...') |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 svg_json_path = os.path.relpath('../docs/svg_docs.json') | 199 svg_json_path = os.path.relpath('../docs/svg_docs.json') |
198 html_command = ' '.join(['dart', html_to_json_script, '--mode=json-to-html', | 200 html_command = ' '.join(['dart', html_to_json_script, '--mode=json-to-html', |
199 html_output_dir, html_json_path]) | 201 html_output_dir, html_json_path]) |
200 svg_command = ' '.join(['dart', html_to_json_script, '--mode=json-to-html', | 202 svg_command = ' '.join(['dart', html_to_json_script, '--mode=json-to-html', |
201 svg_output_dir, svg_json_path]) | 203 svg_output_dir, svg_json_path]) |
202 subprocess.call([html_command], shell=True) | 204 subprocess.call([html_command], shell=True) |
203 subprocess.call([svg_command], shell=True) | 205 subprocess.call([svg_command], shell=True) |
204 | 206 |
205 if 'htmldart2js' in systems: | 207 if 'htmldart2js' in systems: |
206 _logger.info('Generating dart2js single files.') | 208 _logger.info('Generating dart2js single files.') |
207 GenerateSingleFile(os.path.join(dart2js_output_dir, 'html_dart2js.dart'), | 209 for library_name in _libraries: |
208 '../dart2js') | 210 GenerateSingleFile( |
209 GenerateSingleFile(os.path.join(dart2js_output_dir, 'svg_dart2js.dart'), | 211 os.path.join(dart2js_output_dir, '%s_dart2js.dart' % library_name), |
210 '../../svg/dart2js') | 212 '../../%s/dart2js' % library_name) |
211 if 'htmldartium' in systems: | 213 if 'htmldartium' in systems: |
212 _logger.info('Generating dartium single files.') | 214 _logger.info('Generating dartium single files.') |
213 GenerateSingleFile(os.path.join(dartium_output_dir, 'html_dartium.dart'), | 215 for library_name in _libraries: |
214 '../dartium') | 216 GenerateSingleFile( |
215 GenerateSingleFile(os.path.join(dartium_output_dir, 'svg_dartium.dart'), | 217 os.path.join(dartium_output_dir, '%s_dartium.dart' % library_name), |
216 '../../svg/dartium') | 218 '../../%s/dartium' % library_name) |
217 | 219 |
218 if __name__ == '__main__': | 220 if __name__ == '__main__': |
219 sys.exit(main()) | 221 sys.exit(main()) |
OLD | NEW |