| 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 implementation_system = FrogSystem( | 132 implementation_system = FrogSystem( |
| 133 TemplateLoader(template_dir, ['dom/frog', 'dom', '']), | 133 TemplateLoader(template_dir, ['dom/frog', 'dom', '']), |
| 134 target_database, emitters, output_dir) | 134 target_database, emitters, output_dir) |
| 135 elif system == 'htmlfrog': | 135 elif system == 'htmlfrog': |
| 136 implementation_system = HtmlFrogSystem( | 136 implementation_system = HtmlFrogSystem( |
| 137 TemplateLoader(template_dir, | 137 TemplateLoader(template_dir, |
| 138 ['html/frog', 'html/impl', 'html', ''], | 138 ['html/frog', 'html/impl', 'html', ''], |
| 139 {'DARTIUM': False, 'FROG': True}), | 139 {'DARTIUM': False, 'FROG': True}), |
| 140 target_database, emitters, output_dir) | 140 target_database, emitters, output_dir) |
| 141 elif system == 'htmldartium': | 141 elif system == 'htmldartium': |
| 142 # Generate native wrappers. |
| 143 native_system = NativeImplementationSystem( |
| 144 TemplateLoader(template_dir, ['dom/native', 'dom', '']), |
| 145 dom_database, html_renames, emitters, auxiliary_dir, |
| 146 output_dir) |
| 147 generator.Generate(dom_database, native_system, |
| 148 source_filter=['WebKit', 'Dart'], |
| 149 super_database=common_database, |
| 150 common_prefix='common', |
| 151 webkit_renames=_webkit_renames, |
| 152 html_renames=html_renames) |
| 153 dom_implementation_classes = native_system.DartImplementationFiles() |
| 142 implementation_system = HtmlDartiumSystem( | 154 implementation_system = HtmlDartiumSystem( |
| 143 TemplateLoader(template_dir, | 155 TemplateLoader(template_dir, |
| 144 ['html/dartium', 'html/impl', 'html', ''], | 156 ['html/dartium', 'html/impl', 'html', ''], |
| 145 {'DARTIUM': True, 'FROG': False}), | 157 {'DARTIUM': True, 'FROG': False}), |
| 146 target_database, emitters, auxiliary_dir, | 158 target_database, emitters, auxiliary_dir, dom_implementation_classes, |
| 147 output_dir) | |
| 148 elif system == 'native': | |
| 149 implementation_system = NativeImplementationSystem( | |
| 150 TemplateLoader(template_dir, ['dom/native', 'dom', '']), | |
| 151 target_database, html_renames, emitters, auxiliary_dir, | |
| 152 output_dir) | 159 output_dir) |
| 153 else: | 160 else: |
| 154 raise Exception('Unsupported system %s' % system) | 161 raise Exception('Unsupported system %s' % system) |
| 155 | 162 |
| 156 # Makes interface files available for listing in the library for the | 163 # Makes interface files available for listing in the library for the |
| 157 # implementation system. | 164 # implementation system. |
| 158 implementation_system._interface_system = interface_system | 165 implementation_system._interface_system = interface_system |
| 159 | 166 |
| 160 for system in [interface_system, implementation_system]: | 167 for system in [interface_system, implementation_system]: |
| 161 generator.Generate(target_database, system, | 168 generator.Generate(target_database, system, |
| 162 source_filter=['WebKit', 'Dart'], | 169 source_filter=['WebKit', 'Dart'], |
| 163 super_database=common_database, | 170 super_database=common_database, |
| 164 common_prefix='common', | 171 common_prefix='common', |
| 165 webkit_renames=_webkit_renames, | 172 webkit_renames=_webkit_renames, |
| 166 html_renames=html_renames) | 173 html_renames=html_renames) |
| 167 | 174 |
| 168 _logger.info('Flush...') | 175 _logger.info('Flush...') |
| 169 emitters.Flush() | 176 emitters.Flush() |
| 170 | 177 |
| 178 def GenerateSingleFile(systems): |
| 171 if 'frog' in systems: | 179 if 'frog' in systems: |
| 172 _logger.info('Copy dom_frog to frog/') | 180 _logger.info('Copy dom_frog to frog/') |
| 173 subprocess.call(['cd ../generated ; ' | 181 subprocess.call(['cd ../generated ; ' |
| 174 '../../../tools/copy_dart.py ../frog dom_frog.dart'], | 182 '../../../tools/copy_dart.py ../frog dom_frog.dart'], |
| 175 shell=True); | 183 shell=True); |
| 176 | 184 |
| 177 if 'htmlfrog' in systems: | 185 if 'htmlfrog' in systems: |
| 178 _logger.info('Copy html_frog to ../html/frog/') | 186 _logger.info('Copy html_frog to ../html/frog/') |
| 179 subprocess.call(['cd ../../html/generated ; ' | 187 subprocess.call(['cd ../../html/generated ; ' |
| 180 '../../../tools/copy_dart.py ../frog html_frog.dart'], | 188 '../../../tools/copy_dart.py ../frog html_frog.dart'], |
| (...skipping 11 matching lines...) Expand all Loading... |
| 192 subprocess.call(['cd ../generated ; ' | 200 subprocess.call(['cd ../generated ; ' |
| 193 '../../../tools/copy_dart.py dummy dom_dummy.dart ;' | 201 '../../../tools/copy_dart.py dummy dom_dummy.dart ;' |
| 194 'cp dummy/dom_dummy.dart ../dom.dart'], | 202 'cp dummy/dom_dummy.dart ../dom.dart'], |
| 195 shell=True); | 203 shell=True); |
| 196 | 204 |
| 197 def main(): | 205 def main(): |
| 198 parser = optparse.OptionParser() | 206 parser = optparse.OptionParser() |
| 199 parser.add_option('--systems', dest='systems', | 207 parser.add_option('--systems', dest='systems', |
| 200 action='store', type='string', | 208 action='store', type='string', |
| 201 default='frog,dummy,htmlfrog,htmldartium', | 209 default='frog,dummy,htmlfrog,htmldartium', |
| 202 help='Systems to generate (frog, native, dummy, ' | 210 help='Systems to generate (frog, dummy, ' |
| 203 'htmlfrog, htmldartium)') | 211 'htmlfrog, htmldartium)') |
| 204 parser.add_option('--output-dir', dest='output_dir', | 212 parser.add_option('--output-dir', dest='output_dir', |
| 205 action='store', type='string', | 213 action='store', type='string', |
| 206 default=None, | 214 default=None, |
| 207 help='Directory to put the generated files') | 215 help='Directory to put the generated files') |
| 208 parser.add_option('--use-database-cache', dest='use_database_cache', | 216 parser.add_option('--use-database-cache', dest='use_database_cache', |
| 209 action='store_true', | 217 action='store_true', |
| 210 default=False, | 218 default=False, |
| 211 help='''Use the cached database from the previous run to | 219 help='''Use the cached database from the previous run to |
| 212 improve startup performance''') | 220 improve startup performance''') |
| 213 (options, args) = parser.parse_args() | 221 (options, args) = parser.parse_args() |
| 214 | 222 |
| 215 current_dir = os.path.dirname(__file__) | 223 current_dir = os.path.dirname(__file__) |
| 216 database_dir = os.path.join(current_dir, '..', 'database') | 224 database_dir = os.path.join(current_dir, '..', 'database') |
| 217 logging.config.fileConfig(os.path.join(current_dir, 'logging.conf')) | 225 logging.config.fileConfig(os.path.join(current_dir, 'logging.conf')) |
| 218 systems = options.systems.split(',') | 226 systems = options.systems.split(',') |
| 219 | 227 |
| 220 dom_output_dir = options.output_dir or os.path.join(current_dir, | 228 dom_output_dir = options.output_dir or os.path.join(current_dir, |
| 221 '../generated') | 229 '../generated') |
| 222 html_output_dir = options.output_dir or os.path.join(current_dir, | 230 html_output_dir = options.output_dir or os.path.join(current_dir, |
| 223 '../../html/generated') | 231 '../../html/generated') |
| 224 Generate(systems, database_dir, options.use_database_cache, | 232 Generate(systems, database_dir, options.use_database_cache, |
| 225 dom_output_dir, html_output_dir) | 233 dom_output_dir, html_output_dir) |
| 234 GenerateSingleFile(systems) |
| 226 | 235 |
| 227 if __name__ == '__main__': | 236 if __name__ == '__main__': |
| 228 sys.exit(main()) | 237 sys.exit(main()) |
| OLD | NEW |