Chromium Code Reviews| 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 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 42 | 42 |
| 43 def LoadDatabase(database_dir, use_database_cache): | 43 def LoadDatabase(database_dir, use_database_cache): |
| 44 common_database = database.Database(database_dir) | 44 common_database = database.Database(database_dir) |
| 45 if use_database_cache: | 45 if use_database_cache: |
| 46 common_database.LoadFromCache() | 46 common_database.LoadFromCache() |
| 47 else: | 47 else: |
| 48 common_database.Load() | 48 common_database.Load() |
| 49 return common_database | 49 return common_database |
| 50 | 50 |
| 51 def GenerateFromDatabase(common_database, dart2js_output_dir, | 51 def GenerateFromDatabase(common_database, dart2js_output_dir, |
| 52 dartium_output_dir): | 52 dartium_output_dir, update_dom_metadata): |
|
vsm
2013/05/22 23:21:17
Note, you'll need to update Dartium as well where
blois
2013/05/23 20:26:55
Great catch, I just defaulted to to false.
| |
| 53 current_dir = os.path.dirname(__file__) | 53 current_dir = os.path.dirname(__file__) |
| 54 auxiliary_dir = os.path.join(current_dir, '..', 'src') | 54 auxiliary_dir = os.path.join(current_dir, '..', 'src') |
| 55 template_dir = os.path.join(current_dir, '..', 'templates') | 55 template_dir = os.path.join(current_dir, '..', 'templates') |
| 56 | 56 |
| 57 generator = dartgenerator.DartGenerator() | 57 generator = dartgenerator.DartGenerator() |
| 58 generator.LoadAuxiliary(auxiliary_dir) | 58 generator.LoadAuxiliary(auxiliary_dir) |
| 59 | 59 |
| 60 generator.FilterMembersWithUnidentifiedTypes(common_database) | 60 generator.FilterMembersWithUnidentifiedTypes(common_database) |
| 61 webkit_database = common_database.Clone() | 61 webkit_database = common_database.Clone() |
| 62 | 62 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 133 RunGenerator(dart_libraries, dart_output_dir, | 133 RunGenerator(dart_libraries, dart_output_dir, |
| 134 template_loader, backend_factory) | 134 template_loader, backend_factory) |
| 135 cpp_library_emitter.EmitDerivedSources( | 135 cpp_library_emitter.EmitDerivedSources( |
| 136 template_loader.Load('cpp_derived_sources.template'), | 136 template_loader.Load('cpp_derived_sources.template'), |
| 137 dartium_output_dir) | 137 dartium_output_dir) |
| 138 cpp_library_emitter.EmitResolver( | 138 cpp_library_emitter.EmitResolver( |
| 139 template_loader.Load('cpp_resolver.template'), dartium_output_dir) | 139 template_loader.Load('cpp_resolver.template'), dartium_output_dir) |
| 140 | 140 |
| 141 _logger.info('Flush...') | 141 _logger.info('Flush...') |
| 142 emitters.Flush() | 142 emitters.Flush() |
| 143 metadata.Flush() | 143 |
| 144 if update_dom_metadata: | |
| 145 metadata.Flush() | |
| 144 | 146 |
| 145 monitored.FinishMonitoring(dart2js_output_dir) | 147 monitored.FinishMonitoring(dart2js_output_dir) |
| 146 | 148 |
| 147 def GenerateSingleFile(library_path, output_dir, generated_output_dir=None): | 149 def GenerateSingleFile(library_path, output_dir, generated_output_dir=None): |
| 148 library_dir = os.path.dirname(library_path) | 150 library_dir = os.path.dirname(library_path) |
| 149 library_filename = os.path.basename(library_path) | 151 library_filename = os.path.basename(library_path) |
| 150 copy_dart_script = os.path.relpath('../../copy_dart.py', | 152 copy_dart_script = os.path.relpath('../../copy_dart.py', |
| 151 library_dir) | 153 library_dir) |
| 152 output_dir = os.path.relpath(output_dir, library_dir) | 154 output_dir = os.path.relpath(output_dir, library_dir) |
| 153 command = ' '.join(['cd', library_dir, ';', | 155 command = ' '.join(['cd', library_dir, ';', |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 168 help='Systems to generate (htmldart2js, htmldartium)') | 170 help='Systems to generate (htmldart2js, htmldartium)') |
| 169 parser.add_option('--output-dir', dest='output_dir', | 171 parser.add_option('--output-dir', dest='output_dir', |
| 170 action='store', type='string', | 172 action='store', type='string', |
| 171 default=None, | 173 default=None, |
| 172 help='Directory to put the generated files') | 174 help='Directory to put the generated files') |
| 173 parser.add_option('--use-database-cache', dest='use_database_cache', | 175 parser.add_option('--use-database-cache', dest='use_database_cache', |
| 174 action='store_true', | 176 action='store_true', |
| 175 default=False, | 177 default=False, |
| 176 help='''Use the cached database from the previous run to | 178 help='''Use the cached database from the previous run to |
| 177 improve startup performance''') | 179 improve startup performance''') |
| 180 parser.add_option('--update-dom-metadata', dest='update_dom_metadata', | |
| 181 action='store_true', | |
| 182 default=False, | |
| 183 help='''Update the metadata list of DOM APIs''') | |
| 178 (options, args) = parser.parse_args() | 184 (options, args) = parser.parse_args() |
| 179 | 185 |
| 180 current_dir = os.path.dirname(__file__) | 186 current_dir = os.path.dirname(__file__) |
| 181 database_dir = os.path.join(current_dir, '..', 'database') | 187 database_dir = os.path.join(current_dir, '..', 'database') |
| 182 logging.config.fileConfig(os.path.join(current_dir, 'logging.conf')) | 188 logging.config.fileConfig(os.path.join(current_dir, 'logging.conf')) |
| 183 systems = options.systems.split(',') | 189 systems = options.systems.split(',') |
| 184 | 190 |
| 185 output_dir = options.output_dir or os.path.join( | 191 output_dir = options.output_dir or os.path.join( |
| 186 current_dir, '..', '..', utils.GetBuildDir(utils.GuessOS(), None), | 192 current_dir, '..', '..', utils.GetBuildDir(utils.GuessOS(), None), |
| 187 'generated') | 193 'generated') |
| 188 | 194 |
| 189 dart2js_output_dir = None | 195 dart2js_output_dir = None |
| 190 if 'htmldart2js' in systems: | 196 if 'htmldart2js' in systems: |
| 191 dart2js_output_dir = os.path.join(output_dir, 'dart2js') | 197 dart2js_output_dir = os.path.join(output_dir, 'dart2js') |
| 192 dartium_output_dir = None | 198 dartium_output_dir = None |
| 193 if 'htmldartium' in systems: | 199 if 'htmldartium' in systems: |
| 194 dartium_output_dir = os.path.join(output_dir, 'dartium') | 200 dartium_output_dir = os.path.join(output_dir, 'dartium') |
| 195 | 201 |
| 196 if options.rebuild: | 202 if options.rebuild: |
| 197 # Parse the IDL and create the database. | 203 # Parse the IDL and create the database. |
| 198 database = fremontcutbuilder.main(options.parallel) | 204 database = fremontcutbuilder.main(options.parallel) |
| 199 else: | 205 else: |
| 200 # Load the previously generated database. | 206 # Load the previously generated database. |
| 201 database = LoadDatabase(database_dir, options.use_database_cache) | 207 database = LoadDatabase(database_dir, options.use_database_cache) |
| 202 GenerateFromDatabase(database, dart2js_output_dir, dartium_output_dir) | 208 GenerateFromDatabase(database, dart2js_output_dir, dartium_output_dir, |
| 209 options.update_dom_metadata) | |
| 203 | 210 |
| 204 if 'htmldart2js' in systems: | 211 if 'htmldart2js' in systems: |
| 205 _logger.info('Generating dart2js single files.') | 212 _logger.info('Generating dart2js single files.') |
| 206 for library_name in HTML_LIBRARY_NAMES: | 213 for library_name in HTML_LIBRARY_NAMES: |
| 207 GenerateSingleFile( | 214 GenerateSingleFile( |
| 208 os.path.join(dart2js_output_dir, '%s_dart2js.dart' % library_name), | 215 os.path.join(dart2js_output_dir, '%s_dart2js.dart' % library_name), |
| 209 os.path.join('..', '..', '..', 'sdk', 'lib', library_name, 'dart2js')) | 216 os.path.join('..', '..', '..', 'sdk', 'lib', library_name, 'dart2js')) |
| 210 if 'htmldartium' in systems: | 217 if 'htmldartium' in systems: |
| 211 _logger.info('Generating dartium single files.') | 218 _logger.info('Generating dartium single files.') |
| 212 for library_name in HTML_LIBRARY_NAMES: | 219 for library_name in HTML_LIBRARY_NAMES: |
| 213 GenerateSingleFile( | 220 GenerateSingleFile( |
| 214 os.path.join(dartium_output_dir, '%s_dartium.dart' % library_name), | 221 os.path.join(dartium_output_dir, '%s_dartium.dart' % library_name), |
| 215 os.path.join('..', '..', '..', 'sdk', 'lib', library_name, 'dartium')) | 222 os.path.join('..', '..', '..', 'sdk', 'lib', library_name, 'dartium')) |
| 216 | 223 |
| 217 if __name__ == '__main__': | 224 if __name__ == '__main__': |
| 218 sys.exit(main()) | 225 sys.exit(main()) |
| OLD | NEW |