| 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 css_code_generator | 8 import css_code_generator |
| 9 import dartgenerator | 9 import dartgenerator |
| 10 import database | 10 import database |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 | 44 |
| 45 def LoadDatabase(database_dir, use_database_cache): | 45 def LoadDatabase(database_dir, use_database_cache): |
| 46 common_database = database.Database(database_dir) | 46 common_database = database.Database(database_dir) |
| 47 if use_database_cache: | 47 if use_database_cache: |
| 48 common_database.LoadFromCache() | 48 common_database.LoadFromCache() |
| 49 else: | 49 else: |
| 50 common_database.Load() | 50 common_database.Load() |
| 51 return common_database | 51 return common_database |
| 52 | 52 |
| 53 def GenerateFromDatabase(common_database, dart2js_output_dir, | 53 def GenerateFromDatabase(common_database, dart2js_output_dir, |
| 54 dartium_output_dir, update_dom_metadata=False, | 54 dartium_output_dir, update_dom_metadata=False): |
| 55 dart_use_blink=False): | |
| 56 current_dir = os.path.dirname(__file__) | 55 current_dir = os.path.dirname(__file__) |
| 57 auxiliary_dir = os.path.join(current_dir, '..', 'src') | 56 auxiliary_dir = os.path.join(current_dir, '..', 'src') |
| 58 template_dir = os.path.join(current_dir, '..', 'templates') | 57 template_dir = os.path.join(current_dir, '..', 'templates') |
| 59 | 58 |
| 60 generator = dartgenerator.DartGenerator() | 59 generator = dartgenerator.DartGenerator() |
| 61 generator.LoadAuxiliary(auxiliary_dir) | 60 generator.LoadAuxiliary(auxiliary_dir) |
| 62 | 61 |
| 63 generator.FilterMembersWithUnidentifiedTypes(common_database) | 62 generator.FilterMembersWithUnidentifiedTypes(common_database) |
| 64 webkit_database = common_database.Clone() | 63 webkit_database = common_database.Clone() |
| 65 | 64 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 95 interface_generator.Generate() | 94 interface_generator.Generate() |
| 96 | 95 |
| 97 generator.Generate(webkit_database, common_database, generate_interface) | 96 generator.Generate(webkit_database, common_database, generate_interface) |
| 98 | 97 |
| 99 dart_library_emitter.EmitLibraries(auxiliary_dir) | 98 dart_library_emitter.EmitLibraries(auxiliary_dir) |
| 100 | 99 |
| 101 if dart2js_output_dir: | 100 if dart2js_output_dir: |
| 102 template_paths = ['html/dart2js', 'html/impl', 'html/interface', ''] | 101 template_paths = ['html/dart2js', 'html/impl', 'html/interface', ''] |
| 103 template_loader = TemplateLoader(template_dir, | 102 template_loader = TemplateLoader(template_dir, |
| 104 template_paths, | 103 template_paths, |
| 105 {'DARTIUM': False, 'DART2JS': True, | 104 {'DARTIUM': False, 'DART2JS': True}) |
| 106 'DART_USE_BLINK' : False}) | |
| 107 backend_options = GeneratorOptions( | 105 backend_options = GeneratorOptions( |
| 108 template_loader, webkit_database, type_registry, renamer, | 106 template_loader, webkit_database, type_registry, renamer, |
| 109 metadata) | 107 metadata) |
| 110 backend_factory = lambda interface:\ | 108 backend_factory = lambda interface:\ |
| 111 Dart2JSBackend(interface, backend_options) | 109 Dart2JSBackend(interface, backend_options) |
| 112 | 110 |
| 113 dart_output_dir = os.path.join(dart2js_output_dir, 'dart') | 111 dart_output_dir = os.path.join(dart2js_output_dir, 'dart') |
| 114 dart_libraries = DartLibraries( | 112 dart_libraries = DartLibraries( |
| 115 HTML_LIBRARY_NAMES, template_loader, 'dart2js', dart2js_output_dir) | 113 HTML_LIBRARY_NAMES, template_loader, 'dart2js', dart2js_output_dir) |
| 116 | 114 |
| 117 RunGenerator(dart_libraries, dart_output_dir, | 115 RunGenerator(dart_libraries, dart_output_dir, |
| 118 template_loader, backend_factory) | 116 template_loader, backend_factory) |
| 119 | 117 |
| 120 if dartium_output_dir: | 118 if dartium_output_dir: |
| 121 template_paths = ['html/dartium', 'html/impl', 'html/interface', ''] | 119 template_paths = ['html/dartium', 'html/impl', 'html/interface', ''] |
| 122 template_loader = TemplateLoader(template_dir, | 120 template_loader = TemplateLoader(template_dir, |
| 123 template_paths, | 121 template_paths, |
| 124 {'DARTIUM': True, 'DART2JS': False, | 122 {'DARTIUM': True, 'DART2JS': False}) |
| 125 'DART_USE_BLINK' : dart_use_blink}) | |
| 126 backend_options = GeneratorOptions( | 123 backend_options = GeneratorOptions( |
| 127 template_loader, webkit_database, type_registry, renamer, | 124 template_loader, webkit_database, type_registry, renamer, |
| 128 metadata) | 125 metadata) |
| 129 cpp_output_dir = os.path.join(dartium_output_dir, 'cpp') | 126 cpp_output_dir = os.path.join(dartium_output_dir, 'cpp') |
| 130 cpp_library_emitter = CPPLibraryEmitter(emitters, cpp_output_dir) | 127 cpp_library_emitter = CPPLibraryEmitter(emitters, cpp_output_dir) |
| 131 dart_output_dir = os.path.join(dartium_output_dir, 'dart') | 128 dart_output_dir = os.path.join(dartium_output_dir, 'dart') |
| 132 native_library_emitter = \ | 129 native_library_emitter = \ |
| 133 GetNativeLibraryEmitter(emitters, template_loader, | 130 GetNativeLibraryEmitter(emitters, template_loader, |
| 134 dartium_output_dir, dart_output_dir, | 131 dartium_output_dir, dart_output_dir, |
| 135 auxiliary_dir) | 132 auxiliary_dir) |
| 136 backend_factory = lambda interface:\ | 133 backend_factory = lambda interface:\ |
| 137 DartiumBackend(interface, native_library_emitter, | 134 DartiumBackend(interface, native_library_emitter, |
| 138 cpp_library_emitter, backend_options, dart_use_blink) | 135 cpp_library_emitter, backend_options) |
| 139 dart_libraries = DartLibraries( | 136 dart_libraries = DartLibraries( |
| 140 HTML_LIBRARY_NAMES, template_loader, 'dartium', dartium_output_dir) | 137 HTML_LIBRARY_NAMES, template_loader, 'dartium', dartium_output_dir) |
| 141 RunGenerator(dart_libraries, dart_output_dir, | 138 RunGenerator(dart_libraries, dart_output_dir, |
| 142 template_loader, backend_factory) | 139 template_loader, backend_factory) |
| 143 cpp_library_emitter.EmitDerivedSources( | 140 cpp_library_emitter.EmitDerivedSources( |
| 144 template_loader.Load('cpp_derived_sources.template'), | 141 template_loader.Load('cpp_derived_sources.template'), |
| 145 dartium_output_dir) | 142 dartium_output_dir) |
| 146 cpp_library_emitter.EmitResolver( | 143 cpp_library_emitter.EmitResolver( |
| 147 template_loader.Load('cpp_resolver.template'), dartium_output_dir) | 144 template_loader.Load('cpp_resolver.template'), dartium_output_dir) |
| 148 cpp_library_emitter.EmitClassIdTable( | 145 cpp_library_emitter.EmitClassIdTable( |
| (...skipping 30 matching lines...) Expand all Loading... |
| 179 action='store_true', default=False, | 176 action='store_true', default=False, |
| 180 help='Rebuild the database from IDL using fremontcut.') | 177 help='Rebuild the database from IDL using fremontcut.') |
| 181 parser.add_option('--systems', dest='systems', | 178 parser.add_option('--systems', dest='systems', |
| 182 action='store', type='string', | 179 action='store', type='string', |
| 183 default='htmldart2js,htmldartium', | 180 default='htmldart2js,htmldartium', |
| 184 help='Systems to generate (htmldart2js, htmldartium)') | 181 help='Systems to generate (htmldart2js, htmldartium)') |
| 185 parser.add_option('--output-dir', dest='output_dir', | 182 parser.add_option('--output-dir', dest='output_dir', |
| 186 action='store', type='string', | 183 action='store', type='string', |
| 187 default=None, | 184 default=None, |
| 188 help='Directory to put the generated files') | 185 help='Directory to put the generated files') |
| 189 parser.add_option('--use-blink', dest='dart_use_blink', | |
| 190 action='store_true', | |
| 191 default=False, | |
| 192 help='''Delegate all native calls to dart:blink''') | |
| 193 parser.add_option('--use-database-cache', dest='use_database_cache', | 186 parser.add_option('--use-database-cache', dest='use_database_cache', |
| 194 action='store_true', | 187 action='store_true', |
| 195 default=False, | 188 default=False, |
| 196 help='''Use the cached database from the previous run to | 189 help='''Use the cached database from the previous run to |
| 197 improve startup performance''') | 190 improve startup performance''') |
| 198 parser.add_option('--update-dom-metadata', dest='update_dom_metadata', | 191 parser.add_option('--update-dom-metadata', dest='update_dom_metadata', |
| 199 action='store_true', | 192 action='store_true', |
| 200 default=False, | 193 default=False, |
| 201 help='''Update the metadata list of DOM APIs''') | 194 help='''Update the metadata list of DOM APIs''') |
| 202 (options, args) = parser.parse_args() | 195 (options, args) = parser.parse_args() |
| (...skipping 15 matching lines...) Expand all Loading... |
| 218 dartium_output_dir = os.path.join(output_dir, 'dartium') | 211 dartium_output_dir = os.path.join(output_dir, 'dartium') |
| 219 | 212 |
| 220 UpdateCssProperties() | 213 UpdateCssProperties() |
| 221 if options.rebuild: | 214 if options.rebuild: |
| 222 # Parse the IDL and create the database. | 215 # Parse the IDL and create the database. |
| 223 database = fremontcutbuilder.main(options.parallel) | 216 database = fremontcutbuilder.main(options.parallel) |
| 224 else: | 217 else: |
| 225 # Load the previously generated database. | 218 # Load the previously generated database. |
| 226 database = LoadDatabase(database_dir, options.use_database_cache) | 219 database = LoadDatabase(database_dir, options.use_database_cache) |
| 227 GenerateFromDatabase(database, dart2js_output_dir, dartium_output_dir, | 220 GenerateFromDatabase(database, dart2js_output_dir, dartium_output_dir, |
| 228 options.update_dom_metadata, options.dart_use_blink) | 221 options.update_dom_metadata) |
| 229 | 222 |
| 230 if 'htmldart2js' in systems: | 223 if 'htmldart2js' in systems: |
| 231 _logger.info('Generating dart2js single files.') | 224 _logger.info('Generating dart2js single files.') |
| 232 for library_name in HTML_LIBRARY_NAMES: | 225 for library_name in HTML_LIBRARY_NAMES: |
| 233 GenerateSingleFile( | 226 GenerateSingleFile( |
| 234 os.path.join(dart2js_output_dir, '%s_dart2js.dart' % library_name), | 227 os.path.join(dart2js_output_dir, '%s_dart2js.dart' % library_name), |
| 235 os.path.join('..', '..', '..', 'sdk', 'lib', library_name, 'dart2js')) | 228 os.path.join('..', '..', '..', 'sdk', 'lib', library_name, 'dart2js')) |
| 236 if 'htmldartium' in systems: | 229 if 'htmldartium' in systems: |
| 237 _logger.info('Generating dartium single files.') | 230 _logger.info('Generating dartium single files.') |
| 238 for library_name in HTML_LIBRARY_NAMES: | 231 for library_name in HTML_LIBRARY_NAMES: |
| 239 GenerateSingleFile( | 232 GenerateSingleFile( |
| 240 os.path.join(dartium_output_dir, '%s_dartium.dart' % library_name), | 233 os.path.join(dartium_output_dir, '%s_dartium.dart' % library_name), |
| 241 os.path.join('..', '..', '..', 'sdk', 'lib', library_name, 'dartium')) | 234 os.path.join('..', '..', '..', 'sdk', 'lib', library_name, 'dartium')) |
| 242 GenerateSingleFile( | 235 GenerateSingleFile( |
| 243 os.path.join(dartium_output_dir, '_blink_dartium.dart'), | 236 os.path.join(dartium_output_dir, '_blink_dartium.dart'), |
| 244 os.path.join('..', '..', '..', 'sdk', 'lib', '_blink', 'dartium')) | 237 os.path.join('..', '..', '..', 'sdk', 'lib', '_blink', 'dartium')) |
| 245 | 238 |
| 246 if __name__ == '__main__': | 239 if __name__ == '__main__': |
| 247 sys.exit(main()) | 240 sys.exit(main()) |
| OLD | NEW |