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 import database | 6 import database |
7 import databasebuilder | 7 import databasebuilder |
8 import idlparser | |
9 import logging.config | 8 import logging.config |
10 import os.path | 9 import os.path |
11 import sys | 10 import sys |
12 import time | 11 import time |
13 | 12 |
14 _logger = logging.getLogger('fremontcutbuilder') | 13 _logger = logging.getLogger('fremontcutbuilder') |
15 | 14 |
16 # See: | 15 # See: |
17 # http://src.chromium.org/viewvc/multivm/trunk/webkit/Source/core/features.gypi | 16 # http://src.chromium.org/viewvc/multivm/trunk/webkit/Source/core/features.gypi |
18 # for ENABLE_* flags defined in Chromium / Blink. | 17 # for ENABLE_* flags defined in Chromium / Blink. |
19 # We list all ENABLE flags used in IDL in one of these two lists. | 18 # We list all ENABLE flags used in IDL in one of these two lists. |
20 FEATURE_DISABLED = [ | 19 FEATURE_DISABLED = [ |
21 'ENABLE_CUSTOM_SCHEME_HANDLER', | 20 'ENABLE_CUSTOM_SCHEME_HANDLER', |
22 'ENABLE_MEDIA_CAPTURE', # Only enabled on Android. | 21 'ENABLE_MEDIA_CAPTURE', # Only enabled on Android. |
23 'ENABLE_ORIENTATION_EVENTS', # Only enabled on Android. | 22 'ENABLE_ORIENTATION_EVENTS', # Only enabled on Android. |
24 'ENABLE_WEBVTT_REGIONS', | 23 'ENABLE_WEBVTT_REGIONS', |
25 ] | 24 ] |
26 | 25 |
27 FEATURE_DEFINES = [ | 26 FEATURE_DEFINES = [ |
28 'ENABLE_CALENDAR_PICKER', # Not on Android | 27 'ENABLE_CALENDAR_PICKER', # Not on Android |
29 'ENABLE_ENCRYPTED_MEDIA_V2', | 28 'ENABLE_ENCRYPTED_MEDIA_V2', |
30 'ENABLE_INPUT_SPEECH', # Not on Android | 29 'ENABLE_INPUT_SPEECH', # Not on Android |
31 'ENABLE_LEGACY_NOTIFICATIONS', # Not on Android | 30 'ENABLE_LEGACY_NOTIFICATIONS', # Not on Android |
32 'ENABLE_NAVIGATOR_CONTENT_UTILS', # Not on Android | 31 'ENABLE_NAVIGATOR_CONTENT_UTILS', # Not on Android |
33 'ENABLE_NOTIFICATIONS', # Not on Android | 32 'ENABLE_NOTIFICATIONS', # Not on Android |
34 'ENABLE_SVG_FONTS', | 33 'ENABLE_SVG_FONTS', |
35 'ENABLE_WEB_AUDIO', # Not on Android | 34 'ENABLE_WEB_AUDIO', # Not on Android |
36 ] | 35 ] |
37 | 36 |
38 def build_database(idl_files, database_dir, feature_defines=None, parallel=False
, | 37 def build_database(idl_files, database_dir, feature_defines=None, |
39 blink_parser=False, logging_level=logging.WARNING): | 38 logging_level=logging.WARNING): |
40 """This code reconstructs the FremontCut IDL database from W3C, | 39 """This code reconstructs the FremontCut IDL database from W3C, |
41 WebKit and Dart IDL files.""" | 40 WebKit and Dart IDL files.""" |
42 current_dir = os.path.dirname(__file__) | 41 current_dir = os.path.dirname(__file__) |
43 logging.config.fileConfig(os.path.join(current_dir, "logging.conf")) | 42 logging.config.fileConfig(os.path.join(current_dir, "logging.conf")) |
44 | 43 |
45 _logger.setLevel(logging_level) | 44 _logger.setLevel(logging_level) |
46 | 45 |
47 db = database.Database(database_dir) | 46 db = database.Database(database_dir) |
48 | 47 |
49 # Delete all existing IDLs in the DB. | 48 # Delete all existing IDLs in the DB. |
50 db.Delete() | 49 db.Delete() |
51 | 50 |
52 builder = databasebuilder.DatabaseBuilder(db) | 51 builder = databasebuilder.DatabaseBuilder(db) |
53 | 52 |
54 # TODO(vsm): Move this to a README. | 53 # TODO(vsm): Move this to a README. |
55 # This is the Dart SVN revision. | 54 # This is the Dart SVN revision. |
56 webkit_revision = '1060' | 55 webkit_revision = '1060' |
57 | 56 |
58 # TODO(vsm): Reconcile what is exposed here and inside WebKit code | 57 # TODO(vsm): Reconcile what is exposed here and inside WebKit code |
59 # generation. We need to recheck this periodically for now. | 58 # generation. We need to recheck this periodically for now. |
60 webkit_defines = [ 'LANGUAGE_DART', 'LANGUAGE_JAVASCRIPT' ] | 59 webkit_defines = [ 'LANGUAGE_DART', 'LANGUAGE_JAVASCRIPT' ] |
61 | 60 |
62 if feature_defines is None: | 61 if feature_defines is None: |
63 feature_defines = FEATURE_DEFINES | 62 feature_defines = FEATURE_DEFINES |
64 | 63 |
65 webkit_options = databasebuilder.DatabaseBuilderOptions( | 64 webkit_options = databasebuilder.DatabaseBuilderOptions( |
66 idl_syntax=idlparser.WEBKIT_SYNTAX, | |
67 # TODO(vsm): What else should we define as on when processing IDL? | 65 # TODO(vsm): What else should we define as on when processing IDL? |
68 idl_defines=webkit_defines + feature_defines, | 66 idl_defines=webkit_defines + feature_defines, |
69 source='WebKit', | 67 source='WebKit', |
70 source_attributes={'revision': webkit_revision}, | 68 source_attributes={'revision': webkit_revision}, |
71 logging_level=logging_level) | 69 logging_level=logging_level) |
72 | 70 |
73 # Import WebKit IDLs. | 71 # Import WebKit IDLs. |
74 builder.import_idl_files(idl_files, webkit_options, parallel, blink_parser, Fa
lse) | 72 builder.import_idl_files(idl_files, webkit_options, False) |
75 | 73 |
76 # Import Dart idl: | 74 # Import Dart idl: |
77 dart_options = databasebuilder.DatabaseBuilderOptions( | 75 dart_options = databasebuilder.DatabaseBuilderOptions( |
78 idl_syntax=idlparser.FREMONTCUT_SYNTAX, | |
79 source='Dart', | 76 source='Dart', |
80 rename_operation_arguments_on_merge=True, | 77 rename_operation_arguments_on_merge=True, |
81 logging_level=logging_level) | 78 logging_level=logging_level) |
82 | 79 |
83 builder.import_idl_files( | 80 builder.import_idl_files( |
84 [ os.path.join(current_dir, '..', 'idl', 'dart', 'dart.idl') ], | 81 [ os.path.join(current_dir, '..', 'idl', 'dart', 'dart.idl') ], |
85 dart_options, parallel, blink_parser, True) | 82 dart_options, True) |
86 | 83 |
87 start_time = time.time() | 84 start_time = time.time() |
88 | 85 |
89 # Merging: | 86 # Merging: |
90 builder.merge_imported_interfaces(blink_parser) | 87 builder.merge_imported_interfaces() |
91 | 88 |
92 builder.fetch_constructor_data(webkit_options) | 89 builder.fetch_constructor_data(webkit_options) |
93 builder.fix_displacements('WebKit') | 90 builder.fix_displacements('WebKit') |
94 | 91 |
95 # Cleanup: | 92 # Cleanup: |
96 builder.normalize_annotations(['WebKit', 'Dart']) | 93 builder.normalize_annotations(['WebKit', 'Dart']) |
97 | 94 |
98 conditionals_met = set( | 95 conditionals_met = set( |
99 'ENABLE_' + conditional for conditional in builder.conditionals_met) | 96 'ENABLE_' + conditional for conditional in builder.conditionals_met) |
100 known_conditionals = set(FEATURE_DEFINES + FEATURE_DISABLED) | 97 known_conditionals = set(FEATURE_DEFINES + FEATURE_DISABLED) |
(...skipping 10 matching lines...) Expand all Loading... |
111 sorted(unknown_conditionals)) | 108 sorted(unknown_conditionals)) |
112 _logger.warning('Please update fremontcutbuilder.py') | 109 _logger.warning('Please update fremontcutbuilder.py') |
113 | 110 |
114 print 'Merging interfaces %s seconds' % round(time.time() - start_time, 2) | 111 print 'Merging interfaces %s seconds' % round(time.time() - start_time, 2) |
115 | 112 |
116 # TODO(terry): Don't generate the database cache. | 113 # TODO(terry): Don't generate the database cache. |
117 # db.Save() | 114 # db.Save() |
118 | 115 |
119 return db | 116 return db |
120 | 117 |
121 def main(parallel=False, blink_parser=False, logging_level=logging.WARNING): | 118 def main(parallel=False, logging_level=logging.WARNING): |
122 current_dir = os.path.dirname(__file__) | 119 current_dir = os.path.dirname(__file__) |
123 | 120 |
124 idl_files = [] | 121 idl_files = [] |
125 | 122 |
126 # Check default location in a regular dart enlistment. | 123 # Check default location in a regular dart enlistment. |
127 webcore_dir = os.path.join(current_dir, '..', '..', '..', 'third_party', | 124 webcore_dir = os.path.join(current_dir, '..', '..', '..', 'third_party', |
128 'WebCore') | 125 'WebCore') |
129 | 126 |
130 if not os.path.exists(webcore_dir): | 127 if not os.path.exists(webcore_dir): |
131 # Check default location in a dartium enlistment. | 128 # Check default location in a dartium enlistment. |
(...skipping 25 matching lines...) Expand all Loading... |
157 for name in names: | 154 for name in names: |
158 file_name = os.path.join(dir_name, name) | 155 file_name = os.path.join(dir_name, name) |
159 (interface, ext) = os.path.splitext(file_name) | 156 (interface, ext) = os.path.splitext(file_name) |
160 if ext == '.idl' and not(name in FILES_TO_IGNORE): | 157 if ext == '.idl' and not(name in FILES_TO_IGNORE): |
161 idl_files.append(file_name) | 158 idl_files.append(file_name) |
162 | 159 |
163 os.path.walk(webcore_dir, visitor, webcore_dir) | 160 os.path.walk(webcore_dir, visitor, webcore_dir) |
164 | 161 |
165 database_dir = os.path.join(current_dir, '..', 'database') | 162 database_dir = os.path.join(current_dir, '..', 'database') |
166 | 163 |
167 return build_database(idl_files, database_dir, parallel=parallel, | 164 return build_database(idl_files, database_dir, logging_level=logging_level) |
168 blink_parser=blink_parser, logging_level=logging_level) | |
169 | 165 |
170 if __name__ == '__main__': | 166 if __name__ == '__main__': |
171 sys.exit(main()) | 167 sys.exit(main()) |
OLD | NEW |