| 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 logging.config | 10 import logging.config |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 renamer = HtmlRenamer(webkit_database) | 82 renamer = HtmlRenamer(webkit_database) |
| 83 type_registry = TypeRegistry(webkit_database, renamer) | 83 type_registry = TypeRegistry(webkit_database, renamer) |
| 84 if system_name == 'htmldart2js': | 84 if system_name == 'htmldart2js': |
| 85 options = CreateGeneratorOptions( | 85 options = CreateGeneratorOptions( |
| 86 ['html/dart2js', 'html/impl', 'html', ''], | 86 ['html/dart2js', 'html/impl', 'html', ''], |
| 87 {'DARTIUM': False, 'DART2JS': True}, | 87 {'DARTIUM': False, 'DART2JS': True}, |
| 88 type_registry, html_output_dir, renamer) | 88 type_registry, html_output_dir, renamer) |
| 89 backend = HtmlDart2JSSystem(options) | 89 backend = HtmlDart2JSSystem(options) |
| 90 else: | 90 else: |
| 91 options = CreateGeneratorOptions( | 91 options = CreateGeneratorOptions( |
| 92 ['dom/native', 'html/dartium', 'html/impl', ''], | 92 ['html/dartium', 'html/impl', ''], |
| 93 {'DARTIUM': True, 'DART2JS': False}, | 93 {'DARTIUM': True, 'DART2JS': False}, |
| 94 type_registry, html_output_dir, renamer) | 94 type_registry, html_output_dir, renamer) |
| 95 backend = NativeImplementationSystem(options, auxiliary_dir) | 95 backend = NativeImplementationSystem(options, auxiliary_dir) |
| 96 options = CreateGeneratorOptions( | 96 options = CreateGeneratorOptions( |
| 97 ['html/interface', 'html/impl', 'html', ''], {}, | 97 ['html/interface', 'html/impl', 'html', ''], {}, |
| 98 type_registry, html_output_dir, renamer) | 98 type_registry, html_output_dir, renamer) |
| 99 html_system = HtmlInterfacesSystem(options, backend) | 99 html_system = HtmlInterfacesSystem(options, backend) |
| 100 Generate(html_system) | 100 Generate(html_system) |
| 101 | 101 |
| 102 _logger.info('Flush...') | 102 _logger.info('Flush...') |
| 103 emitters.Flush() | 103 emitters.Flush() |
| 104 | 104 |
| 105 def GenerateSingleFile(systems): | 105 def GenerateSingleFile(systems): |
| 106 if 'htmldart2js' in systems: | 106 if 'htmldart2js' in systems: |
| 107 _logger.info('Copy html_dart2js to ../html/dart2js/') | 107 _logger.info('Copy html_dart2js to dart2js/') |
| 108 subprocess.call(['cd ../../html/generated ; ' | 108 subprocess.call(['cd ../generated ; ' |
| 109 '../../../tools/copy_dart.py ../dart2js html_dart2js.dart']
, | 109 '../../../tools/copy_dart.py ../dart2js html_dart2js.dart']
, |
| 110 shell=True) | 110 shell=True) |
| 111 | 111 |
| 112 if 'htmldartium' in systems: | 112 if 'htmldartium' in systems: |
| 113 _logger.info('Copy html_dartium to ../html/dartium/') | 113 _logger.info('Copy html_dartium to dartium/') |
| 114 subprocess.call(['cd ../../html/generated ; ' | 114 subprocess.call(['cd ../generated ; ' |
| 115 '../../../tools/copy_dart.py ../dartium html_dartium.dart']
, | 115 '../../../tools/copy_dart.py ../dartium html_dartium.dart']
, |
| 116 shell=True) | 116 shell=True) |
| 117 | 117 |
| 118 def main(): | 118 def main(): |
| 119 parser = optparse.OptionParser() | 119 parser = optparse.OptionParser() |
| 120 parser.add_option('--systems', dest='systems', | 120 parser.add_option('--systems', dest='systems', |
| 121 action='store', type='string', | 121 action='store', type='string', |
| 122 default='htmldart2js,htmldartium', | 122 default='htmldart2js,htmldartium', |
| 123 help='Systems to generate (htmldart2js, htmldartium)') | 123 help='Systems to generate (htmldart2js, htmldartium)') |
| 124 parser.add_option('--output-dir', dest='output_dir', | 124 parser.add_option('--output-dir', dest='output_dir', |
| 125 action='store', type='string', | 125 action='store', type='string', |
| 126 default=None, | 126 default=None, |
| 127 help='Directory to put the generated files') | 127 help='Directory to put the generated files') |
| 128 parser.add_option('--use-database-cache', dest='use_database_cache', | 128 parser.add_option('--use-database-cache', dest='use_database_cache', |
| 129 action='store_true', | 129 action='store_true', |
| 130 default=False, | 130 default=False, |
| 131 help='''Use the cached database from the previous run to | 131 help='''Use the cached database from the previous run to |
| 132 improve startup performance''') | 132 improve startup performance''') |
| 133 (options, args) = parser.parse_args() | 133 (options, args) = parser.parse_args() |
| 134 | 134 |
| 135 current_dir = os.path.dirname(__file__) | 135 current_dir = os.path.dirname(__file__) |
| 136 database_dir = os.path.join(current_dir, '..', 'database') | 136 database_dir = os.path.join(current_dir, '..', 'database') |
| 137 logging.config.fileConfig(os.path.join(current_dir, 'logging.conf')) | 137 logging.config.fileConfig(os.path.join(current_dir, 'logging.conf')) |
| 138 systems = options.systems.split(',') | 138 systems = options.systems.split(',') |
| 139 | 139 |
| 140 html_output_dir = options.output_dir or os.path.join(current_dir, | 140 html_output_dir = options.output_dir or os.path.join(current_dir, |
| 141 '../../html/generated') | 141 '../generated') |
| 142 Generate(systems, database_dir, options.use_database_cache, | 142 Generate(systems, database_dir, options.use_database_cache, |
| 143 html_output_dir) | 143 html_output_dir) |
| 144 GenerateSingleFile(systems) | 144 GenerateSingleFile(systems) |
| 145 | 145 |
| 146 if __name__ == '__main__': | 146 if __name__ == '__main__': |
| 147 sys.exit(main()) | 147 sys.exit(main()) |
| OLD | NEW |