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 |
11 import multiemitter | 11 import multiemitter |
12 import optparse | 12 import optparse |
13 import os | 13 import os |
14 import shutil | 14 import shutil |
15 import subprocess | 15 import subprocess |
16 import sys | 16 import sys |
| 17 from generator import TypeRegistry |
| 18 from systembase import GeneratorOptions |
17 from systemfrog import FrogSystem | 19 from systemfrog import FrogSystem |
18 from systemhtml import HtmlInterfacesSystem, HtmlFrogSystem | 20 from systemhtml import HtmlInterfacesSystem, HtmlFrogSystem |
19 from systeminterface import InterfacesSystem | 21 from systeminterface import InterfacesSystem |
20 from systemnative import NativeImplementationSystem | 22 from systemnative import NativeImplementationSystem |
21 from templateloader import TemplateLoader | 23 from templateloader import TemplateLoader |
22 | 24 |
23 _logger = logging.getLogger('dartdomgenerator') | 25 _logger = logging.getLogger('dartdomgenerator') |
24 | 26 |
25 _webkit_renames = { | 27 _webkit_renames = { |
26 # W3C -> WebKit name conversion | 28 # W3C -> WebKit name conversion |
(...skipping 26 matching lines...) Expand all Loading... |
53 webkit_database = common_database.Clone() | 55 webkit_database = common_database.Clone() |
54 | 56 |
55 # Generate Dart interfaces for the WebKit DOM. | 57 # Generate Dart interfaces for the WebKit DOM. |
56 generator.FilterInterfaces(database = webkit_database, | 58 generator.FilterInterfaces(database = webkit_database, |
57 or_annotations = ['WebKit', 'Dart'], | 59 or_annotations = ['WebKit', 'Dart'], |
58 exclude_displaced = ['WebKit'], | 60 exclude_displaced = ['WebKit'], |
59 exclude_suppressed = ['WebKit', 'Dart']) | 61 exclude_suppressed = ['WebKit', 'Dart']) |
60 generator.RenameTypes(webkit_database, _webkit_renames, True) | 62 generator.RenameTypes(webkit_database, _webkit_renames, True) |
61 generator.FixEventTargets(webkit_database) | 63 generator.FixEventTargets(webkit_database) |
62 | 64 |
| 65 def CreateGeneratorOptions(template_paths, conditions, output_dir): |
| 66 return GeneratorOptions( |
| 67 TemplateLoader(template_dir, template_paths, conditions), |
| 68 webkit_database, emitters, TypeRegistry(), output_dir) |
| 69 |
63 def Generate(system): | 70 def Generate(system): |
64 generator.Generate(webkit_database, system, | 71 generator.Generate(webkit_database, system, |
65 super_database=common_database, | 72 super_database=common_database, |
66 webkit_renames=_webkit_renames) | 73 webkit_renames=_webkit_renames) |
67 | 74 |
68 emitters = multiemitter.MultiEmitter() | 75 emitters = multiemitter.MultiEmitter() |
69 | 76 |
70 for system_name in system_names: | 77 for system_name in system_names: |
71 if system_name in ['htmlfrog', 'htmldartium']: | 78 if system_name in ['htmlfrog', 'htmldartium']: |
72 output_dir = html_output_dir | |
73 if system_name == 'htmlfrog': | 79 if system_name == 'htmlfrog': |
74 backend = HtmlFrogSystem( | 80 options = CreateGeneratorOptions( |
75 TemplateLoader(template_dir, | 81 ['html/frog', 'html/impl', 'html', ''], |
76 ['html/frog', 'html/impl', 'html', ''], | 82 {'DARTIUM': False, 'FROG': True}, |
77 {'DARTIUM': False, 'FROG': True}), | 83 html_output_dir) |
78 webkit_database, emitters, output_dir) | 84 backend = HtmlFrogSystem(options) |
79 else: | 85 else: |
80 backend = NativeImplementationSystem( | 86 options = CreateGeneratorOptions( |
81 TemplateLoader(template_dir, ['dom/native', 'html/dartium', | 87 ['dom/native', 'html/dartium', 'html/impl', ''], |
82 'html/impl', ''], | 88 {'DARTIUM': True, 'FROG': False}, |
83 {'DARTIUM': True, 'FROG': False}), | 89 html_output_dir) |
84 webkit_database, emitters, output_dir, auxiliary_dir) | 90 backend = NativeImplementationSystem(options, auxiliary_dir) |
85 html_system = HtmlInterfacesSystem( | 91 options = CreateGeneratorOptions( |
86 TemplateLoader(template_dir, ['html/interface', 'html/impl', 'html', | 92 ['html/interface', 'html/impl', 'html', ''], {}, html_output_dir) |
87 '']), | 93 html_system = HtmlInterfacesSystem(options, backend) |
88 webkit_database, emitters, output_dir, backend) | |
89 Generate(html_system) | 94 Generate(html_system) |
90 else: | 95 else: |
91 output_dir = dom_output_dir | 96 options = CreateGeneratorOptions( |
92 interface_system = InterfacesSystem( | 97 ['dom/interface', 'dom', ''], {}, dom_output_dir) |
93 TemplateLoader(template_dir, ['dom/interface', 'dom', '']), | 98 interface_system = InterfacesSystem(options) |
94 webkit_database, emitters, output_dir) | |
95 if system_name == 'dummy': | 99 if system_name == 'dummy': |
| 100 options = CreateGeneratorOptions( |
| 101 ['dom/dummy', 'dom', ''], {}, dom_output_dir) |
96 implementation_system = dartgenerator.DummyImplementationSystem( | 102 implementation_system = dartgenerator.DummyImplementationSystem( |
97 TemplateLoader(template_dir, ['dom/dummy', 'dom', '']), | 103 options) |
98 webkit_database, emitters, output_dir) | |
99 elif system_name == 'frog': | 104 elif system_name == 'frog': |
100 implementation_system = FrogSystem( | 105 options = CreateGeneratorOptions( |
101 TemplateLoader(template_dir, ['dom/frog', 'dom', '']), | 106 ['dom/frog', 'dom', ''], {}, dom_output_dir) |
102 webkit_database, emitters, output_dir) | 107 implementation_system = FrogSystem(options) |
103 else: | 108 else: |
104 raise Exception('Unsupported system_name %s' % system_name) | 109 raise Exception('Unsupported system_name %s' % system_name) |
105 | 110 |
106 # Makes interface files available for listing in the library for the | 111 # Makes interface files available for listing in the library for the |
107 # implementation system. | 112 # implementation system. |
108 implementation_system._interface_system = interface_system | 113 implementation_system._interface_system = interface_system |
109 Generate(interface_system) | 114 Generate(interface_system) |
110 Generate(implementation_system) | 115 Generate(implementation_system) |
111 | 116 |
112 _logger.info('Flush...') | 117 _logger.info('Flush...') |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 dom_output_dir = options.output_dir or os.path.join(current_dir, | 170 dom_output_dir = options.output_dir or os.path.join(current_dir, |
166 '../generated') | 171 '../generated') |
167 html_output_dir = options.output_dir or os.path.join(current_dir, | 172 html_output_dir = options.output_dir or os.path.join(current_dir, |
168 '../../html/generated') | 173 '../../html/generated') |
169 Generate(systems, database_dir, options.use_database_cache, | 174 Generate(systems, database_dir, options.use_database_cache, |
170 dom_output_dir, html_output_dir) | 175 dom_output_dir, html_output_dir) |
171 GenerateSingleFile(systems) | 176 GenerateSingleFile(systems) |
172 | 177 |
173 if __name__ == '__main__': | 178 if __name__ == '__main__': |
174 sys.exit(main()) | 179 sys.exit(main()) |
OLD | NEW |