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 optparse | 11 import optparse |
12 import os | 12 import os |
13 import shutil | 13 import shutil |
14 import sys | 14 import sys |
15 | 15 |
16 DOM_LIBRARY = 'dom.dart' | 16 DOM_LIBRARY = 'dom.dart' |
17 DOM_DEFAULT_LIBRARY = 'wrapping_dom.dart' | 17 DOM_DEFAULT_LIBRARY = 'dom_dummy.dart' |
18 DEFAULT_SYSTEM = 'wrapping' | 18 DEFAULT_SYSTEM = 'dummy' |
19 | 19 |
20 _logger = logging.getLogger('dartdomgenerator') | 20 _logger = logging.getLogger('dartdomgenerator') |
21 | 21 |
22 _webkit_renames = { | 22 _webkit_renames = { |
23 # W3C -> WebKit name conversion | 23 # W3C -> WebKit name conversion |
24 # TODO(vsm): Maybe Store these renames in the IDLs. | 24 # TODO(vsm): Maybe Store these renames in the IDLs. |
25 'ApplicationCache': 'DOMApplicationCache', | 25 'ApplicationCache': 'DOMApplicationCache', |
26 'BarProp': 'BarInfo', | 26 'BarProp': 'BarInfo', |
27 'DedicatedWorkerGlobalScope': 'DedicatedWorkerContext', | 27 'DedicatedWorkerGlobalScope': 'DedicatedWorkerContext', |
28 'FormData': 'DOMFormData', | 28 'FormData': 'DOMFormData', |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 common_prefix = 'common', | 83 common_prefix = 'common', |
84 super_map = _webkit_renames_inverse, | 84 super_map = _webkit_renames_inverse, |
85 systems = systems) | 85 systems = systems) |
86 | 86 |
87 generator.Flush() | 87 generator.Flush() |
88 | 88 |
89 def main(): | 89 def main(): |
90 parser = optparse.OptionParser() | 90 parser = optparse.OptionParser() |
91 parser.add_option('--systems', dest='systems', | 91 parser.add_option('--systems', dest='systems', |
92 action='store', type='string', | 92 action='store', type='string', |
93 default='frog,wrapping', | 93 default='frog,dummy', |
94 help='Systems to generate (frog, native, wrapping)') | 94 help='Systems to generate (frog, native, dummy)') |
95 parser.add_option('--output-dir', dest='output_dir', | 95 parser.add_option('--output-dir', dest='output_dir', |
96 action='store', type='string', | 96 action='store', type='string', |
97 default=None, | 97 default=None, |
98 help='Directory to put the generated files') | 98 help='Directory to put the generated files') |
99 (options, args) = parser.parse_args() | 99 (options, args) = parser.parse_args() |
100 | 100 |
101 current_dir = os.path.dirname(__file__) | 101 current_dir = os.path.dirname(__file__) |
102 output_dir = options.output_dir or os.path.join(current_dir, '..') | 102 output_dir = options.output_dir or os.path.join(current_dir, '..') |
103 systems = options.systems.split(',') | 103 systems = options.systems.split(',') |
104 | 104 |
105 logging.config.fileConfig(os.path.join(current_dir, 'logging.conf')) | 105 logging.config.fileConfig(os.path.join(current_dir, 'logging.conf')) |
106 GenerateDOM(systems, output_dir) | 106 GenerateDOM(systems, output_dir) |
107 | 107 |
108 if DEFAULT_SYSTEM in systems: | 108 if DEFAULT_SYSTEM in systems: |
109 # Install default DOM library. | 109 # Install default DOM library. |
110 default = os.path.join(output_dir, DOM_DEFAULT_LIBRARY) | 110 default = os.path.join(output_dir, DOM_DEFAULT_LIBRARY) |
111 target = os.path.join(output_dir, DOM_LIBRARY) | 111 target = os.path.join(output_dir, DOM_LIBRARY) |
112 shutil.copyfile(default, target) | 112 shutil.copyfile(default, target) |
113 | 113 |
114 if __name__ == '__main__': | 114 if __name__ == '__main__': |
115 sys.exit(main()) | 115 sys.exit(main()) |
OLD | NEW |