| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 exclude_displaced = ['WebKit'], | 61 exclude_displaced = ['WebKit'], |
| 62 exclude_suppressed = ['WebKit', 'Dart']) | 62 exclude_suppressed = ['WebKit', 'Dart']) |
| 63 generator.RenameTypes(webkit_database, _webkit_renames, True) | 63 generator.RenameTypes(webkit_database, _webkit_renames, True) |
| 64 generator.FixEventTargets(webkit_database) | 64 generator.FixEventTargets(webkit_database) |
| 65 generator.AddMissingArguments(webkit_database) | 65 generator.AddMissingArguments(webkit_database) |
| 66 | 66 |
| 67 emitters = multiemitter.MultiEmitter() | 67 emitters = multiemitter.MultiEmitter() |
| 68 renamer = HtmlRenamer(webkit_database) | 68 renamer = HtmlRenamer(webkit_database) |
| 69 type_registry = TypeRegistry(webkit_database, renamer) | 69 type_registry = TypeRegistry(webkit_database, renamer) |
| 70 | 70 |
| 71 def CreateGeneratorOptions(template_paths, conditions, type_registry, output_d
ir, | 71 def CreateGeneratorOptions(template_paths, conditions, output_dir): |
| 72 renamer=None): | |
| 73 template_loader = TemplateLoader(template_dir, template_paths, conditions) | 72 template_loader = TemplateLoader(template_dir, template_paths, conditions) |
| 74 return GeneratorOptions( | 73 return GeneratorOptions( |
| 75 template_loader, webkit_database, emitters, type_registry, renamer, | 74 template_loader, webkit_database, emitters, type_registry, renamer, |
| 76 output_dir) | 75 output_dir, auxiliary_dir) |
| 77 | 76 |
| 78 def Generate(backend, output_dir): | 77 def Generate(backend, output_dir): |
| 79 options = CreateGeneratorOptions( | 78 options = CreateGeneratorOptions( |
| 80 ['html/interface', 'html/impl', 'html', ''], {}, | 79 ['html/interface', 'html/impl', 'html', ''], {}, output_dir) |
| 81 type_registry, output_dir, renamer) | |
| 82 html_system = HtmlInterfacesSystem(options, backend) | 80 html_system = HtmlInterfacesSystem(options, backend) |
| 83 generator.Generate(webkit_database, html_system, | 81 generator.Generate(webkit_database, html_system, |
| 84 super_database=common_database, | 82 super_database=common_database, |
| 85 webkit_renames=_webkit_renames) | 83 webkit_renames=_webkit_renames) |
| 86 | 84 |
| 87 if dart2js_output_dir: | 85 if dart2js_output_dir: |
| 88 options = CreateGeneratorOptions( | 86 options = CreateGeneratorOptions( |
| 89 ['html/dart2js', 'html/impl', 'html', ''], | 87 ['html/dart2js', 'html/impl', 'html', ''], |
| 90 {'DARTIUM': False, 'DART2JS': True}, | 88 {'DARTIUM': False, 'DART2JS': True}, dart2js_output_dir) |
| 91 type_registry, dart2js_output_dir, renamer) | |
| 92 backend = HtmlDart2JSSystem(options) | 89 backend = HtmlDart2JSSystem(options) |
| 93 Generate(backend, dart2js_output_dir) | 90 Generate(backend, dart2js_output_dir) |
| 94 | 91 |
| 95 if dartium_output_dir: | 92 if dartium_output_dir: |
| 96 options = CreateGeneratorOptions( | 93 options = CreateGeneratorOptions( |
| 97 ['html/dartium', 'html/impl', ''], | 94 ['html/dartium', 'html/impl', ''], |
| 98 {'DARTIUM': True, 'DART2JS': False}, | 95 {'DARTIUM': True, 'DART2JS': False}, dartium_output_dir) |
| 99 type_registry, dartium_output_dir, renamer) | 96 backend = NativeImplementationSystem(options) |
| 100 backend = NativeImplementationSystem(options, auxiliary_dir) | |
| 101 Generate(backend, dartium_output_dir) | 97 Generate(backend, dartium_output_dir) |
| 102 | 98 |
| 103 _logger.info('Flush...') | 99 _logger.info('Flush...') |
| 104 emitters.Flush() | 100 emitters.Flush() |
| 105 | 101 |
| 106 def GenerateSingleFile(systems): | 102 def GenerateSingleFile(library_path, output_dir): |
| 107 if 'htmldart2js' in systems: | 103 library_dir = os.path.dirname(library_path) |
| 108 _logger.info('Copy html_dart2js to dart2js/') | 104 library_filename = os.path.basename(library_path) |
| 109 subprocess.call(['cd ../generated ; ' | 105 copy_dart_path = os.path.relpath('../../../tools/copy_dart.py', library_dir) |
| 110 '../../../tools/copy_dart.py ../dart2js html_dart2js.dart']
, | 106 output_dir = os.path.relpath(output_dir, library_dir) |
| 111 shell=True) | 107 command = ' '.join(['cd', library_dir, ';', |
| 112 | 108 copy_dart_path, output_dir, library_filename]) |
| 113 if 'htmldartium' in systems: | 109 subprocess.call([command], shell=True) |
| 114 _logger.info('Copy html_dartium to dartium/') | |
| 115 subprocess.call(['cd ../generated ; ' | |
| 116 '../../../tools/copy_dart.py ../dartium html_dartium.dart']
, | |
| 117 shell=True) | |
| 118 | 110 |
| 119 def main(): | 111 def main(): |
| 120 parser = optparse.OptionParser() | 112 parser = optparse.OptionParser() |
| 121 parser.add_option('--systems', dest='systems', | 113 parser.add_option('--systems', dest='systems', |
| 122 action='store', type='string', | 114 action='store', type='string', |
| 123 default='htmldart2js,htmldartium', | 115 default='htmldart2js,htmldartium', |
| 124 help='Systems to generate (htmldart2js, htmldartium)') | 116 help='Systems to generate (htmldart2js, htmldartium)') |
| 125 parser.add_option('--output-dir', dest='output_dir', | 117 parser.add_option('--output-dir', dest='output_dir', |
| 126 action='store', type='string', | 118 action='store', type='string', |
| 127 default=None, | 119 default=None, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 138 logging.config.fileConfig(os.path.join(current_dir, 'logging.conf')) | 130 logging.config.fileConfig(os.path.join(current_dir, 'logging.conf')) |
| 139 systems = options.systems.split(',') | 131 systems = options.systems.split(',') |
| 140 | 132 |
| 141 output_dir = options.output_dir or os.path.join(current_dir, '../generated') | 133 output_dir = options.output_dir or os.path.join(current_dir, '../generated') |
| 142 dart2js_output_dir = None | 134 dart2js_output_dir = None |
| 143 if 'htmldart2js' in systems: | 135 if 'htmldart2js' in systems: |
| 144 dart2js_output_dir = os.path.join(output_dir, 'dart2js') | 136 dart2js_output_dir = os.path.join(output_dir, 'dart2js') |
| 145 dartium_output_dir = None | 137 dartium_output_dir = None |
| 146 if 'htmldartium' in systems: | 138 if 'htmldartium' in systems: |
| 147 dartium_output_dir = os.path.join(output_dir, 'dartium') | 139 dartium_output_dir = os.path.join(output_dir, 'dartium') |
| 140 |
| 148 Generate(database_dir, options.use_database_cache, dart2js_output_dir, | 141 Generate(database_dir, options.use_database_cache, dart2js_output_dir, |
| 149 dartium_output_dir) | 142 dartium_output_dir) |
| 150 GenerateSingleFile(systems) | 143 |
| 144 if 'htmldart2js' in systems: |
| 145 _logger.info('Copy html_dart2js to dart2js/') |
| 146 GenerateSingleFile(os.path.join(dart2js_output_dir, 'html_dart2js.dart'), |
| 147 '../dart2js') |
| 148 if 'htmldartium' in systems: |
| 149 _logger.info('Copy html_dartium to dartium/') |
| 150 GenerateSingleFile(os.path.join(dartium_output_dir, 'html_dartium.dart'), |
| 151 '../dartium') |
| 151 | 152 |
| 152 if __name__ == '__main__': | 153 if __name__ == '__main__': |
| 153 sys.exit(main()) | 154 sys.exit(main()) |
| OLD | NEW |